From 2c0a2b0d688b4450c72cde12ecedaa3fc3c9662a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 24 Oct 2016 16:13:26 +0200 Subject: Add build.driver variable with build system driver path (argv[0]) --- build2/b.cxx | 3 ++- build2/context.cxx | 2 ++ build2/utility | 6 +++++- build2/utility.cxx | 5 ++++- 4 files changed, 13 insertions(+), 3 deletions(-) (limited to 'build2') diff --git a/build2/b.cxx b/build2/b.cxx index d800605..a652c97 100644 --- a/build2/b.cxx +++ b/build2/b.cxx @@ -161,7 +161,8 @@ main (int argc, char* argv[]) // Global initializations. // - init (ops.verbose_specified () + init (argv[0], + ops.verbose_specified () ? ops.verbose () : ops.V () ? 3 : ops.v () ? 2 : ops.q () ? 0 : 1); diff --git a/build2/context.cxx b/build2/context.cxx index c783832..6d39da2 100644 --- a/build2/context.cxx +++ b/build2/context.cxx @@ -238,6 +238,8 @@ namespace build2 v.insert ("extension", variable_visibility::target); } + gs.assign ("build.driver") = argv0; + gs.assign ("build.work") = work; gs.assign ("build.home") = home; diff --git a/build2/utility b/build2/utility index 56e0c47..7c30395 100644 --- a/build2/utility +++ b/build2/utility @@ -83,6 +83,10 @@ namespace build2 next_word (const string&, size_t n, size_t& b, size_t& e, char d1 = ' ', char d2 = '\0'); + // Build system driver recall path (argv[0]). + // + extern path argv0; + // Work/home directories (must be initialized in main()) and relative path // calculation. // @@ -476,7 +480,7 @@ namespace build2 // Should be called early in main() once. // void - init (uint16_t verbosity); + init (const char* argv0, uint16_t verbosity); } #include diff --git a/build2/utility.cxx b/build2/utility.cxx index ca6b239..4b68edb 100644 --- a/build2/utility.cxx +++ b/build2/utility.cxx @@ -89,6 +89,7 @@ namespace build2 return l; } + path argv0; dir_path work; dir_path home; const dir_path* relative_base = &work; @@ -505,8 +506,10 @@ namespace build2 bool exception_unwinding_dtor = false; void - init (uint16_t v) + init (const char* a0, uint16_t v) { + argv0 = path (a0); + // Diagnostics verbosity. // verb = v; -- cgit v1.1