aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-08-23 07:38:34 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-08-23 07:38:34 +0200
commit51ce9885c4987b7cf12d948daa1db2b50339df79 (patch)
tree3f15927cc7c48279010f42ffff84af9d1575908d
parentf3fa8fe79ba4c0b9d0a9817957c71f56b7f1a9a2 (diff)
By default append .config to user's module names in cfg-create
The idea is that in the bpkg amalgamation we only want the configuration, without any rules, etc. This can be overridden by adding the period at the end of the module name. While at it, recognize the leading question mark in the module name and treat it as the optional module load.
-rw-r--r--bpkg/cfg-create.cli10
-rw-r--r--bpkg/cfg-create.cxx29
2 files changed, 37 insertions, 2 deletions
diff --git a/bpkg/cfg-create.cli b/bpkg/cfg-create.cli
index 510f477..c01c039 100644
--- a/bpkg/cfg-create.cli
+++ b/bpkg/cfg-create.cli
@@ -33,6 +33,16 @@ namespace bpkg
\
bpkg create cxx config.cxx=clang++ config.install.root=/usr/local
\
+
+ By default, \cb{bpkg} appends \cb{.config} to the names of the modules
+ that you specify so that only their configurations are loaded. You can
+ override this behavior by appending the period (\cb{.}) after the module
+ name. You can also instruct \cb{bpkg} to use the optional module load by
+ prefixing the module name with the question mark (\cb{?}). For example:
+
+ \
+ bpkg create cxx. \"?cli\"
+ \
"
}
diff --git a/bpkg/cfg-create.cxx b/bpkg/cfg-create.cxx
index 94a7764..1d8171f 100644
--- a/bpkg/cfg-create.cxx
+++ b/bpkg/cfg-create.cxx
@@ -59,7 +59,25 @@ namespace bpkg
while (args.more ())
{
string a (args.next ());
- (a.find ('=') != string::npos ? vars : mods).push_back (move (a));
+
+ if (a.find ('=') != string::npos)
+ {
+ vars.push_back (move (a));
+ }
+ else if (!a.empty ())
+ {
+ // Append .config unless the module name ends with '.', in which case
+ // strip it.
+ //
+ if (a.back () != '.')
+ a += ".config";
+ else
+ a.pop_back ();
+
+ mods.push_back (move (a));
+ }
+ else
+ fail << "empty string as argument";
}
// Create build/.
@@ -106,7 +124,14 @@ namespace bpkg
// be loaded in bootstrap.
//
for (const string& m: mods)
- ofs << "using " << m << endl;
+ {
+ // If the module name start with '?', then use optional load.
+ //
+ if (m.front () != '?')
+ ofs << "using " << m << endl;
+ else
+ ofs << "using? " << m.c_str () + 1 << endl;
+ }
ofs.close ();
}