mirror of
https://github.com/NixOS/nix.git
synced 2025-11-14 22:42:41 +01:00
Apply clang-format universally.
* It is tough to contribute to a project that doesn't use a formatter, * It is extra hard to contribute to a project which has configured the formatter, but ignores it for some files * Code formatting makes it harder to hide obscure / weird bugs by accident or on purpose, Let's rip the bandaid off? Note that PRs currently in flight should be able to be merged relatively easily by applying `clang-format` to their tip prior to merge.
This commit is contained in:
parent
41bf87ec70
commit
e4f62e4608
587 changed files with 23258 additions and 23135 deletions
|
|
@ -14,29 +14,24 @@ Machine::Machine(
|
|||
decltype(speedFactor) speedFactor,
|
||||
decltype(supportedFeatures) supportedFeatures,
|
||||
decltype(mandatoryFeatures) mandatoryFeatures,
|
||||
decltype(sshPublicHostKey) sshPublicHostKey) :
|
||||
storeUri(StoreReference::parse(
|
||||
// Backwards compatibility: if the URI is schemeless, is not a path,
|
||||
// and is not one of the special store connection words, prepend
|
||||
// ssh://.
|
||||
storeUri.find("://") != std::string::npos
|
||||
|| storeUri.find("/") != std::string::npos
|
||||
|| storeUri == "auto"
|
||||
|| storeUri == "daemon"
|
||||
|| storeUri == "local"
|
||||
|| hasPrefix(storeUri, "auto?")
|
||||
|| hasPrefix(storeUri, "daemon?")
|
||||
|| hasPrefix(storeUri, "local?")
|
||||
|| hasPrefix(storeUri, "?")
|
||||
? storeUri
|
||||
: "ssh://" + storeUri)),
|
||||
systemTypes(systemTypes),
|
||||
sshKey(sshKey),
|
||||
maxJobs(maxJobs),
|
||||
speedFactor(speedFactor == 0.0f ? 1.0f : speedFactor),
|
||||
supportedFeatures(supportedFeatures),
|
||||
mandatoryFeatures(mandatoryFeatures),
|
||||
sshPublicHostKey(sshPublicHostKey)
|
||||
decltype(sshPublicHostKey) sshPublicHostKey)
|
||||
: storeUri(
|
||||
StoreReference::parse(
|
||||
// Backwards compatibility: if the URI is schemeless, is not a path,
|
||||
// and is not one of the special store connection words, prepend
|
||||
// ssh://.
|
||||
storeUri.find("://") != std::string::npos || storeUri.find("/") != std::string::npos || storeUri == "auto"
|
||||
|| storeUri == "daemon" || storeUri == "local" || hasPrefix(storeUri, "auto?")
|
||||
|| hasPrefix(storeUri, "daemon?") || hasPrefix(storeUri, "local?") || hasPrefix(storeUri, "?")
|
||||
? storeUri
|
||||
: "ssh://" + storeUri))
|
||||
, systemTypes(systemTypes)
|
||||
, sshKey(sshKey)
|
||||
, maxJobs(maxJobs)
|
||||
, speedFactor(speedFactor == 0.0f ? 1.0f : speedFactor)
|
||||
, supportedFeatures(supportedFeatures)
|
||||
, mandatoryFeatures(mandatoryFeatures)
|
||||
, sshPublicHostKey(sshPublicHostKey)
|
||||
{
|
||||
if (speedFactor < 0.0)
|
||||
throw UsageError("speed factor must be >= 0");
|
||||
|
|
@ -49,19 +44,16 @@ bool Machine::systemSupported(const std::string & system) const
|
|||
|
||||
bool Machine::allSupported(const StringSet & features) const
|
||||
{
|
||||
return std::all_of(features.begin(), features.end(),
|
||||
[&](const std::string & feature) {
|
||||
return supportedFeatures.count(feature) ||
|
||||
mandatoryFeatures.count(feature);
|
||||
});
|
||||
return std::all_of(features.begin(), features.end(), [&](const std::string & feature) {
|
||||
return supportedFeatures.count(feature) || mandatoryFeatures.count(feature);
|
||||
});
|
||||
}
|
||||
|
||||
bool Machine::mandatoryMet(const StringSet & features) const
|
||||
{
|
||||
return std::all_of(mandatoryFeatures.begin(), mandatoryFeatures.end(),
|
||||
[&](const std::string & feature) {
|
||||
return features.count(feature);
|
||||
});
|
||||
return std::all_of(mandatoryFeatures.begin(), mandatoryFeatures.end(), [&](const std::string & feature) {
|
||||
return features.count(feature);
|
||||
});
|
||||
}
|
||||
|
||||
StoreReference Machine::completeStoreReference() const
|
||||
|
|
@ -86,7 +78,8 @@ StoreReference Machine::completeStoreReference() const
|
|||
auto & fs = storeUri.params["system-features"];
|
||||
auto append = [&](auto feats) {
|
||||
for (auto & f : feats) {
|
||||
if (fs.size() > 0) fs += ' ';
|
||||
if (fs.size() > 0)
|
||||
fs += ' ';
|
||||
fs += f;
|
||||
}
|
||||
};
|
||||
|
|
@ -145,7 +138,10 @@ static Machine parseBuilderLine(const StringSet & defaultSystems, const std::str
|
|||
auto parseUnsignedIntField = [&](size_t fieldIndex) {
|
||||
const auto result = string2Int<unsigned int>(tokens[fieldIndex]);
|
||||
if (!result) {
|
||||
throw FormatError("bad machine specification: failed to convert column #%lu in a row: '%s' to 'unsigned int'", fieldIndex, line);
|
||||
throw FormatError(
|
||||
"bad machine specification: failed to convert column #%lu in a row: '%s' to 'unsigned int'",
|
||||
fieldIndex,
|
||||
line);
|
||||
}
|
||||
return result.value();
|
||||
};
|
||||
|
|
@ -153,7 +149,8 @@ static Machine parseBuilderLine(const StringSet & defaultSystems, const std::str
|
|||
auto parseFloatField = [&](size_t fieldIndex) {
|
||||
const auto result = string2Float<float>(tokens[fieldIndex]);
|
||||
if (!result) {
|
||||
throw FormatError("bad machine specification: failed to convert column #%lu in a row: '%s' to 'float'", fieldIndex, line);
|
||||
throw FormatError(
|
||||
"bad machine specification: failed to convert column #%lu in a row: '%s' to 'float'", fieldIndex, line);
|
||||
}
|
||||
return result.value();
|
||||
};
|
||||
|
|
@ -170,7 +167,8 @@ static Machine parseBuilderLine(const StringSet & defaultSystems, const std::str
|
|||
};
|
||||
|
||||
if (!isSet(0))
|
||||
throw FormatError("bad machine specification: store URL was not found at the first column of a row: '%s'", line);
|
||||
throw FormatError(
|
||||
"bad machine specification: store URL was not found at the first column of a row: '%s'", line);
|
||||
|
||||
// TODO use designated initializers, once C++ supports those with
|
||||
// custom constructors.
|
||||
|
|
@ -190,16 +188,15 @@ static Machine parseBuilderLine(const StringSet & defaultSystems, const std::str
|
|||
// `mandatoryFeatures`
|
||||
isSet(6) ? tokenizeString<StringSet>(tokens[6], ",") : StringSet{},
|
||||
// `sshPublicHostKey`
|
||||
isSet(7) ? ensureBase64(7) : ""
|
||||
};
|
||||
isSet(7) ? ensureBase64(7) : ""};
|
||||
}
|
||||
|
||||
static Machines parseBuilderLines(const StringSet & defaultSystems, const std::vector<std::string> & builders)
|
||||
{
|
||||
Machines result;
|
||||
std::transform(
|
||||
builders.begin(), builders.end(), std::back_inserter(result),
|
||||
[&](auto && line) { return parseBuilderLine(defaultSystems, line); });
|
||||
std::transform(builders.begin(), builders.end(), std::back_inserter(result), [&](auto && line) {
|
||||
return parseBuilderLine(defaultSystems, line);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -214,4 +211,4 @@ Machines getMachines()
|
|||
return Machine::parseConfig({settings.thisSystem}, settings.builders);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace nix
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue