From edab35e216bc3839915129e54f98160428634283 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 12 Aug 2019 14:56:03 +0300 Subject: Add support for default options files --- bdep/sync.cxx | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'bdep/sync.cxx') diff --git a/bdep/sync.cxx b/bdep/sync.cxx index cb85e98..ab2fb2b 100644 --- a/bdep/sync.cxx +++ b/bdep/sync.cxx @@ -861,4 +861,59 @@ namespace bdep return 0; } + + default_options_files + options_files (const char*, const cmd_sync_options& o, const strings&) + { + // bdep.options + // bdep-{sync|sync-implicit}.options + + default_options_files r {{path ("bdep.options")}, nullopt}; + + // Add bdep-sync-implicit.options for an implicit sync and + // bdep-sync.options otherwise. Omit the search start dir in the former + // case. + // + auto add = [&r] (const string& n) + { + r.files.push_back (path ("bdep-" + n + ".options")); + }; + + if (o.implicit () || o.hook_specified ()) + { + add ("sync-implicit"); + } + else + { + add ("sync"); + + r.start_dir = find_project (o); + } + + return r; + } + + cmd_sync_options + merge_options (const default_options& defs, + const cmd_sync_options& cmd) + { + return merge_default_options ( + defs, + cmd, + [] (const default_options_entry& e, + const cmd_sync_options&) + { + const cmd_sync_options& o (e.options); + + auto forbid = [&e] (const char* opt, bool specified) + { + if (specified) + fail (e.file) << opt << " in default options file"; + }; + + forbid ("--directory|-d", o.directory_specified ()); + forbid ("--implicit", o.implicit ()); + forbid ("--hook", o.hook_specified ()); + }); + } } -- cgit v1.1