aboutsummaryrefslogtreecommitdiff
path: root/build/install
diff options
context:
space:
mode:
Diffstat (limited to 'build/install')
-rw-r--r--build/install/module.cxx29
-rw-r--r--build/install/rule.cxx23
2 files changed, 33 insertions, 19 deletions
diff --git a/build/install/module.cxx b/build/install/module.cxx
index 204bddd..706f367 100644
--- a/build/install/module.cxx
+++ b/build/install/module.cxx
@@ -79,21 +79,22 @@ namespace build
}
static void
- set_dir (bool s,
- scope& r,
- const char* name,
- const string& path,
- const string& fmode = string (),
- const string& dmode = string (),
- const string& cmd = string (),
- bool ovr = false)
+ set_dir (bool s, // specified
+ scope& r, // root scope
+ const char* n, // var name
+ const string& ps, // path (as string)
+ const string& fm = string (), // file mode
+ const string& dm = string (), // dir mode
+ const string& c = string (), // command
+ bool o = false) // override
{
- dir_path dpath (path);
- set_var (s, r, name, "", dpath.empty () ? nullptr : &dpath, ovr);
- set_var (s, r, name, ".mode", fmode.empty () ? nullptr : &fmode);
- set_var (s, r, name, ".dir_mode", dmode.empty () ? nullptr : &dmode);
- set_var (s, r, name, ".cmd", cmd.empty () ? nullptr : &cmd);
- set_var<strings> (s, r, name, ".options", nullptr);
+ dir_path p (ps);
+ set_var (s, r, n, "", p.empty () ? nullptr : &p, o);
+ set_var (s, r, n, ".mode", fm.empty () ? nullptr : &fm);
+ set_var (s, r, n, ".dir_mode", dm.empty () ? nullptr : &dm);
+ set_var<string> (s, r, n, ".sudo", nullptr);
+ set_var (s, r, n, ".cmd", c.empty () ? nullptr : &c);
+ set_var<strings> (s, r, n, ".options", nullptr);
}
static alias_rule alias_;
diff --git a/build/install/rule.cxx b/build/install/rule.cxx
index 3f8c16a..eb48bbe 100644
--- a/build/install/rule.cxx
+++ b/build/install/rule.cxx
@@ -213,6 +213,7 @@ namespace build
struct install_dir
{
dir_path dir;
+ string sudo;
string cmd; //@@ VAR type
const_strings_value options {nullptr};
string mode;
@@ -226,7 +227,13 @@ namespace build
{
path reld (relative (d));
- cstrings args {base.cmd.c_str (), "-d"};
+ cstrings args;
+
+ if (!base.sudo.empty ())
+ args.push_back (base.sudo.c_str ());
+
+ args.push_back (base.cmd.c_str ());
+ args.push_back ("-d");
if (base.options.d != nullptr) //@@ VAR
config::append_options (args, base.options);
@@ -267,7 +274,12 @@ namespace build
path reld (relative (base.dir));
path relf (relative (t.path ()));
- cstrings args {base.cmd.c_str ()};
+ cstrings args;
+
+ if (!base.sudo.empty ())
+ args.push_back (base.sudo.c_str ());
+
+ args.push_back (base.cmd.c_str ());
if (base.options.d != nullptr) //@@ VAR
config::append_options (args, base.options);
@@ -347,10 +359,11 @@ namespace build
//
if (var != nullptr)
{
- if (auto l = s[*var + ".cmd"]) r.cmd = as<string> (*l);
- if (auto l = s[*var + ".mode"]) r.mode = as<string> (*l);
+ if (auto l = s[*var + ".sudo"]) r.sudo = as<string> (*l);
+ if (auto l = s[*var + ".cmd"]) r.cmd = as<string> (*l);
+ if (auto l = s[*var + ".mode"]) r.mode = as<string> (*l);
if (auto l = s[*var + ".dir_mode"]) r.dir_mode = as<string> (*l);
- if (auto l = s[*var + ".options"]) r.options = as<strings> (*l);
+ if (auto l = s[*var + ".options"]) r.options = as<strings> (*l);
}
// Set defaults for unspecified components.