From c06264486507b0b2306e26f66392b1558fa8a1fb Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 8 Sep 2017 15:56:33 +0200 Subject: Add install::resolve_dir(scope) overload --- build2/install/rule.cxx | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'build2/install/rule.cxx') diff --git a/build2/install/rule.cxx b/build2/install/rule.cxx index 3b17b68..928384a 100644 --- a/build2/install/rule.cxx +++ b/build2/install/rule.cxx @@ -322,8 +322,13 @@ namespace build2 // Resolve installation directory name to absolute directory path. Return // all the super-directories leading up to the destination (last). // + // If target is not NULL, then also handle the subdirs logic. + // static install_dirs - resolve (const target& t, dir_path d, const string* var = nullptr) + resolve (const scope& s, + const target* t, + dir_path d, + const string* var = nullptr) { install_dirs rs; @@ -337,14 +342,13 @@ namespace build2 // const string& sn (*d.begin ()); const string var ("install." + sn); - if (const dir_path* dn = - lookup_install (t.base_scope (), var)) + if (const dir_path* dn = lookup_install (s, var)) { if (dn->empty ()) fail << "empty installation directory for name " << sn << info << "did you specified empty config." << var << "?"; - rs = resolve (t, *dn, &var); + rs = resolve (s, t, *dn, &var); d = rs.back ().dir / dir_path (++d.begin (), d.end ()); rs.emplace_back (move (d.normalize ()), rs.back ()); } @@ -354,7 +358,6 @@ namespace build2 } install_dir* r (&rs.back ()); - const scope& s (t.base_scope ()); // Override components in install_dir if we have our own. // @@ -366,10 +369,13 @@ namespace build2 if (auto l = s[*var + ".dir_mode"]) r->dir_mode = &cast (l); if (auto l = s[*var + ".options"]) r->options = &cast (l); - if (auto l = s[*var + ".subdirs"]) + if (t != nullptr) { - if (cast (l)) - r = &resolve_subdir (rs, t, s, l); + if (auto l = s[*var + ".subdirs"]) + { + if (cast (l)) + r = &resolve_subdir (rs, *t, s, l); + } } } @@ -393,12 +399,24 @@ namespace build2 return rs; } + static inline install_dirs + resolve (const target& t, dir_path d, const string* var = nullptr) + { + return resolve (t.base_scope (), &t, d, var); + } + dir_path resolve_dir (const target& t, dir_path d) { return move (resolve (t, move (d)).back ().dir); } + dir_path + resolve_dir (const scope& s, dir_path d) + { + return move (resolve (s, nullptr, move (d)).back ().dir); + } + path resolve_file (const file& f) { -- cgit v1.1