From b9e8ca2f16bc06fdaa9b2b7c3bfffca01ec590ac Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 9 Jun 2022 08:58:12 +0200 Subject: Handle bogus configuration variables --- bpkg/package-configuration.cxx | 54 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) (limited to 'bpkg/package-configuration.cxx') diff --git a/bpkg/package-configuration.cxx b/bpkg/package-configuration.cxx index 624de18..560fb3b 100644 --- a/bpkg/package-configuration.cxx +++ b/bpkg/package-configuration.cxx @@ -3,12 +3,62 @@ #include +#include + #include namespace bpkg { using build2::config::variable_origin; + string config_variable_value:: + serialize_cmdline () const + { + using namespace build2; + + string r (name + '='); + + if (!value) + r += "[null]"; + else + { + if (!value->empty ()) + { + // Note: we need to use command-line (effective) quoting. + // + ostringstream os; + to_stream (os, *value, quote_mode::effective, '@'); + r += os.str (); + } + } + + return r; + } + + void + to_checksum (sha256& cs, const config_variable_value& v) + { + using namespace build2; + + cs.append (v.name); + cs.append (static_cast (v.origin)); + if (v.type) + cs.append (*v.type); + + if (v.origin != variable_origin::undefined) + { + if (v.value) + for (const name& n: *v.value) + to_checksum (cs, n); + + if (v.origin == variable_origin::buildfile) + { + cs.append (v.dependent->string ()); + cs.append (v.confirmed); + } + } + } + bool up_negotiate_configuration ( package_configurations& cfgs, @@ -118,9 +168,7 @@ namespace bpkg // Note that we will not reload it to default in case of require. // - v.origin = variable_origin::undefined; - v.value = nullopt; - v.dependent = nullopt; + v.undefine (); } else old_cfgs.push_back ( -- cgit v1.1