mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
Merge pull request #9838 from obsidiansystems/systemTypes-set
Make `Machine::systemTypes` a set not vector
This commit is contained in:
commit
f1b0304153
3 changed files with 23 additions and 8 deletions
|
@ -137,11 +137,8 @@ static int main_build_remote(int argc, char * * argv)
|
||||||
for (auto & m : machines) {
|
for (auto & m : machines) {
|
||||||
debug("considering building on remote machine '%s'", m.storeUri);
|
debug("considering building on remote machine '%s'", m.storeUri);
|
||||||
|
|
||||||
if (m.enabled
|
if (m.enabled &&
|
||||||
&& (neededSystem == "builtin"
|
m.systemSupported(neededSystem) &&
|
||||||
|| std::find(m.systemTypes.begin(),
|
|
||||||
m.systemTypes.end(),
|
|
||||||
neededSystem) != m.systemTypes.end()) &&
|
|
||||||
m.allSupported(requiredFeatures) &&
|
m.allSupported(requiredFeatures) &&
|
||||||
m.mandatoryMet(requiredFeatures))
|
m.mandatoryMet(requiredFeatures))
|
||||||
{
|
{
|
||||||
|
@ -214,7 +211,7 @@ static int main_build_remote(int argc, char * * argv)
|
||||||
|
|
||||||
for (auto & m : machines)
|
for (auto & m : machines)
|
||||||
error
|
error
|
||||||
% concatStringsSep<std::vector<std::string>>(", ", m.systemTypes)
|
% concatStringsSep<StringSet>(", ", m.systemTypes)
|
||||||
% m.maxJobs
|
% m.maxJobs
|
||||||
% concatStringsSep<StringSet>(", ", m.supportedFeatures)
|
% concatStringsSep<StringSet>(", ", m.supportedFeatures)
|
||||||
% concatStringsSep<StringSet>(", ", m.mandatoryFeatures);
|
% concatStringsSep<StringSet>(", ", m.mandatoryFeatures);
|
||||||
|
|
|
@ -38,6 +38,11 @@ Machine::Machine(decltype(storeUri) storeUri,
|
||||||
sshPublicHostKey(sshPublicHostKey)
|
sshPublicHostKey(sshPublicHostKey)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
bool Machine::systemSupported(const std::string & system) const
|
||||||
|
{
|
||||||
|
return system == "builtin" || (systemTypes.count(system) > 0);
|
||||||
|
}
|
||||||
|
|
||||||
bool Machine::allSupported(const std::set<std::string> & features) const
|
bool Machine::allSupported(const std::set<std::string> & features) const
|
||||||
{
|
{
|
||||||
return std::all_of(features.begin(), features.end(),
|
return std::all_of(features.begin(), features.end(),
|
||||||
|
@ -145,7 +150,7 @@ static Machine parseBuilderLine(const std::string & line)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
tokens[0],
|
tokens[0],
|
||||||
isSet(1) ? tokenizeString<std::vector<std::string>>(tokens[1], ",") : std::vector<std::string>{settings.thisSystem},
|
isSet(1) ? tokenizeString<std::set<std::string>>(tokens[1], ",") : std::set<std::string>{settings.thisSystem},
|
||||||
isSet(2) ? tokens[2] : "",
|
isSet(2) ? tokens[2] : "",
|
||||||
isSet(3) ? parseUnsignedIntField(3) : 1U,
|
isSet(3) ? parseUnsignedIntField(3) : 1U,
|
||||||
isSet(4) ? parseUnsignedIntField(4) : 1U,
|
isSet(4) ? parseUnsignedIntField(4) : 1U,
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Store;
|
||||||
struct Machine {
|
struct Machine {
|
||||||
|
|
||||||
const std::string storeUri;
|
const std::string storeUri;
|
||||||
const std::vector<std::string> systemTypes;
|
const std::set<std::string> systemTypes;
|
||||||
const std::string sshKey;
|
const std::string sshKey;
|
||||||
const unsigned int maxJobs;
|
const unsigned int maxJobs;
|
||||||
const unsigned int speedFactor;
|
const unsigned int speedFactor;
|
||||||
|
@ -19,8 +19,21 @@ struct Machine {
|
||||||
const std::string sshPublicHostKey;
|
const std::string sshPublicHostKey;
|
||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Whether `system` is either `"builtin"` or in
|
||||||
|
* `systemTypes`.
|
||||||
|
*/
|
||||||
|
bool systemSupported(const std::string & system) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Whether `features` is a subset of the union of `supportedFeatures` and
|
||||||
|
* `mandatoryFeatures`
|
||||||
|
*/
|
||||||
bool allSupported(const std::set<std::string> & features) const;
|
bool allSupported(const std::set<std::string> & features) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return @Whether `mandatoryFeatures` is a subset of `features`
|
||||||
|
*/
|
||||||
bool mandatoryMet(const std::set<std::string> & features) const;
|
bool mandatoryMet(const std::set<std::string> & features) const;
|
||||||
|
|
||||||
Machine(decltype(storeUri) storeUri,
|
Machine(decltype(storeUri) storeUri,
|
||||||
|
|
Loading…
Reference in a new issue