diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2021-04-20 22:48:59 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2021-04-21 17:15:28 +0300 |
commit | 09c231965f9f8e8f1e86f127a22f112d63ef4d9b (patch) | |
tree | e1a8689a0053099719722ba45d35aa33d229fc1e /libbuild2/script | |
parent | 30da2a90b3d433160c06643fb7ca51722fbae6b8 (diff) |
Add buildscript depdb builtin 'env' command
Diffstat (limited to 'libbuild2/script')
-rw-r--r-- | libbuild2/script/parser.cxx | 2 | ||||
-rw-r--r-- | libbuild2/script/run.cxx | 2 | ||||
-rw-r--r-- | libbuild2/script/script.cxx | 28 | ||||
-rw-r--r-- | libbuild2/script/script.hxx | 9 |
4 files changed, 29 insertions, 12 deletions
diff --git a/libbuild2/script/parser.cxx b/libbuild2/script/parser.cxx index 41d3092..ebfd5fc 100644 --- a/libbuild2/script/parser.cxx +++ b/libbuild2/script/parser.cxx @@ -1437,7 +1437,7 @@ namespace build2 } else if (optional<string> v = str ("--unset", "-u")) { - verify_environment_var_name (*v, o.c_str (), "env: ", i->second); + verify_environment_var_name (*v, "env: ", i->second, o.c_str ()); r.variables.add (move (*v)); } diff --git a/libbuild2/script/run.cxx b/libbuild2/script/run.cxx index 3faa35c..f36e979 100644 --- a/libbuild2/script/run.cxx +++ b/libbuild2/script/run.cxx @@ -781,7 +781,7 @@ namespace build2 // auto verify_name = [&ll] (const string& name, const char* opt) { - verify_environment_var_name (name, opt, "export: ", ll); + verify_environment_var_name (name, "export: ", ll, opt); }; // Parse options (variable set/unset cleanups and unsets). diff --git a/libbuild2/script/script.cxx b/libbuild2/script/script.cxx index db53418..298d71f 100644 --- a/libbuild2/script/script.cxx +++ b/libbuild2/script/script.cxx @@ -818,18 +818,34 @@ namespace build2 // void verify_environment_var_name (const string& name, - const char* opt, const char* prefix, - const location& l) + const location& l, + const char* opt) { if (name.empty ()) - fail (l) << prefix << "empty value for option " << opt; + { + diag_record dr (fail (l)); + dr << prefix << "empty "; + + if (opt == nullptr) + dr << "variable name"; + else + dr << "value for option " << opt; + } if (name.find ('=') != string::npos) - fail (l) << prefix << "invalid value '" << name << "' for option " - << opt << ": contains '='"; - } + { + diag_record dr (fail (l)); + dr << prefix << "invalid "; + + if (opt == nullptr) + dr << "variable name '" << name << "'"; + else + dr << "value '" << name << "' for option " << opt; + dr << ": contains '='"; + } + } void verify_environment_var_assignment (const string& var, diff --git a/libbuild2/script/script.hxx b/libbuild2/script/script.hxx index b4cb7fc..dd31e33 100644 --- a/libbuild2/script/script.hxx +++ b/libbuild2/script/script.hxx @@ -569,14 +569,15 @@ namespace build2 // Helpers. // - // Issue diagnostics with the specified prefix and fail if the string is - // not a valid variable name or assignment (empty, etc). + // Issue diagnostics with the specified prefix and fail if the string + // (potentially an option value) is not a valid variable name or + // assignment (empty, etc). // void verify_environment_var_name (const string&, - const char* opt, const char* prefix, - const location&); + const location&, + const char* opt = nullptr); void verify_environment_var_assignment (const string&, |