aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbutl/default-options.ixx11
-rw-r--r--libbutl/default-options.mxx50
-rw-r--r--libbutl/default-options.txx51
-rw-r--r--tests/default-options/driver.cxx137
-rw-r--r--tests/default-options/testscript253
5 files changed, 354 insertions, 148 deletions
diff --git a/libbutl/default-options.ixx b/libbutl/default-options.ixx
index 7e4c378..4a551ac 100644
--- a/libbutl/default-options.ixx
+++ b/libbutl/default-options.ixx
@@ -12,4 +12,15 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
cmd_ops,
[] (const default_options_entry<O>&, const O&) {});
}
+
+ template <typename O, typename AS>
+ inline AS
+ merge_default_arguments (const default_options<O>& def_ops,
+ const AS& cmd_args)
+ {
+ return merge_default_arguments (
+ def_ops,
+ cmd_args,
+ [] (const default_options_entry<O>&, const AS&) {});
+ }
}
diff --git a/libbutl/default-options.mxx b/libbutl/default-options.mxx
index e9f92d3..aeb246d 100644
--- a/libbutl/default-options.mxx
+++ b/libbutl/default-options.mxx
@@ -6,6 +6,7 @@
#endif
#ifndef __cpp_lib_modules_ts
+#include <string>
#include <vector>
#include <utility> // move(), forward(), make_pair()
@@ -50,17 +51,21 @@ LIBBUTL_MODEXPORT namespace butl
template <typename O>
struct default_options_entry
{
- path file;
- O options;
- bool remote;
+ path file;
+ O options;
+ small_vector<std::string, 1> arguments;
+ bool remote;
};
template <typename O>
using default_options = small_vector<default_options_entry<O>, 4>;
- // Search for and load (using scanner S and parsing in the U::fail mode for
- // both options and arguments) the specified list of options files in the
- // specified directories returning a vector of option class instances (O).
+ // Search for and load the specified list of options files in the specified
+ // directories returning a vector of option class instances (O). If args is
+ // false, only options are allowed and are parsed using scanner S in the
+ // U::fail mode. If args is true, then both options and arguments are
+ // allowed in any order with options parsed in the U::stop mode.
+ //
// Pass each default options file path to the specified function prior to
// load (can be used for tracing, etc). The function signature is:
//
@@ -106,33 +111,44 @@ LIBBUTL_MODEXPORT namespace butl
const optional<dir_path>& home_dir,
const optional<dir_path>& extra_dir,
const default_options_files&,
- F&&);
+ F&&,
+ bool args = false);
- // Merge the default options and the command line options.
+ // Merge the default options/arguments and the command line
+ // options/arguments.
//
- // Note that this is the default implementation and in some cases you may
+ // Note that these are the default implementations and in some cases you may
// want to provide an options class-specific version that verifies/sanitizes
- // the default options (e.g., you may not want to allow certain options to
- // be specified in the default options files) or warns/prompts about
- // potentially dangerous options if they came from the remote options files.
+ // the default options/arguments (e.g., you may not want to allow certain
+ // options to be specified in the default options files) or warns/prompts
+ // about potentially dangerous options if they came from the remote options
+ // files.
//
template <typename O>
O
merge_default_options (const default_options<O>&, const O& cmd_ops);
- // As above but pass each default option to the specified function prior to
- // merging. The function signature is:
+ template <typename O, typename AS>
+ AS
+ merge_default_arguments (const default_options<O>&, const AS& cmd_args);
+
+ // As above but pass each default option/argument entry to the specified
+ // function prior to merging. The function signature is:
//
// void (const default_options_entry<O>&, const O& cmd_ops)
//
- // This version can be used to verify the default options. For example, you
- // may want to disallow certain options from being specified in the default
- // options files.
+ // This version can be used to verify the default options/arguments. For
+ // example, you may want to disallow certain options/arguments from being
+ // specified in the default options files.
//
template <typename O, typename F>
O
merge_default_options (const default_options<O>&, const O&, F&&);
+ template <typename O, typename AS, typename F>
+ AS
+ merge_default_arguments (const default_options<O>&, const AS&, F&&);
+
// Find a common start (parent) directory stopping at home or root
// (excluding).
//
diff --git a/libbutl/default-options.txx b/libbutl/default-options.txx
index 730d588..5245bd6 100644
--- a/libbutl/default-options.txx
+++ b/libbutl/default-options.txx
@@ -31,6 +31,7 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
template <typename O, typename S, typename U, typename F>
bool
load_default_options_files (const dir_path& d,
+ bool args,
bool remote,
const small_vector<path, 2>& fs,
F&& fn,
@@ -42,7 +43,7 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
bool r (true);
- auto load = [&fs, &fn, &def_ops, &r] (const dir_path& d, bool remote)
+ auto load = [args, &fs, &fn, &def_ops, &r] (const dir_path& d, bool rem)
{
using namespace std;
@@ -54,7 +55,7 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
{
if (file_exists (p)) // Follows symlinks.
{
- fn (p, remote, false /* overwrite */);
+ fn (p, rem, false /* overwrite */);
S s (p.string ());
@@ -65,14 +66,26 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
// this in CLI.
//
O o;
- o.parse (s, U::fail, U::fail);
+ small_vector<std::string, 1> as;
+
+ if (args)
+ {
+ while (s.more ())
+ {
+ if (!o.parse (s, U::fail, U::stop))
+ as.push_back (s.next ());
+ }
+ }
+ else
+ o.parse (s, U::fail, U::fail);
if (o.no_default_options ())
r = false;
def_ops.push_back (default_options_entry<O> {move (p),
move (o),
- remote});
+ move (as),
+ rem});
}
}
catch (std::system_error& e)
@@ -102,7 +115,8 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
const optional<dir_path>& home_dir,
const optional<dir_path>& extra_dir,
const default_options_files& ofs,
- F&& fn)
+ F&& fn,
+ bool args)
{
if (sys_dir)
assert (sys_dir->absolute () && sys_dir->normalized ());
@@ -192,6 +206,7 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
if (load_extra && extra_dir->sub (d))
{
load = load_default_options_files<O, S, U> (*extra_dir,
+ args,
false /* remote */,
ofs.files,
std::forward<F> (fn),
@@ -204,6 +219,7 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
if (load && options_dir_exists (od))
load = load_default_options_files<O, S, U> (od,
+ args,
remote,
ofs.files,
std::forward<F> (fn),
@@ -219,6 +235,7 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
if (load && load_extra)
load = load_default_options_files<O, S, U> (*extra_dir,
+ args,
false /* remote */,
ofs.files,
std::forward<F> (fn),
@@ -230,6 +247,7 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
if (options_dir_exists (d))
load = load_default_options_files<O, S, U> (d,
+ args,
false /* remote */,
ofs.files,
std::forward<F> (fn),
@@ -238,6 +256,7 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
if (load && sys_dir && options_dir_exists (*sys_dir))
load_default_options_files<O, S, U> (*sys_dir,
+ args,
false /* remote */,
ofs.files,
std::forward<F> (fn),
@@ -269,4 +288,26 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
r.merge (cmd_ops);
return r;
}
+
+ template <typename O, typename AS, typename F>
+ AS
+ merge_default_arguments (const default_options<O>& def_ops,
+ const AS& cmd_args,
+ F&& fn)
+ {
+ AS r;
+ for (const default_options_entry<O>& e: def_ops)
+ {
+ fn (e, cmd_args);
+ r.insert (r.end (), e.arguments.begin (), e.arguments.end ());
+ }
+
+ // Optimize for the common case.
+ //
+ if (r.empty ())
+ return cmd_args;
+
+ r.insert (r.end (), cmd_args.begin (), cmd_args.end ());
+ return r;
+ }
}
diff --git a/tests/default-options/driver.cxx b/tests/default-options/driver.cxx
index c6ac671..574e002 100644
--- a/tests/default-options/driver.cxx
+++ b/tests/default-options/driver.cxx
@@ -7,6 +7,7 @@
#include <string>
#include <vector>
#include <iostream>
+#include <stdexcept> // invalid_argument
#endif
// Other includes.
@@ -57,6 +58,9 @@ using namespace butl;
// -x
// Extra directory.
//
+// -a
+// Default arguments are allowed in the options files.
+//
// -e
// Print the default options entries (rather than the merged options) to
// STDOUT one per line in the following format:
@@ -76,19 +80,59 @@ main (int argc, const char* argv[])
public:
scanner (const string& f): ifs_ (f, fdopen_mode::in, ifdstream::badbit) {}
- optional<string>
+ bool
+ more ()
+ {
+ if (peeked_)
+ return true;
+
+ if (!eof_)
+ eof_ = ifs_.peek () == ifdstream::traits_type::eof ();
+
+ return !eof_;
+ }
+
+ string
+ peek ()
+ {
+ assert (more ());
+
+ if (peeked_)
+ return *peeked_;
+
+ string s;
+ getline (ifs_, s);
+
+ peeked_ = move (s);
+ return *peeked_;
+ }
+
+ string
next ()
{
+ assert (more ());
+
string s;
- return !eof (getline (ifs_, s)) ? optional<string> (move (s)) : nullopt;
+ if (peeked_)
+ {
+ s = move (*peeked_);
+ peeked_ = nullopt;
+ }
+ else
+ getline (ifs_, s);
+
+ return s;
}
private:
ifdstream ifs_;
+ bool eof_ = false;
+ optional<string> peeked_;
};
enum class unknow_mode
{
+ stop,
fail
};
@@ -96,15 +140,28 @@ main (int argc, const char* argv[])
{
public:
bool
- parse (scanner& s, unknow_mode, unknow_mode)
+ parse (scanner& s, unknow_mode, unknow_mode m)
{
bool r (false);
- while (optional<string> o = s.next ())
+ while (s.more ())
{
- if (*o == "--no-default-options")
+ string a (s.peek ());
+
+ if (a.compare (0, 2, "--") != 0)
+ {
+ switch (m)
+ {
+ case unknow_mode::stop: return r;
+ case unknow_mode::fail: throw invalid_argument (a);
+ }
+ }
+
+ s.next ();
+
+ if (a == "--no-default-options")
no_default_options_ = true;
- push_back (move (*o));
+ push_back (move (a));
r = true;
}
return r;
@@ -132,50 +189,58 @@ main (int argc, const char* argv[])
optional<dir_path> sys_dir;
optional<dir_path> home_dir;
optional<dir_path> extra_dir;
+ bool args (false);
vector<dir_path> dirs;
options cmd_ops;
+ vector<string> cmd_args;
bool print_entries (false);
bool trace (false);
for (int i (1); i != argc; ++i)
{
- string op (argv[i]);
+ string a (argv[i]);
- if (op == "-f")
+ if (a == "-f")
{
assert (++i != argc);
fs.files.push_back (path (argv[i]));
}
- else if (op == "-d")
+ else if (a == "-d")
{
assert (++i != argc);
dirs.emplace_back (argv[i]);
}
- else if (op == "-s")
+ else if (a == "-s")
{
assert (++i != argc);
sys_dir = dir_path (argv[i]);
}
- else if (op == "-h")
+ else if (a == "-h")
{
assert (++i != argc);
home_dir = dir_path (argv[i]);
}
- else if (op == "-x")
+ else if (a == "-x")
{
assert (++i != argc);
extra_dir = dir_path (argv[i]);
}
- else if (op == "-e")
+ else if (a == "-a")
+ {
+ args = true;
+ }
+ else if (a == "-e")
{
print_entries = true;
}
- else if (op == "-t")
+ else if (a == "-t")
{
trace = true;
}
+ else if (a.compare (0, 2, "--") == 0)
+ cmd_ops.push_back (move (a));
else
- cmd_ops.push_back (argv[i]);
+ cmd_args.push_back (move (a));
}
// Deduce a common start directory.
@@ -184,8 +249,11 @@ main (int argc, const char* argv[])
// Load and print the default options.
//
- default_options<options> def_ops (
- load_default_options<options, scanner, unknow_mode> (
+ default_options<options> def_ops;
+
+ try
+ {
+ def_ops = load_default_options<options, scanner, unknow_mode> (
sys_dir,
home_dir,
extra_dir,
@@ -195,7 +263,14 @@ main (int argc, const char* argv[])
if (trace)
cerr << (overwrite ? "overwriting " : "loading ")
<< (remote ? "remote " : "local ") << f << endl;
- }));
+ },
+ args);
+ }
+ catch (const invalid_argument& e)
+ {
+ cerr << "error: unexpected argument '" << e.what () << "'" << endl;
+ return 1;
+ }
if (print_entries)
{
@@ -211,18 +286,40 @@ main (int argc, const char* argv[])
cout << o;
}
+ if (args)
+ {
+ cout << "|";
+
+ for (const string& a: e.arguments)
+ {
+ if (&a != &e.arguments[0])
+ cout << ' ';
+
+ cout << a;
+ }
+
+ }
+
cout << (e.remote ? ",true" : ",false") << endl;
}
}
// Merge the options and print the result.
//
- options ops (merge_default_options (def_ops, cmd_ops));
-
if (!print_entries)
{
+ options ops (merge_default_options (def_ops, cmd_ops));
+
for (const string& o: ops)
cout << o << endl;
+
+ if (args)
+ {
+ vector<string> as (merge_default_arguments (def_ops, cmd_args));
+
+ for (const string& a: as)
+ cout << a << endl;
+ }
}
return 0;
diff --git a/tests/default-options/testscript b/tests/default-options/testscript
index fa65e62..b168ca9 100644
--- a/tests/default-options/testscript
+++ b/tests/default-options/testscript
@@ -4,9 +4,9 @@
# Note that when cross-testing the driver may not be able to run the command
# due to the meaningless program path.
#
-+if ($test.target != $build.host)
- exit
-end
+#+if ($test.target != $build.host)
+# exit
+#end
: basic
:
@@ -14,46 +14,46 @@ end
sys_dir = $canonicalize([dir_path] $~/build2)
+mkdir -p $sys_dir/local
- +echo 'sys-foo' >=$sys_dir/foo
- +echo 'sys-bar' >=$sys_dir/bar
- +echo 'sys-local-foo' >=$sys_dir/local/foo
- +echo 'sys-local-bar' >=$sys_dir/local/bar
+ +echo '--sys-foo' >=$sys_dir/foo
+ +echo '--sys-bar' >=$sys_dir/bar
+ +echo '--sys-local-foo' >=$sys_dir/local/foo
+ +echo '--sys-local-bar' >=$sys_dir/local/bar
home_dir = $canonicalize([dir_path] $~/home)
+mkdir -p $home_dir/.build2/local/
- +echo 'home-foo' >=$home_dir/.build2/foo
- +echo 'home-bar' >=$home_dir/.build2/bar
- +echo 'home-local-foo' >=$home_dir/.build2/local/foo
- +echo 'home-local-bar' >=$home_dir/.build2/local/bar
+ +echo '--home-foo' >=$home_dir/.build2/foo
+ +echo '--home-bar' >=$home_dir/.build2/bar
+ +echo '--home-local-foo' >=$home_dir/.build2/local/foo
+ +echo '--home-local-bar' >=$home_dir/.build2/local/bar
work_dir = $home_dir/work
+mkdir -p $work_dir/.build2/local/
d = $work_dir/.build2
- +echo 'work-foo' >=$d/foo
- +echo 'work-bar' >=$d/bar
- +echo 'work-local-foo' >=$d/local/foo
- +echo 'work-local-bar' >=$d/local/bar
+ +echo '--work-foo' >=$d/foo
+ +echo '--work-bar' >=$d/bar
+ +echo '--work-local-foo' >=$d/local/foo
+ +echo '--work-local-bar' >=$d/local/bar
d = $work_dir/project/.build2
+mkdir -p $d/local/
+touch $work_dir/project/.git
- +echo 'project-foo' >=$d/foo
- +echo 'project-bar' >=$d/bar
- +echo 'project-local-foo' >=$d/local/foo
- +echo 'project-local-bar' >=$d/local/bar
+ +echo '--project-foo' >=$d/foo
+ +echo '--project-bar' >=$d/bar
+ +echo '--project-local-foo' >=$d/local/foo
+ +echo '--project-local-bar' >=$d/local/bar
d = $work_dir/project/package/.build2
+mkdir -p $d/local/
- +echo 'package-foo' >=$d/foo
- +echo 'package-bar' >=$d/bar
- +echo 'package-local-foo' >=$d/local/foo
- +echo 'package-local-bar' >=$d/local/bar
+ +echo '--package-foo' >=$d/foo
+ +echo '--package-bar' >=$d/bar
+ +echo '--package-local-foo' >=$d/local/foo
+ +echo '--package-local-bar' >=$d/local/bar
+echo '--no-default-options' >=$d/local/baz
@@ -62,26 +62,26 @@ end
: entries
:
$* -e -t -f foo -f bar -d $start_dir -s $sys_dir -h $home_dir >>/~%EOO%d 2>>/~%EOE%d
- %\.+/build2/foo,sys-foo,false%
- %\.+/build2/bar,sys-bar,false%
- %\.+/build2/local/foo,sys-local-foo,false%
- %\.+/build2/local/bar,sys-local-bar,false%
- %\.+/home/.build2/foo,home-foo,false%
- %\.+/home/.build2/bar,home-bar,false%
- %\.+/home/.build2/local/foo,home-local-foo,false%
- %\.+/home/.build2/local/bar,home-local-bar,false%
- %\.+/home/work/.build2/foo,work-foo,false%
- %\.+/home/work/.build2/bar,work-bar,false%
- %\.+/home/work/.build2/local/foo,work-local-foo,false%
- %\.+/home/work/.build2/local/bar,work-local-bar,false%
- %\.+/home/work/project/.build2/foo,project-foo,true%
- %\.+/home/work/project/.build2/bar,project-bar,true%
- %\.+/home/work/project/.build2/local/foo,project-local-foo,true%
- %\.+/home/work/project/.build2/local/bar,project-local-bar,true%
- %\.+/home/work/project/package/.build2/foo,package-foo,true%
- %\.+/home/work/project/package/.build2/bar,package-bar,true%
- %\.+/home/work/project/package/.build2/local/foo,package-local-foo,true%
- %\.+/home/work/project/package/.build2/local/bar,package-local-bar,true%
+ %\.+/build2/foo,--sys-foo,false%
+ %\.+/build2/bar,--sys-bar,false%
+ %\.+/build2/local/foo,--sys-local-foo,false%
+ %\.+/build2/local/bar,--sys-local-bar,false%
+ %\.+/home/.build2/foo,--home-foo,false%
+ %\.+/home/.build2/bar,--home-bar,false%
+ %\.+/home/.build2/local/foo,--home-local-foo,false%
+ %\.+/home/.build2/local/bar,--home-local-bar,false%
+ %\.+/home/work/.build2/foo,--work-foo,false%
+ %\.+/home/work/.build2/bar,--work-bar,false%
+ %\.+/home/work/.build2/local/foo,--work-local-foo,false%
+ %\.+/home/work/.build2/local/bar,--work-local-bar,false%
+ %\.+/home/work/project/.build2/foo,--project-foo,true%
+ %\.+/home/work/project/.build2/bar,--project-bar,true%
+ %\.+/home/work/project/.build2/local/foo,--project-local-foo,true%
+ %\.+/home/work/project/.build2/local/bar,--project-local-bar,true%
+ %\.+/home/work/project/package/.build2/foo,--package-foo,true%
+ %\.+/home/work/project/package/.build2/bar,--package-bar,true%
+ %\.+/home/work/project/package/.build2/local/foo,--package-local-foo,true%
+ %\.+/home/work/project/package/.build2/local/bar,--package-local-bar,true%
EOO
%loading local \.+/home/work/project/package/.build2/local/bar%
%loading local \.+/home/work/project/package/.build2/local/foo%
@@ -111,37 +111,37 @@ end
: merged
:
- $* -f foo -f bar -d $start_dir -s $sys_dir -h $home_dir cmd-foo cmd-bar >>EOO
- sys-foo
- sys-bar
- sys-local-foo
- sys-local-bar
- home-foo
- home-bar
- home-local-foo
- home-local-bar
- work-foo
- work-bar
- work-local-foo
- work-local-bar
- project-foo
- project-bar
- project-local-foo
- project-local-bar
- package-foo
- package-bar
- package-local-foo
- package-local-bar
- cmd-foo
- cmd-bar
+ $* -f foo -f bar -d $start_dir -s $sys_dir -h $home_dir --cmd-foo --cmd-bar >>EOO
+ --sys-foo
+ --sys-bar
+ --sys-local-foo
+ --sys-local-bar
+ --home-foo
+ --home-bar
+ --home-local-foo
+ --home-local-bar
+ --work-foo
+ --work-bar
+ --work-local-foo
+ --work-local-bar
+ --project-foo
+ --project-bar
+ --project-local-foo
+ --project-local-bar
+ --package-foo
+ --package-bar
+ --package-local-foo
+ --package-local-bar
+ --cmd-foo
+ --cmd-bar
EOO
: no-default-options
:
$* -e -t -f foo -f baz -f bar -d $start_dir -s $sys_dir -h $home_dir >>/~%EOO%d 2>>/~%EOE%d
- %\.+/home/work/project/package/.build2/local/foo,package-local-foo,true%
+ %\.+/home/work/project/package/.build2/local/foo,--package-local-foo,true%
%\.+/home/work/project/package/.build2/local/baz,--no-default-options,true%
- %\.+/home/work/project/package/.build2/local/bar,package-local-bar,true%
+ %\.+/home/work/project/package/.build2/local/bar,--package-local-bar,true%
EOO
%loading local \.+/home/work/project/package/.build2/local/bar%
%loading local \.+/home/work/project/package/.build2/local/baz%
@@ -152,6 +152,47 @@ end
EOE
}
+: args
+:
+{
+ home_dir = $canonicalize([dir_path] $~/home)
+ +mkdir -p $home_dir/.build2
+ +echo '--home' >=$home_dir/.build2/ops
+ +echo 'home' >+$home_dir/.build2/ops
+
+ start_dir = $canonicalize([dir_path] $home_dir/start)
+ +mkdir -p $start_dir/.build2
+ +echo '--start1' >=$start_dir/.build2/ops
+ +echo 'start2' >+$start_dir/.build2/ops
+ +echo '--start3' >+$start_dir/.build2/ops
+ +echo 'start4' >+$start_dir/.build2/ops
+
+ : allowed
+ :
+ $* -a -e -f ops -d $start_dir -h $home_dir >>/~%EOO%d
+ %\.+/home/.build2/ops,--home\|home,false%
+ %\.+/home/start/.build2/ops,--start1 --start3\|start2 start4,false%
+ EOO
+
+ : disallowed
+ :
+ $* -e -f ops -d $start_dir -h $home_dir 2>>EOE != 0
+ error: unexpected argument 'start2'
+ EOE
+
+ : merged
+ :
+ $* -a -f ops -d $start_dir -h $home_dir cmd >>EOO
+ --home
+ --start1
+ --start3
+ home
+ start2
+ start4
+ cmd
+ EOO
+}
+
: common-start
:
{
@@ -166,10 +207,10 @@ end
+mkdir -p $work_dir/.build2 $cfg1/.build2 $cfg2/.build2 $cfg3/.build2
- +echo 'work' >=$work_dir/.build2/ops
- +echo 'cfg1' >=$cfg1/.build2/ops
- +echo 'cfg2' >=$cfg2/.build2/ops
- +echo 'cfg3' >=$cfg3/.build2/ops
+ +echo '--work' >=$work_dir/.build2/ops
+ +echo '--cfg1' >=$cfg1/.build2/ops
+ +echo '--cfg2' >=$cfg2/.build2/ops
+ +echo '--cfg3' >=$cfg3/.build2/ops
: exists
:
@@ -177,29 +218,29 @@ end
: single
:
$* -f ops -d $cfg3 -h $home_dir >>EOO
- work
- cfg2
- cfg3
+ --work
+ --cfg2
+ --cfg3
EOO
: same
:
$* -f ops -d $cfg1 -d $cfg1 -h $home_dir >>EOO
- work
- cfg1
+ --work
+ --cfg1
EOO
: adjacent
:
$* -f ops -d $cfg1 -d $cfg2 -h $home_dir >>EOO
- work
+ --work
EOO
: nested
:
$* -f ops -d $cfg2 -d $cfg3 -h $home_dir >>EOO
- work
- cfg2
+ --work
+ --cfg2
EOO
}
@@ -209,7 +250,7 @@ end
: home-reached
:
$* -f ops -d $cfg1 -d $cfg2 -h $work_dir >>EOO
- work
+ --work
EOO
: root-reached
@@ -229,20 +270,20 @@ end
{
home_dir = $canonicalize([dir_path] $~/home);
mkdir -p $home_dir/.build2;
- echo 'home' >=$home_dir/.build2/ops;
+ echo '--home' >=$home_dir/.build2/ops;
extra_dir = $canonicalize([dir_path] $home_dir/extra);
mkdir -p $extra_dir;
- echo 'extra' >=$extra_dir/ops;
+ echo '--extra' >=$extra_dir/ops;
start_dir = $canonicalize([dir_path] $home_dir/start);
mkdir -p $start_dir/.build2;
- echo 'start' >=$start_dir/.build2/ops;
+ echo '--start' >=$start_dir/.build2/ops;
$* -e -f ops -d $start_dir -h $home_dir -x $extra_dir >>/~%EOO%d
- %\.+/home/.build2/ops,home,false%
- %\.+/home/extra/ops,extra,false%
- %\.+/home/start/.build2/ops,start,false%
+ %\.+/home/.build2/ops,--home,false%
+ %\.+/home/extra/ops,--extra,false%
+ %\.+/home/start/.build2/ops,--start,false%
EOO
}
@@ -251,56 +292,56 @@ end
{
home_dir = $canonicalize([dir_path] $~/home);
mkdir -p $home_dir/.build2;
- echo 'home' >=$home_dir/.build2/ops;
+ echo '--home' >=$home_dir/.build2/ops;
d = $home_dir/project/.build2;
mkdir -p $d;
- echo 'project' >=$d/ops;
+ echo '--project' >=$d/ops;
touch $home_dir/project/.git;
d = $home_dir/project/package/.build2;
mkdir -p $d;
- echo 'package' >=$d/ops;
+ echo '--package' >=$d/ops;
extra_dir = $canonicalize([dir_path] $home_dir/project/package/extra1);
mkdir -p $extra_dir;
- echo 'extra1' >=$extra_dir/ops;
+ echo '--extra1' >=$extra_dir/ops;
start_dir = $canonicalize([dir_path] $home_dir/project/package);
$* -e -f ops -d $start_dir -h $home_dir -x $extra_dir >>/~%EOO%d;
- %\.+/home/.build2/ops,home,false%
- %\.+/home/project/.build2/ops,project,true%
- %\.+/home/project/package/.build2/ops,package,true%
- %\.+/home/project/package/extra1/ops,extra1,false%
+ %\.+/home/.build2/ops,--home,false%
+ %\.+/home/project/.build2/ops,--project,true%
+ %\.+/home/project/package/.build2/ops,--package,true%
+ %\.+/home/project/package/extra1/ops,--extra1,false%
EOO
extra_dir = $canonicalize([dir_path] $home_dir/project/package/.build2);
$* -e -f ops -d $start_dir -h $home_dir -x $extra_dir/ >>/~%EOO%d;
- %\.+/home/.build2/ops,home,false%
- %\.+/home/project/.build2/ops,project,true%
- %\.+/home/project/package/.build2/ops,package,false%
+ %\.+/home/.build2/ops,--home,false%
+ %\.+/home/project/.build2/ops,--project,true%
+ %\.+/home/project/package/.build2/ops,--package,false%
EOO
extra_dir = $canonicalize([dir_path] $home_dir/project/extra2);
mkdir -p $extra_dir;
- echo 'extra2' >=$extra_dir/ops;
+ echo '--extra2' >=$extra_dir/ops;
$* -e -f ops -d $start_dir -h $home_dir -x $extra_dir >>/~%EOO%d;
- %\.+/home/.build2/ops,home,false%
- %\.+/home/project/.build2/ops,project,true%
- %\.+/home/project/extra2/ops,extra2,false%
- %\.+/home/project/package/.build2/ops,package,true%
+ %\.+/home/.build2/ops,--home,false%
+ %\.+/home/project/.build2/ops,--project,true%
+ %\.+/home/project/extra2/ops,--extra2,false%
+ %\.+/home/project/package/.build2/ops,--package,true%
EOO
extra_dir = $canonicalize([dir_path] $home_dir/project/.build2);
$* -e -f ops -d $start_dir -h $home_dir -x $extra_dir/ >>/~%EOO%d
- %\.+/home/.build2/ops,home,false%
- %\.+/home/project/.build2/ops,project,false%
- %\.+/home/project/package/.build2/ops,package,true%
+ %\.+/home/.build2/ops,--home,false%
+ %\.+/home/project/.build2/ops,--project,false%
+ %\.+/home/project/package/.build2/ops,--package,true%
EOO
}
}