From 5417243b54862d0e5f0214dde2b84eb90a100bf2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 11 Apr 2016 09:22:00 +0200 Subject: Adjust abs_dir_path usage to take advantage of inheritance --- build2/file.cxx | 2 +- build2/install/module.cxx | 36 ++++++++++++++++++------------------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/build2/file.cxx b/build2/file.cxx index c3d2273..4b0795c 100644 --- a/build2/file.cxx +++ b/build2/file.cxx @@ -872,7 +872,7 @@ namespace build2 if (auto l = iroot[var]) { - out_root = cast (l); + out_root = cast (l); config::save_variable (iroot, var); // Mark as part of configuration. } else diff --git a/build2/install/module.cxx b/build2/install/module.cxx index e7840ca..2a4d164 100644 --- a/build2/install/module.cxx +++ b/build2/install/module.cxx @@ -33,13 +33,13 @@ namespace build2 // configurations. We have to do this for paths that contain the // package name. // - template + template static void set_var (bool spec, scope& r, const char* name, const char* var, - const T* dv, + const CT* dv, bool override = false) { string vn; @@ -50,7 +50,7 @@ namespace build2 vn = "config.install."; vn += name; vn += var; - const variable& vr (var_pool.insert (move (vn), true)); + const variable& vr (var_pool.insert (move (vn), true)); cv = dv != nullptr ? &config::required (r, vr, *dv, override).first.get () @@ -67,7 +67,7 @@ namespace build2 if (spec) { if (*cv && !cv->empty ()) - v = *cv; + v = cast (*cv); // Strip CT to T. } else { @@ -82,19 +82,19 @@ namespace build2 scope& r, // root scope const char* n, // var name const T& p, // path + bool o = false, // override const string& fm = string (), // file mode const string& dm = string (), // dir mode - const build2::path& c = build2::path (), // command - bool o = false) // override + const build2::path& c = build2::path ()) // command { using build2::path; - 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 (s, r, n, ".sudo", nullptr); - set_var (s, r, n, ".cmd", c.empty () ? nullptr : &c); - set_var (s, r, n, ".options", nullptr); + 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 (s, r, n, ".sudo", (string*) (nullptr)); + set_var (s, r, n, ".cmd", c.empty () ? nullptr : &c); + set_var (s, r, n, ".options", (strings*) (nullptr)); } static alias_rule alias_; @@ -162,19 +162,19 @@ namespace build2 bool s (config::specified (r, "config.install")); const string& n (cast (r["project"])); - set_dir (s, r, "root", abs_dir_path (), "", "755", path ("install")); - set_dir (s, r, "data_root", dir_path ("root"), "644"); - set_dir (s, r, "exec_root", dir_path ("root"), "755"); + set_dir (s, r, "root", abs_dir_path (), false, "", "755", path ("install")); + set_dir (s, r, "data_root", dir_path ("root"), false, "644"); + set_dir (s, r, "exec_root", dir_path ("root"), false, "755"); set_dir (s, r, "sbin", dir_path ("exec_root/sbin")); set_dir (s, r, "bin", dir_path ("exec_root/bin")); set_dir (s, r, "lib", dir_path ("exec_root/lib")); - set_dir (s, r, "libexec", dir_path ("exec_root/libexec/" + n), "", "", path (), true); + set_dir (s, r, "libexec", dir_path ("exec_root/libexec/" + n), true); - set_dir (s, r, "data", dir_path ("data_root/share/" + n), "", "", path (), true); + set_dir (s, r, "data", dir_path ("data_root/share/" + n), true); set_dir (s, r, "include", dir_path ("data_root/include")); - set_dir (s, r, "doc", dir_path ("data_root/share/doc/" + n), "", "", path (), true); + set_dir (s, r, "doc", dir_path ("data_root/share/doc/" + n), true); set_dir (s, r, "man", dir_path ("data_root/share/man")); set_dir (s, r, "man1", dir_path ("man/man1")); } -- cgit v1.1