aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-11-12 10:16:07 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-11-12 10:16:07 +0200
commit87d871e77649d439b4d62208576239d1341eedef (patch)
tree7b5ed940155fde57d242d5289ed08fd0c9231526 /libbuild2
parent4551e5797fe83d4e5e31f3164fcfa3418332ac3d (diff)
Rename config.{import,export} to config.config.{load,save}
Also rename the $config.export() function to $config.save().
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/buildfile2
-rw-r--r--libbuild2/config/functions.cxx10
-rw-r--r--libbuild2/config/init.cxx35
-rw-r--r--libbuild2/config/operation.cxx49
-rw-r--r--libbuild2/config/operation.hxx4
5 files changed, 52 insertions, 48 deletions
diff --git a/libbuild2/buildfile b/libbuild2/buildfile
index 6f368d0..7b88fd4 100644
--- a/libbuild2/buildfile
+++ b/libbuild2/buildfile
@@ -44,7 +44,7 @@ config/cxx{host-config}: config/in{host-config}
# Remove comment lines which could be confused with preprocessor directives
# by some lesser compilers.
#
- host_config = $regex.replace_lines($config.export(), '^ *#.*$', [null], return_lines)
+ host_config = $regex.replace_lines($config.save(), '^ *#.*$', [null], return_lines)
}
libul{build2}: dist/{hxx ixx txx cxx}{** -**.test...}
diff --git a/libbuild2/config/functions.cxx b/libbuild2/config/functions.cxx
index ec4af65..1fada98 100644
--- a/libbuild2/config/functions.cxx
+++ b/libbuild2/config/functions.cxx
@@ -22,21 +22,21 @@ namespace build2
function_family f (m, "config");
// Return the configuration file contents as a string, similar to the
- // config.export variable functionality.
+ // config.config.save variable functionality.
//
// Note that this function can only be used during configure unless the
// config module creation was requested for other meta-operations with
// config.config.module=true in bootstrap.build.
//
- f[".export"] = [] (const scope* s)
+ f[".save"] = [] (const scope* s)
{
if (s == nullptr)
- fail << "config.export() called out of scope" << endf;
+ fail << "config.save() called out of scope" << endf;
s = s->root_scope ();
if (s == nullptr)
- fail << "config.export() called out of project" << endf;
+ fail << "config.save() called out of project" << endf;
ostringstream os;
@@ -44,7 +44,7 @@ namespace build2
//
project_set ps;
save_config (*s,
- os, path_name ("config.export()"),
+ os, path_name ("config.save()"),
false /* inherit */,
ps);
diff --git a/libbuild2/config/init.cxx b/libbuild2/config/init.cxx
index 1775a52..9fc914c 100644
--- a/libbuild2/config/init.cxx
+++ b/libbuild2/config/init.cxx
@@ -47,19 +47,18 @@ namespace build2
//
auto& vp (rs.ctx.var_pool.rw (rs));
- // While config.import could theoretically be specified in a buildfile,
- // config.export is expected to always be specified as a command line
- // override.
+ // While config.config.load could theoretically be specified in a
+ // buildfile, config.config.save is expected to always be specified as a
+ // command line override.
//
- // Note: must be entered during bootstrap since we need them in
+ // Note: must be entered during bootstrap since we need it in
// configure_execute().
//
- vp.insert<path> ("config.export", true /* ovr */);
- vp.insert<paths> ("config.import", true /* ovr */);
+ vp.insert<path> ("config.config.save", true /* ovr */);
// Only create the module if we are configuring or creating or if it was
// requested with config.config.module (useful if we need to call
- // $config.export() during other meta-operations).
+ // $config.save() during other meta-operations).
//
// Detecting the former (configuring/creating) is a bit tricky since the
// build2 core may not yet know if this is the case. But we know.
@@ -73,6 +72,10 @@ namespace build2
(mname.empty () && (oname == "configure" || oname == "create")) ||
cast_false<bool> (rs.vars[c_m]))
{
+ // Used as a variable prefix by configure_execute().
+ //
+ vp.insert ("config.import");
+
unique_ptr<module> m (new module);
// Adjust priority for the import pseudo-module so that
@@ -124,11 +127,12 @@ namespace build2
assert (config_hints.empty ()); // We don't known any hints.
auto& vp (rs.ctx.var_pool.rw (rs));
+ auto& c_l (vp.insert<paths> ("config.config.load", true /* ovr */));
auto& c_v (vp.insert<uint64_t> ("config.version", false /*ovr*/));
// Load config.build if one exists followed by extra files specified in
- // config.import (we don't need to worry about disfigure since we will
- // never be init'ed).
+ // config.config.load (we don't need to worry about disfigure since we
+ // will never be init'ed).
//
auto load_config = [&rs, &c_v] (istream& is,
const path_name& in,
@@ -147,7 +151,8 @@ namespace build2
// than one character back). So what we are going to do is continue
// reading after extracting the variable. One side effect of this is
// that we won't have the config.version variable entered in the scope
- // but that is harmless (we could do it manually if necessary).
+ // but that is harmless (we could do it manually if necessary though
+ // it's not clear which it should be if we load multiple files).
//
lexer lex (is, in);
@@ -181,7 +186,7 @@ namespace build2
load_config_file (f, l);
}
- if (lookup l = rs["config.import"])
+ if (lookup l = rs[c_l])
{
// Only load files that were specified on our root scope as well as
// global overrides. This way we can use our override "positioning"
@@ -189,9 +194,9 @@ namespace build2
// extra config is loaded. The resulting semantics feels quite natural
// and consistent with command line variable overrides:
//
- // b config.import=.../config.build # outermost amalgamation
- // b ./config.import=.../config.build # this project
- // b !config.import=.../config.build # every project
+ // b config.config.load=.../config.build # outermost amalgamation
+ // b ./config.config.load=.../config.build # this project
+ // b !config.config.load=.../config.build # every project
//
if (l.belongs (rs) || l.belongs (rs.ctx.global_scope))
{
@@ -214,7 +219,7 @@ namespace build2
}
else
fail << "unknown special configuration name '" << s << "' in "
- << "config.import";
+ << "config.config.load";
}
}
}
diff --git a/libbuild2/config/operation.cxx b/libbuild2/config/operation.cxx
index ea6ff15..21bf8c1 100644
--- a/libbuild2/config/operation.cxx
+++ b/libbuild2/config/operation.cxx
@@ -115,8 +115,7 @@ namespace build2
}
}
- // If inherit is false, then don't rely on inheritance from outer scopes
- // (used for config.export).
+ // If inherit is false, then don't rely on inheritance from outer scopes.
//
void
save_config (const scope& rs,
@@ -215,7 +214,7 @@ namespace build2
// will be dropped from the amalgamation's config.build on the
// next reconfigure. Let's also warn the user just in case,
// unless there is no module and thus we couldn't really check
- // (the latter could happen when calling $config.export() during
+ // (the latter could happen when calling $config.save() during
// other meta-operations).
//
// There is also another case that falls under this now that
@@ -254,8 +253,8 @@ namespace build2
// such an override even though that project is not
// being configured -- i.e., they would need to
// communicate to us what will have happened once the
- // outer project is reconfigured). Feels like it will be
- // quite obscure and error-prone.
+ // outer project is reconfigured). Feels like this will
+ // be quite obscure and error-prone.
//
if (!found)
found = var.name.compare (0, 14, "config.import.") == 0;
@@ -419,7 +418,7 @@ namespace build2
static void
configure_project (action a,
const scope& rs,
- const variable* c_e, // config.export
+ const variable* c_s, // config.config.save
project_set& projects)
{
tracer trace ("configure_project");
@@ -451,40 +450,40 @@ namespace build2
// Save src-root.build unless out_root is the same as src.
//
- if (c_e == nullptr && out_root != src_root)
+ if (c_s == nullptr && out_root != src_root)
save_src_root (rs);
// Save config.build unless an alternative is specified with
- // config.export. Similar to config.import we will only save to that
- // file if it is specified on our root scope or as a global override
- // (the latter is a bit iffy but let's allow it, for example, to dump
- // everything to stdout). Note that to save a subproject's config we
- // will have to use a scope-specific override (since the default will
- // apply to the amalgamation):
+ // config.config.save. Similar to config.config.load we will only save
+ // to that file if it is specified on our root scope or as a global
+ // override (the latter is a bit iffy but let's allow it, for example,
+ // to dump everything to stdout). Note that to save a subproject's
+ // config we will have to use a scope-specific override (since the
+ // default will apply to the amalgamation):
//
- // b configure: subproj/ subproj/config.export=.../config.build
+ // b configure: subproj/ subproj/config.config.save=.../config.build
//
// Could be confusing but then normally it will be the amalgamation
// whose configuration we want to export.
//
- // Note also that if config.export is specified we do not rewrite
+ // Note also that if config.config.save is specified we do not rewrite
// config.build files (say, of subprojects) as well as src-root.build
// above. Failed that, if we are running in a disfigured project, we
// may end up leaving it in partially configured state.
//
- if (c_e == nullptr)
+ if (c_s == nullptr)
save_config (rs, config_file (rs), true /* inherit */, projects);
else
{
- lookup l (rs[*c_e]);
+ lookup l (rs[*c_s]);
if (l && (l.belongs (rs) || l.belongs (ctx.global_scope)))
{
// While writing the complete configuration seems like a natural
// default, there might be a desire to take inheritance into
// account (if, say, we are exporting at multiple levels). One can
// of course just copy the relevant config.build files, but we may
- // still want to support this mode somehow in the future (maybe
- // using `+` as a modifier, say config.export=+.../config.build).
+ // still want to support this mode somehow in the future (it seems
+ // like an override of config.config.persist should do the trick).
//
save_config (rs, cast<path> (l), false /* inherit */, projects);
}
@@ -511,7 +510,7 @@ namespace build2
if (nrs.out_path () != out_nroot) // This subproject not loaded.
continue;
- configure_project (a, nrs, c_e, projects);
+ configure_project (a, nrs, c_s, projects);
}
}
}
@@ -658,12 +657,12 @@ namespace build2
context& ctx (fwd ? ts[0].as<scope> ().ctx : ts[0].as<target> ().ctx);
- const variable* c_e (ctx.var_pool.find ("config.export"));
+ const variable* c_s (ctx.var_pool.find ("config.config.save"));
- if (c_e->overrides == nullptr)
- c_e = nullptr;
+ if (c_s->overrides == nullptr)
+ c_s = nullptr;
else if (fwd)
- fail << "config.export specified for forward configuration";
+ fail << "config.config.save specified for forward configuration";
project_set projects;
@@ -717,7 +716,7 @@ namespace build2
}
}
- configure_project (a, *rs, c_e, projects);
+ configure_project (a, *rs, c_s, projects);
}
}
}
diff --git a/libbuild2/config/operation.hxx b/libbuild2/config/operation.hxx
index 1b4a452..79539b5 100644
--- a/libbuild2/config/operation.hxx
+++ b/libbuild2/config/operation.hxx
@@ -31,8 +31,8 @@ namespace build2
using project_set = std::set<const scope*>; // Pointers for comparison.
// If inherit is false, then don't rely on inheritance from outer scopes
- // (used for config.export). In this case the already configured project
- // set can be empty.
+ // (used for config.config.save/$config.save()). In this case the already
+ // configured project set can be empty.
//
void
save_config (const scope& rs,