aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-06-04 13:40:26 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-06-04 13:40:26 +0200
commit49887d80b7986ba3df5306ea0aa985034fdb0444 (patch)
treec601f004e42b2ef27c74e5b41d149db4d607856b
parent7bc20238740dd4b5beeb40e6a84929c7f9c5a751 (diff)
Add --existing|-e option to bdep-{init,new} -C and bdep-config create modes
With this option bdep initializes a bpkg configuration based on an existing build system configuration instead of creating a new one.
-rw-r--r--bdep/config.cli4
-rw-r--r--bdep/config.cxx12
-rw-r--r--bdep/init.cli4
-rw-r--r--bdep/init.cxx3
-rw-r--r--bdep/new.cli4
-rw-r--r--bdep/new.cxx3
-rw-r--r--bdep/project.cli11
7 files changed, 33 insertions, 8 deletions
diff --git a/bdep/config.cli b/bdep/config.cli
index 55591c1..2fe6c9e 100644
--- a/bdep/config.cli
+++ b/bdep/config.cli
@@ -14,7 +14,7 @@ namespace bdep
"<options>
<cfg-spec> <cfg-name> <cfg-dir>
<prj-spec> <prj-dir>
- <cfg-args> <option> <module> <cfg-var>",
+ <cfg-args> <bpkg-options> <module> <cfg-var>",
"\h|SYNOPSIS|
@@ -31,7 +31,7 @@ namespace bdep
\c{<cfg-spec> = \b{@}<cfg-name> | \b{--config}|\b{-c} <cfg-dir>\n
<prj-spec> = \b{--directory}|\b{-d} <prj-dir>\n
- <cfg-args> = (<option> | <module> | <cfg-var>)...}
+ <cfg-args> = [<bpkg-options>] [\b{--existing}|\b{-e} | (<module> | <cfg-var>)...]}
\h|DESCRIPTION|
diff --git a/bdep/config.cxx b/bdep/config.cxx
index 412b753..7c9b45d 100644
--- a/bdep/config.cxx
+++ b/bdep/config.cxx
@@ -52,12 +52,16 @@ namespace bdep
if (o.auto_sync () && o.no_auto_sync ())
fail << "both --auto-sync and --no-auto-sync specified";
+ if (o.existing () && o.wipe ())
+ fail << "both --existing|-e and --wipe specified";
+
return (o.default_ () ? "--default" :
o.no_default () ? "--no-default" :
o.forward () ? "--forward" :
o.no_forward () ? "--no-forward" :
o.auto_sync () ? "--auto-sync" :
o.no_auto_sync () ? "--no-auto-sync" :
+ o.existing () ? "--existing|-e" :
o.wipe () ? "--wipe" : nullptr);
}
@@ -284,7 +288,8 @@ namespace bdep
co,
"create",
"-d", path,
- (ao.wipe () ? "--wipe" : nullptr),
+ (ao.existing () ? "--existing" : nullptr),
+ (ao.wipe () ? "--wipe" : nullptr),
args);
}
@@ -295,7 +300,7 @@ namespace bdep
move (path),
move (name),
id,
- "created");
+ ao.existing () ? "initialized" : "created");
}
static int
@@ -756,6 +761,9 @@ namespace bdep
if (!c.add () && !c.create () && !c.set ())
fail << n << " not valid for this subcommand";
+ if (o.existing () && !c.create ())
+ fail << "--existing|-e is not valid for this subcommand";
+
if (o.wipe () && !c.create ())
fail << "--wipe is not valid for this subcommand";
}
diff --git a/bdep/init.cli b/bdep/init.cli
index ea9e53e..72b8d7f 100644
--- a/bdep/init.cli
+++ b/bdep/init.cli
@@ -15,7 +15,7 @@ namespace bdep
<prj-spec> <prj-dir>
<pkg-spec> <pkg-dir>
<cfg-spec> <cfg-name> <cfg-dir>
- <cfg-args> <option> <module> <cfg-var>
+ <cfg-args> <bpkg-options> <module> <cfg-var>
<pkg-args> <pkg>",
"\h|SYNOPSIS|
@@ -30,7 +30,7 @@ namespace bdep
<pkg-spec> = (\b{--directory}|\b{-d} <pkg-dir>)... | <prj-spec>\n
<prj-spec> = \b{--directory}|\b{-d} <prj-dir>\n
<pkg-args> = (<pkg> | <cfg-var>)...\n
- <cfg-args> = (<option> | <module> | <cfg-var>)...}
+ <cfg-args> = [<bpkg-options>] [\b{--existing}|\b{-e} | (<module> | <cfg-var>)...]}
\h|DESCRIPTION|
diff --git a/bdep/init.cxx b/bdep/init.cxx
index 94ce212..782dfe0 100644
--- a/bdep/init.cxx
+++ b/bdep/init.cxx
@@ -136,6 +136,9 @@ namespace bdep
if (!ca && !cc)
fail << n << " specified without --config-(add|create)";
+ if (o.existing () && !cc)
+ fail << "--existing|-e specified without --config-create";
+
if (o.wipe () && !cc)
fail << "--wipe specified without --config-create";
}
diff --git a/bdep/new.cli b/bdep/new.cli
index faf412d..e56e407 100644
--- a/bdep/new.cli
+++ b/bdep/new.cli
@@ -18,7 +18,7 @@ namespace bdep
<vcs> <vcs-opt>
<cfg-name> <cfg-dir>
<prj-spec> <prj-dir>
- <cfg-args> <option> <module> <cfg-var>",
+ <cfg-args> <bpkg-options> <module> <cfg-var>",
"\h|SYNOPSIS|
@@ -34,7 +34,7 @@ namespace bdep
<lang> \ \ \ \ = \b{--lang}|\b{-l} (\b{c}|\b{c++})[\b{,}<lang-opt>...]\n
<vcs> \ \ \ \ \ = \b{--vcs}|\b{-s} \ (\b{git}|\b{none})[\b{,}<vcs-opt>...]\n
<prj-spec> = \b{--directory}|\b{-d} <prj-dir>\n
- <cfg-args> = (<option> | <module> | <cfg-var>)...}
+ <cfg-args> = [<bpkg-options>] [\b{--existing}|\b{-e} | (<module> | <cfg-var>)...]}
\h|DESCRIPTION|
diff --git a/bdep/new.cxx b/bdep/new.cxx
index c74c90c..e94229f 100644
--- a/bdep/new.cxx
+++ b/bdep/new.cxx
@@ -60,6 +60,9 @@ namespace bdep
if (!ca && !cc)
fail << n << " specified without --config-(add|create)";
+ if (o.existing () && !cc)
+ fail << "--existing|-e specified without --config-create";
+
if (o.wipe () && !cc)
fail << "--wipe specified without --config-create";
}
diff --git a/bdep/project.cli b/bdep/project.cli
index d19847a..bcf5cd5 100644
--- a/bdep/project.cli
+++ b/bdep/project.cli
@@ -43,6 +43,17 @@ namespace bdep
synchronized."
}
+ // These two a really just convenience aliases since they can be specified
+ // as part of <cfg-args> but would require `--`, for example:
+ //
+ // bdep ... -- --wipe cc config.cxx=g++
+
+ bool --existing|-e
+ {
+ "Initialize a \cb{bpkg} configuration based on an existing build system
+ configuration."
+ }
+
bool --wipe
{
"Wipe the configuration directory clean before creating the new