From 219e00f3b8caec38a9c8fbb4d70e33455aba5a92 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 13 Oct 2022 09:00:11 +0200 Subject: Optimize by going straight to public variable pool where applicable --- libbuild2/dist/init.cxx | 52 +++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 23 deletions(-) (limited to 'libbuild2/dist/init.cxx') diff --git a/libbuild2/dist/init.cxx b/libbuild2/dist/init.cxx index 5e371bf..26ff86d 100644 --- a/libbuild2/dist/init.cxx +++ b/libbuild2/dist/init.cxx @@ -33,7 +33,34 @@ namespace build2 // Enter module variables. Do it during boot in case they get assigned // in bootstrap.build (which is customary for, e.g., dist.package). // - auto& vp (rs.var_pool ()); + + // The dist flag or path. Normally it is a flag (true or false) but can + // also be used to remap the distribution location. + // + // In the latter case it specifies the "imaginary" source location which + // is used to derive the corresponding distribution local. This location + // can be specified as either a directory path (to remap with the same + // file name) or a file path (to remap with a different name). And the + // way we distinguish between the two is via the presence/absence of the + // trailing directory separator. If the path is relative, then it's + // treated relative to the target directory. Note that to make things + // less error prone, simple paths without any directory separators are + // not allowed (use ./ instead). + // + // Note that if multiple targets end up with the same source location, + // the behavior is undefined and no diagnostics is issued. + // + // Note also that such remapping has no effect in the bootstrap + // distribution mode. + // + // Note: project-private. + // + rs.var_pool ().insert ("dist", variable_visibility::target); + + // The rest of the variables we enter are qualified so go straight for + // the public variable pool. + // + auto& vp (rs.var_pool (true /* public */)); // config.dist.archives is a list of archive extensions (e.g., zip, // tar.gz) that can be optionally prefixed with a directory. If it is @@ -72,27 +99,6 @@ namespace build2 vp.insert ("dist.archives"); vp.insert ("dist.checksums"); - // The dist flag or path. Normally it is a flag (true or false) but can - // also be used to remap the distribution location. - // - // In the latter case it specifies the "imaginary" source location which - // is used to derive the corresponding distribution local. This location - // can be specified as either a directory path (to remap with the same - // file name) or a file path (to remap with a different name). And the - // way we distinguish between the two is via the presence/absence of the - // trailing directory separator. If the path is relative, then it's - // treated relative to the target directory. Note that to make things - // less error prone, simple paths without any directory separators are - // not allowed (use ./ instead). - // - // Note that if multiple targets end up with the same source location, - // the behavior is undefined and no diagnostics is issued. - // - // Note also that such remapping has no effect in the bootstrap - // distribution mode. - // - vp.insert ("dist", variable_visibility::target); - // Project's package name. Note: if set, must be in bootstrap.build. // auto& v_d_p (vp.insert ("dist.package")); @@ -202,7 +208,7 @@ namespace build2 l5 ([&]{trace << "for " << rs;}); - auto& vp (rs.var_pool ()); + auto& vp (rs.var_pool (true /* public */)); // All qualified. // Register our wildcard rule. Do it explicitly for the alias to prevent // something like insert(dist_id, test_id) taking precedence. -- cgit v1.1