Merge changes I29e66ad8,I77ea62cd,I7cd58d92 into main

* changes:
  treewide: make more settings conditionally available
  libstore/build: only send overridden settings to the build hook
  treewide: consistently mark overridden settings as such
This commit is contained in:
alois31
2024-10-23 15:20:51 +00:00
committed by Gerrit Code Review
22 changed files with 118 additions and 115 deletions
+10 -2
View File
@@ -65,6 +65,7 @@ void BaseSetting<T>::appendOrSet(T newValue, bool append, const ApplyConfigOptio
"using default `appendOrSet` implementation with an appendable type");
assert(!append);
overridden = true;
value = std::move(newValue);
}
@@ -85,6 +86,13 @@ void BaseSetting<T>::set(const std::string & str, bool append, const ApplyConfig
}
}
template<typename T>
void BaseSetting<T>::override(const T & v)
{
overridden = true;
value = v;
}
template<> void BaseSetting<bool>::convertToArg(Args & args, const std::string & category);
template<typename T>
@@ -95,7 +103,7 @@ void BaseSetting<T>::convertToArg(Args & args, const std::string & category)
.description = fmt("Set the `%s` setting.", name),
.category = category,
.labels = {"value"},
.handler = {[this](std::string s) { overridden = true; set(s); }},
.handler = {[this](std::string s) { set(s); }},
.experimentalFeature = experimentalFeature,
});
@@ -105,7 +113,7 @@ void BaseSetting<T>::convertToArg(Args & args, const std::string & category)
.description = fmt("Append to the `%s` setting.", name),
.category = category,
.labels = {"value"},
.handler = {[this](std::string s) { overridden = true; set(s, true); }},
.handler = {[this](std::string s) { set(s, true); }},
.experimentalFeature = experimentalFeature,
});
}
+1 -4
View File
@@ -32,7 +32,6 @@ bool Config::set(const std::string & name, const std::string & value, const Appl
return false;
}
i->second.setting->set(value, append, options);
i->second.setting->overridden = true;
return true;
}
@@ -46,7 +45,6 @@ void Config::addSetting(AbstractSetting * setting)
if (auto i = unknownSettings.find(setting->name); i != unknownSettings.end()) {
setting->set(std::move(i->second));
setting->overridden = true;
unknownSettings.erase(i);
set = true;
}
@@ -58,7 +56,6 @@ void Config::addSetting(AbstractSetting * setting)
alias, setting->name);
else {
setting->set(std::move(i->second));
setting->overridden = true;
unknownSettings.erase(i);
set = true;
}
@@ -80,7 +77,7 @@ void AbstractConfig::reapplyUnknownSettings()
{
auto unknownSettings2 = std::move(unknownSettings);
unknownSettings = {};
for (auto & s : unknownSettings2)
for (auto & s : unknownSettings2)
set(s.first, s.second);
}
+3 -14
View File
@@ -218,6 +218,7 @@ protected:
virtual void convertToArg(Args & args, const std::string & category);
bool isOverridden() const;
};
/**
@@ -267,16 +268,12 @@ public:
{ }
operator const T &() const { return value; }
operator T &() { return value; }
const T & get() const { return value; }
template<typename U>
bool operator ==(const U & v2) const { return value == v2; }
template<typename U>
bool operator !=(const U & v2) const { return value != v2; }
template<typename U>
void operator =(const U & v) { assign(v); }
virtual void assign(const T & v) { value = v; }
template<typename U>
void setDefault(const U & v) { if (!overridden) value = v; }
/**
@@ -287,6 +284,8 @@ public:
*/
void set(const std::string & str, bool append = false, const ApplyConfigOptions & options = {}) override final;
void override(const T & v);
/**
* C++ trick; This is template-specialized to compile-time indicate whether
* the type is appendable.
@@ -299,12 +298,6 @@ public:
*/
bool isAppendable() override final;
virtual void override(const T & v)
{
overridden = true;
value = v;
}
std::string to_string() const override;
void convertToArg(Args & args, const std::string & category) override;
@@ -349,8 +342,6 @@ public:
: Setting(options, def, name, description, aliases, documentDefault, std::move(experimentalFeature), true)
{
}
void operator =(const T & v) { this->assign(v); }
};
/**
@@ -375,8 +366,6 @@ public:
}
T parse(const std::string & str, const ApplyConfigOptions & options) const override;
void operator =(const T & v) { this->assign(v); }
};