mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
Refactor: rename C++ concatStringsSep -> dropEmptyInitThenConcatStringsSep
This commit is contained in:
parent
b1effc9649
commit
1a8defd06f
33 changed files with 70 additions and 70 deletions
|
@ -206,15 +206,15 @@ static int main_build_remote(int argc, char * * argv)
|
||||||
error
|
error
|
||||||
% drvstr
|
% drvstr
|
||||||
% neededSystem
|
% neededSystem
|
||||||
% concatStringsSep<StringSet>(", ", requiredFeatures)
|
% dropEmptyInitThenConcatStringsSep<StringSet>(", ", requiredFeatures)
|
||||||
% machines.size();
|
% machines.size();
|
||||||
|
|
||||||
for (auto & m : machines)
|
for (auto & m : machines)
|
||||||
error
|
error
|
||||||
% concatStringsSep<StringSet>(", ", m.systemTypes)
|
% dropEmptyInitThenConcatStringsSep<StringSet>(", ", m.systemTypes)
|
||||||
% m.maxJobs
|
% m.maxJobs
|
||||||
% concatStringsSep<StringSet>(", ", m.supportedFeatures)
|
% dropEmptyInitThenConcatStringsSep<StringSet>(", ", m.supportedFeatures)
|
||||||
% concatStringsSep<StringSet>(", ", m.mandatoryFeatures);
|
% dropEmptyInitThenConcatStringsSep<StringSet>(", ", m.mandatoryFeatures);
|
||||||
|
|
||||||
printMsg(couldBuildLocally ? lvlChatty : lvlWarn, error.str());
|
printMsg(couldBuildLocally ? lvlChatty : lvlWarn, error.str());
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ void NixMultiCommand::run()
|
||||||
for (auto & [name, _] : commands)
|
for (auto & [name, _] : commands)
|
||||||
subCommandTextLines.insert(fmt("- `%s`", name));
|
subCommandTextLines.insert(fmt("- `%s`", name));
|
||||||
std::string markdownError = fmt("`nix %s` requires a sub-command. Available sub-commands:\n\n%s\n",
|
std::string markdownError = fmt("`nix %s` requires a sub-command. Available sub-commands:\n\n%s\n",
|
||||||
commandName, concatStringsSep("\n", subCommandTextLines));
|
commandName, dropEmptyInitThenConcatStringsSep("\n", subCommandTextLines));
|
||||||
throw UsageError(renderMarkdownToTerminal(markdownError));
|
throw UsageError(renderMarkdownToTerminal(markdownError));
|
||||||
}
|
}
|
||||||
command->second->run();
|
command->second->run();
|
||||||
|
|
|
@ -374,7 +374,7 @@ void completeFlakeRefWithFragment(
|
||||||
auto attrPath2 = (*attr)->getAttrPath(attr2);
|
auto attrPath2 = (*attr)->getAttrPath(attr2);
|
||||||
/* Strip the attrpath prefix. */
|
/* Strip the attrpath prefix. */
|
||||||
attrPath2.erase(attrPath2.begin(), attrPath2.begin() + attrPathPrefix.size());
|
attrPath2.erase(attrPath2.begin(), attrPath2.begin() + attrPathPrefix.size());
|
||||||
completions.add(flakeRefS + "#" + prefixRoot + concatStringsSep(".", evalState->symbols.resolve(attrPath2)));
|
completions.add(flakeRefS + "#" + prefixRoot + dropEmptyInitThenConcatStringsSep(".", evalState->symbols.resolve(attrPath2)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -630,7 +630,7 @@ static void throwBuildErrors(
|
||||||
}
|
}
|
||||||
failedPaths.insert(failedResult->path.to_string(store));
|
failedPaths.insert(failedResult->path.to_string(store));
|
||||||
}
|
}
|
||||||
throw Error("build of %s failed", concatStringsSep(", ", quoteStrings(failedPaths)));
|
throw Error("build of %s failed", dropEmptyInitThenConcatStringsSep(", ", quoteStrings(failedPaths)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -625,7 +625,7 @@ ProcessLineResult NixRepl::processLine(std::string line)
|
||||||
|
|
||||||
markdown +=
|
markdown +=
|
||||||
"**Synopsis:** `builtins." + (std::string) (*doc->name) + "` "
|
"**Synopsis:** `builtins." + (std::string) (*doc->name) + "` "
|
||||||
+ concatStringsSep(" ", args) + "\n\n";
|
+ dropEmptyInitThenConcatStringsSep(" ", args) + "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
markdown += stripIndentation(doc->doc);
|
markdown += stripIndentation(doc->doc);
|
||||||
|
|
|
@ -225,7 +225,7 @@ struct AttrDb
|
||||||
(key.first)
|
(key.first)
|
||||||
(symbols[key.second])
|
(symbols[key.second])
|
||||||
(AttrType::ListOfStrings)
|
(AttrType::ListOfStrings)
|
||||||
(concatStringsSep("\t", l)).exec();
|
(dropEmptyInitThenConcatStringsSep("\t", l)).exec();
|
||||||
|
|
||||||
return state->db.getLastInsertedRowId();
|
return state->db.getLastInsertedRowId();
|
||||||
});
|
});
|
||||||
|
@ -435,12 +435,12 @@ std::vector<Symbol> AttrCursor::getAttrPath(Symbol name) const
|
||||||
|
|
||||||
std::string AttrCursor::getAttrPathStr() const
|
std::string AttrCursor::getAttrPathStr() const
|
||||||
{
|
{
|
||||||
return concatStringsSep(".", root->state.symbols.resolve(getAttrPath()));
|
return dropEmptyInitThenConcatStringsSep(".", root->state.symbols.resolve(getAttrPath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AttrCursor::getAttrPathStr(Symbol name) const
|
std::string AttrCursor::getAttrPathStr(Symbol name) const
|
||||||
{
|
{
|
||||||
return concatStringsSep(".", root->state.symbols.resolve(getAttrPath(name)));
|
return dropEmptyInitThenConcatStringsSep(".", root->state.symbols.resolve(getAttrPath(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Value & AttrCursor::forceValue()
|
Value & AttrCursor::forceValue()
|
||||||
|
|
|
@ -47,7 +47,7 @@ void ConfigFile::apply(const Settings & flakeSettings)
|
||||||
else if (auto* b = std::get_if<Explicit<bool>>(&value))
|
else if (auto* b = std::get_if<Explicit<bool>>(&value))
|
||||||
valueS = b->t ? "true" : "false";
|
valueS = b->t ? "true" : "false";
|
||||||
else if (auto ss = std::get_if<std::vector<std::string>>(&value))
|
else if (auto ss = std::get_if<std::vector<std::string>>(&value))
|
||||||
valueS = concatStringsSep(" ", *ss); // FIXME: evil
|
valueS = dropEmptyInitThenConcatStringsSep(" ", *ss); // FIXME: evil
|
||||||
else
|
else
|
||||||
assert(false);
|
assert(false);
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ static std::shared_ptr<Node> doFind(const ref<Node>& root, const InputPath & pat
|
||||||
std::vector<std::string> cycle;
|
std::vector<std::string> cycle;
|
||||||
std::transform(found, visited.cend(), std::back_inserter(cycle), printInputPath);
|
std::transform(found, visited.cend(), std::back_inserter(cycle), printInputPath);
|
||||||
cycle.push_back(printInputPath(path));
|
cycle.push_back(printInputPath(path));
|
||||||
throw Error("follow cycle detected: [%s]", concatStringsSep(" -> ", cycle));
|
throw Error("follow cycle detected: [%s]", dropEmptyInitThenConcatStringsSep(" -> ", cycle));
|
||||||
}
|
}
|
||||||
visited.push_back(path);
|
visited.push_back(path);
|
||||||
|
|
||||||
|
@ -367,7 +367,7 @@ void check();
|
||||||
|
|
||||||
std::string printInputPath(const InputPath & path)
|
std::string printInputPath(const InputPath & path)
|
||||||
{
|
{
|
||||||
return concatStringsSep("/", path);
|
return dropEmptyInitThenConcatStringsSep("/", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,11 +301,11 @@ void printVersion(const std::string & programName)
|
||||||
#endif
|
#endif
|
||||||
cfg.push_back("signed-caches");
|
cfg.push_back("signed-caches");
|
||||||
std::cout << "System type: " << settings.thisSystem << "\n";
|
std::cout << "System type: " << settings.thisSystem << "\n";
|
||||||
std::cout << "Additional system types: " << concatStringsSep(", ", settings.extraPlatforms.get()) << "\n";
|
std::cout << "Additional system types: " << dropEmptyInitThenConcatStringsSep(", ", settings.extraPlatforms.get()) << "\n";
|
||||||
std::cout << "Features: " << concatStringsSep(", ", cfg) << "\n";
|
std::cout << "Features: " << dropEmptyInitThenConcatStringsSep(", ", cfg) << "\n";
|
||||||
std::cout << "System configuration file: " << settings.nixConfDir + "/nix.conf" << "\n";
|
std::cout << "System configuration file: " << settings.nixConfDir + "/nix.conf" << "\n";
|
||||||
std::cout << "User configuration files: " <<
|
std::cout << "User configuration files: " <<
|
||||||
concatStringsSep(":", settings.nixUserConfFiles)
|
dropEmptyInitThenConcatStringsSep(":", settings.nixUserConfFiles)
|
||||||
<< "\n";
|
<< "\n";
|
||||||
std::cout << "Store directory: " << settings.nixStore << "\n";
|
std::cout << "Store directory: " << settings.nixStore << "\n";
|
||||||
std::cout << "State directory: " << settings.nixStateDir << "\n";
|
std::cout << "State directory: " << settings.nixStateDir << "\n";
|
||||||
|
|
|
@ -895,7 +895,7 @@ void runPostBuildHook(
|
||||||
std::map<std::string, std::string> hookEnvironment = getEnv();
|
std::map<std::string, std::string> hookEnvironment = getEnv();
|
||||||
|
|
||||||
hookEnvironment.emplace("DRV_PATH", store.printStorePath(drvPath));
|
hookEnvironment.emplace("DRV_PATH", store.printStorePath(drvPath));
|
||||||
hookEnvironment.emplace("OUT_PATHS", chomp(concatStringsSep(" ", store.printStorePathSet(outputPaths))));
|
hookEnvironment.emplace("OUT_PATHS", chomp(dropEmptyInitThenConcatStringsSep(" ", store.printStorePathSet(outputPaths))));
|
||||||
hookEnvironment.emplace("NIX_CONFIG", globalConfig.toKeyValue());
|
hookEnvironment.emplace("NIX_CONFIG", globalConfig.toKeyValue());
|
||||||
|
|
||||||
struct LogSink : Sink {
|
struct LogSink : Sink {
|
||||||
|
@ -1505,7 +1505,7 @@ std::pair<bool, SingleDrvOutputs> DerivationGoal::checkPathValidity()
|
||||||
if (!wantedOutputsLeft.empty())
|
if (!wantedOutputsLeft.empty())
|
||||||
throw Error("derivation '%s' does not have wanted outputs %s",
|
throw Error("derivation '%s' does not have wanted outputs %s",
|
||||||
worker.store.printStorePath(drvPath),
|
worker.store.printStorePath(drvPath),
|
||||||
concatStringsSep(", ", quoteStrings(wantedOutputsLeft)));
|
dropEmptyInitThenConcatStringsSep(", ", quoteStrings(wantedOutputsLeft)));
|
||||||
|
|
||||||
bool allValid = true;
|
bool allValid = true;
|
||||||
for (auto & [_, status] : initialOutputs) {
|
for (auto & [_, status] : initialOutputs) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ void Store::buildPaths(const std::vector<DerivedPath> & reqs, BuildMode buildMod
|
||||||
throw std::move(*ex);
|
throw std::move(*ex);
|
||||||
} else if (!failed.empty()) {
|
} else if (!failed.empty()) {
|
||||||
if (ex) logError(ex->info());
|
if (ex) logError(ex->info());
|
||||||
throw Error(worker.failingExitStatus(), "build of %s failed", concatStringsSep(", ", quoteStrings(failed)));
|
throw Error(worker.failingExitStatus(), "build of %s failed", dropEmptyInitThenConcatStringsSep(", ", quoteStrings(failed)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ Settings::Settings()
|
||||||
Strings ss;
|
Strings ss;
|
||||||
for (auto & p : tokenizeString<Strings>(*s, ":"))
|
for (auto & p : tokenizeString<Strings>(*s, ":"))
|
||||||
ss.push_back("@" + p);
|
ss.push_back("@" + p);
|
||||||
builders = concatStringsSep(" ", ss);
|
builders = dropEmptyInitThenConcatStringsSep(" ", ss);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__linux__) && defined(SANDBOX_SHELL)
|
#if defined(__linux__) && defined(SANDBOX_SHELL)
|
||||||
|
|
|
@ -656,7 +656,7 @@ void LocalStore::registerDrvOutput(const Realisation & info)
|
||||||
combinedSignatures.insert(info.signatures.begin(),
|
combinedSignatures.insert(info.signatures.begin(),
|
||||||
info.signatures.end());
|
info.signatures.end());
|
||||||
state->stmts->UpdateRealisedOutput.use()
|
state->stmts->UpdateRealisedOutput.use()
|
||||||
(concatStringsSep(" ", combinedSignatures))
|
(dropEmptyInitThenConcatStringsSep(" ", combinedSignatures))
|
||||||
(info.id.strHash())
|
(info.id.strHash())
|
||||||
(info.id.outputName)
|
(info.id.outputName)
|
||||||
.exec();
|
.exec();
|
||||||
|
@ -675,7 +675,7 @@ void LocalStore::registerDrvOutput(const Realisation & info)
|
||||||
(info.id.strHash())
|
(info.id.strHash())
|
||||||
(info.id.outputName)
|
(info.id.outputName)
|
||||||
(printStorePath(info.outPath))
|
(printStorePath(info.outPath))
|
||||||
(concatStringsSep(" ", info.signatures))
|
(dropEmptyInitThenConcatStringsSep(" ", info.signatures))
|
||||||
.exec();
|
.exec();
|
||||||
}
|
}
|
||||||
for (auto & [outputId, depPath] : info.dependentRealisations) {
|
for (auto & [outputId, depPath] : info.dependentRealisations) {
|
||||||
|
@ -729,7 +729,7 @@ uint64_t LocalStore::addValidPath(State & state,
|
||||||
(info.deriver ? printStorePath(*info.deriver) : "", (bool) info.deriver)
|
(info.deriver ? printStorePath(*info.deriver) : "", (bool) info.deriver)
|
||||||
(info.narSize, info.narSize != 0)
|
(info.narSize, info.narSize != 0)
|
||||||
(info.ultimate ? 1 : 0, info.ultimate)
|
(info.ultimate ? 1 : 0, info.ultimate)
|
||||||
(concatStringsSep(" ", info.sigs), !info.sigs.empty())
|
(dropEmptyInitThenConcatStringsSep(" ", info.sigs), !info.sigs.empty())
|
||||||
(renderContentAddress(info.ca), (bool) info.ca)
|
(renderContentAddress(info.ca), (bool) info.ca)
|
||||||
.exec();
|
.exec();
|
||||||
uint64_t id = state.db.getLastInsertedRowId();
|
uint64_t id = state.db.getLastInsertedRowId();
|
||||||
|
@ -833,7 +833,7 @@ void LocalStore::updatePathInfo(State & state, const ValidPathInfo & info)
|
||||||
(info.narSize, info.narSize != 0)
|
(info.narSize, info.narSize != 0)
|
||||||
(info.narHash.to_string(HashFormat::Base16, true))
|
(info.narHash.to_string(HashFormat::Base16, true))
|
||||||
(info.ultimate ? 1 : 0, info.ultimate)
|
(info.ultimate ? 1 : 0, info.ultimate)
|
||||||
(concatStringsSep(" ", info.sigs), !info.sigs.empty())
|
(dropEmptyInitThenConcatStringsSep(" ", info.sigs), !info.sigs.empty())
|
||||||
(renderContentAddress(info.ca), (bool) info.ca)
|
(renderContentAddress(info.ca), (bool) info.ca)
|
||||||
(printStorePath(info.path))
|
(printStorePath(info.path))
|
||||||
.exec();
|
.exec();
|
||||||
|
|
|
@ -464,7 +464,7 @@ OutputPathMap resolveDerivedPath(Store & store, const DerivedPath::Built & bfd)
|
||||||
if (!outputsLeft.empty())
|
if (!outputsLeft.empty())
|
||||||
throw Error("derivation '%s' does not have an outputs %s",
|
throw Error("derivation '%s' does not have an outputs %s",
|
||||||
store.printStorePath(drvPath),
|
store.printStorePath(drvPath),
|
||||||
concatStringsSep(", ", quoteStrings(std::get<OutputsSpec::Names>(bfd.outputs.raw))));
|
dropEmptyInitThenConcatStringsSep(", ", quoteStrings(std::get<OutputsSpec::Names>(bfd.outputs.raw))));
|
||||||
return outputMap;
|
return outputMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -337,9 +337,9 @@ public:
|
||||||
(narInfo ? narInfo->fileSize : 0, narInfo != 0 && narInfo->fileSize)
|
(narInfo ? narInfo->fileSize : 0, narInfo != 0 && narInfo->fileSize)
|
||||||
(info->narHash.to_string(HashFormat::Nix32, true))
|
(info->narHash.to_string(HashFormat::Nix32, true))
|
||||||
(info->narSize)
|
(info->narSize)
|
||||||
(concatStringsSep(" ", info->shortRefs()))
|
(dropEmptyInitThenConcatStringsSep(" ", info->shortRefs()))
|
||||||
(info->deriver ? std::string(info->deriver->to_string()) : "", (bool) info->deriver)
|
(info->deriver ? std::string(info->deriver->to_string()) : "", (bool) info->deriver)
|
||||||
(concatStringsSep(" ", info->sigs))
|
(dropEmptyInitThenConcatStringsSep(" ", info->sigs))
|
||||||
(renderContentAddress(info->ca))
|
(renderContentAddress(info->ca))
|
||||||
(time(0)).exec();
|
(time(0)).exec();
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ std::string NarInfo::to_string(const Store & store) const
|
||||||
res += "NarHash: " + narHash.to_string(HashFormat::Nix32, true) + "\n";
|
res += "NarHash: " + narHash.to_string(HashFormat::Nix32, true) + "\n";
|
||||||
res += "NarSize: " + std::to_string(narSize) + "\n";
|
res += "NarSize: " + std::to_string(narSize) + "\n";
|
||||||
|
|
||||||
res += "References: " + concatStringsSep(" ", shortRefs()) + "\n";
|
res += "References: " + dropEmptyInitThenConcatStringsSep(" ", shortRefs()) + "\n";
|
||||||
|
|
||||||
if (deriver)
|
if (deriver)
|
||||||
res += "Deriver: " + std::string(deriver->to_string()) + "\n";
|
res += "Deriver: " + std::string(deriver->to_string()) + "\n";
|
||||||
|
|
|
@ -83,7 +83,7 @@ std::string OutputsSpec::to_string() const
|
||||||
return "*";
|
return "*";
|
||||||
},
|
},
|
||||||
[&](const OutputsSpec::Names & outputNames) -> std::string {
|
[&](const OutputsSpec::Names & outputNames) -> std::string {
|
||||||
return concatStringsSep(",", outputNames);
|
return dropEmptyInitThenConcatStringsSep(",", outputNames);
|
||||||
},
|
},
|
||||||
}, raw);
|
}, raw);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ std::string ValidPathInfo::fingerprint(const Store & store) const
|
||||||
"1;" + store.printStorePath(path) + ";"
|
"1;" + store.printStorePath(path) + ";"
|
||||||
+ narHash.to_string(HashFormat::Nix32, true) + ";"
|
+ narHash.to_string(HashFormat::Nix32, true) + ";"
|
||||||
+ std::to_string(narSize) + ";"
|
+ std::to_string(narSize) + ";"
|
||||||
+ concatStringsSep(",", store.printStorePathSet(references));
|
+ dropEmptyInitThenConcatStringsSep(",", store.printStorePathSet(references));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ std::string StorePathWithOutputs::to_string(const StoreDirConfig & store) const
|
||||||
{
|
{
|
||||||
return outputs.empty()
|
return outputs.empty()
|
||||||
? store.printStorePath(path)
|
? store.printStorePath(path)
|
||||||
: store.printStorePath(path) + "!" + concatStringsSep(",", outputs);
|
: store.printStorePath(path) + "!" + dropEmptyInitThenConcatStringsSep(",", outputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1208,7 +1208,7 @@ std::string StoreDirConfig::showPaths(const StorePathSet & paths)
|
||||||
|
|
||||||
std::string showPaths(const PathSet & paths)
|
std::string showPaths(const PathSet & paths)
|
||||||
{
|
{
|
||||||
return concatStringsSep(", ", quoteStrings(paths));
|
return dropEmptyInitThenConcatStringsSep(", ", quoteStrings(paths));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace nix {
|
||||||
|
|
||||||
HookInstance::HookInstance()
|
HookInstance::HookInstance()
|
||||||
{
|
{
|
||||||
debug("starting build hook '%s'", concatStringsSep(" ", settings.buildHook.get()));
|
debug("starting build hook '%s'", dropEmptyInitThenConcatStringsSep(" ", settings.buildHook.get()));
|
||||||
|
|
||||||
auto buildHookArgs = settings.buildHook.get();
|
auto buildHookArgs = settings.buildHook.get();
|
||||||
|
|
||||||
|
|
|
@ -496,10 +496,10 @@ void LocalDerivationGoal::startBuilder()
|
||||||
if (!parsedDrv->canBuildLocally(worker.store))
|
if (!parsedDrv->canBuildLocally(worker.store))
|
||||||
throw Error("a '%s' with features {%s} is required to build '%s', but I am a '%s' with features {%s}",
|
throw Error("a '%s' with features {%s} is required to build '%s', but I am a '%s' with features {%s}",
|
||||||
drv->platform,
|
drv->platform,
|
||||||
concatStringsSep(", ", parsedDrv->getRequiredSystemFeatures()),
|
dropEmptyInitThenConcatStringsSep(", ", parsedDrv->getRequiredSystemFeatures()),
|
||||||
worker.store.printStorePath(drvPath),
|
worker.store.printStorePath(drvPath),
|
||||||
settings.thisSystem,
|
settings.thisSystem,
|
||||||
concatStringsSep<StringSet>(", ", worker.store.systemFeatures));
|
dropEmptyInitThenConcatStringsSep<StringSet>(", ", worker.store.systemFeatures));
|
||||||
|
|
||||||
/* Create a temporary directory where the build will take
|
/* Create a temporary directory where the build will take
|
||||||
place. */
|
place. */
|
||||||
|
@ -840,7 +840,7 @@ void LocalDerivationGoal::startBuilder()
|
||||||
|
|
||||||
/* Run the builder. */
|
/* Run the builder. */
|
||||||
printMsg(lvlChatty, "executing builder '%1%'", drv->builder);
|
printMsg(lvlChatty, "executing builder '%1%'", drv->builder);
|
||||||
printMsg(lvlChatty, "using builder args '%1%'", concatStringsSep(" ", drv->args));
|
printMsg(lvlChatty, "using builder args '%1%'", dropEmptyInitThenConcatStringsSep(" ", drv->args));
|
||||||
for (auto & i : drv->env)
|
for (auto & i : drv->env)
|
||||||
printMsg(lvlVomit, "setting builder env variable '%1%'='%2%'", i.first, i.second);
|
printMsg(lvlVomit, "setting builder env variable '%1%'='%2%'", i.first, i.second);
|
||||||
|
|
||||||
|
@ -1063,7 +1063,7 @@ void LocalDerivationGoal::startBuilder()
|
||||||
e.addTrace({}, "while waiting for the build environment for '%s' to initialize (%s, previous messages: %s)",
|
e.addTrace({}, "while waiting for the build environment for '%s' to initialize (%s, previous messages: %s)",
|
||||||
worker.store.printStorePath(drvPath),
|
worker.store.printStorePath(drvPath),
|
||||||
statusToString(status),
|
statusToString(status),
|
||||||
concatStringsSep("|", msgs));
|
dropEmptyInitThenConcatStringsSep("|", msgs));
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
|
|
@ -152,7 +152,7 @@ static void parseConfigFiles(const std::string & contents, const std::string & p
|
||||||
|
|
||||||
parsedContents.push_back({
|
parsedContents.push_back({
|
||||||
std::move(name),
|
std::move(name),
|
||||||
concatStringsSep(" ", Strings(i, tokens.end())),
|
dropEmptyInitThenConcatStringsSep(" ", Strings(i, tokens.end())),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ template<> void BaseSetting<Strings>::appendOrSet(Strings newValue, bool append)
|
||||||
|
|
||||||
template<> std::string BaseSetting<Strings>::to_string() const
|
template<> std::string BaseSetting<Strings>::to_string() const
|
||||||
{
|
{
|
||||||
return concatStringsSep(" ", value);
|
return dropEmptyInitThenConcatStringsSep(" ", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> StringSet BaseSetting<StringSet>::parse(const std::string & str) const
|
template<> StringSet BaseSetting<StringSet>::parse(const std::string & str) const
|
||||||
|
@ -334,7 +334,7 @@ template<> void BaseSetting<StringSet>::appendOrSet(StringSet newValue, bool app
|
||||||
|
|
||||||
template<> std::string BaseSetting<StringSet>::to_string() const
|
template<> std::string BaseSetting<StringSet>::to_string() const
|
||||||
{
|
{
|
||||||
return concatStringsSep(" ", value);
|
return dropEmptyInitThenConcatStringsSep(" ", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> std::set<ExperimentalFeature> BaseSetting<std::set<ExperimentalFeature>>::parse(const std::string & str) const
|
template<> std::set<ExperimentalFeature> BaseSetting<std::set<ExperimentalFeature>>::parse(const std::string & str) const
|
||||||
|
@ -362,7 +362,7 @@ template<> std::string BaseSetting<std::set<ExperimentalFeature>>::to_string() c
|
||||||
StringSet stringifiedXpFeatures;
|
StringSet stringifiedXpFeatures;
|
||||||
for (const auto & feature : value)
|
for (const auto & feature : value)
|
||||||
stringifiedXpFeatures.insert(std::string(showExperimentalFeature(feature)));
|
stringifiedXpFeatures.insert(std::string(showExperimentalFeature(feature)));
|
||||||
return concatStringsSep(" ", stringifiedXpFeatures);
|
return dropEmptyInitThenConcatStringsSep(" ", stringifiedXpFeatures);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> StringMap BaseSetting<StringMap>::parse(const std::string & str) const
|
template<> StringMap BaseSetting<StringMap>::parse(const std::string & str) const
|
||||||
|
|
|
@ -37,7 +37,7 @@ template<class C> C tokenizeString(std::string_view s, std::string_view separato
|
||||||
* elements.
|
* elements.
|
||||||
*/
|
*/
|
||||||
template<class C>
|
template<class C>
|
||||||
std::string concatStringsSep(const std::string_view sep, const C & ss)
|
std::string dropEmptyInitThenConcatStringsSep(const std::string_view sep, const C & ss)
|
||||||
{
|
{
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
// need a cast to string_view since this is also called with Symbols
|
// need a cast to string_view since this is also called with Symbols
|
||||||
|
@ -56,7 +56,7 @@ auto concatStrings(Parts && ... parts)
|
||||||
-> std::enable_if_t<(... && std::is_convertible_v<Parts, std::string_view>), std::string>
|
-> std::enable_if_t<(... && std::is_convertible_v<Parts, std::string_view>), std::string>
|
||||||
{
|
{
|
||||||
std::string_view views[sizeof...(parts)] = { parts... };
|
std::string_view views[sizeof...(parts)] = { parts... };
|
||||||
return concatStringsSep({}, views);
|
return dropEmptyInitThenConcatStringsSep({}, views);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -608,7 +608,7 @@ struct CmdDevelop : Common, MixEnvironment
|
||||||
std::vector<std::string> args;
|
std::vector<std::string> args;
|
||||||
for (auto s : command)
|
for (auto s : command)
|
||||||
args.push_back(shellEscape(s));
|
args.push_back(shellEscape(s));
|
||||||
script += fmt("exec %s\n", concatStringsSep(" ", args));
|
script += fmt("exec %s\n", dropEmptyInitThenConcatStringsSep(" ", args));
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -49,7 +49,7 @@ std::string showVersions(const std::set<std::string> & versions)
|
||||||
std::set<std::string> versions2;
|
std::set<std::string> versions2;
|
||||||
for (auto & version : versions)
|
for (auto & version : versions)
|
||||||
versions2.insert(version.empty() ? "ε" : version);
|
versions2.insert(version.empty() ? "ε" : version);
|
||||||
return concatStringsSep(", ", versions2);
|
return dropEmptyInitThenConcatStringsSep(", ", versions2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void printClosureDiff(
|
void printClosureDiff(
|
||||||
|
@ -97,7 +97,7 @@ void printClosureDiff(
|
||||||
items.push_back(fmt("%s → %s", showVersions(removed), showVersions(added)));
|
items.push_back(fmt("%s → %s", showVersions(removed), showVersions(added)));
|
||||||
if (showDelta)
|
if (showDelta)
|
||||||
items.push_back(fmt("%s%+.1f KiB" ANSI_NORMAL, sizeDelta > 0 ? ANSI_RED : ANSI_GREEN, sizeDelta / 1024.0));
|
items.push_back(fmt("%s%+.1f KiB" ANSI_NORMAL, sizeDelta > 0 ? ANSI_RED : ANSI_GREEN, sizeDelta / 1024.0));
|
||||||
logger->cout("%s%s: %s", indent, name, concatStringsSep(", ", items));
|
logger->cout("%s%s: %s", indent, name, dropEmptyInitThenConcatStringsSep(", ", items));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ struct CmdShell : InstallablesCommand, MixEnvironment
|
||||||
|
|
||||||
auto unixPath = tokenizeString<Strings>(getEnv("PATH").value_or(""), ":");
|
auto unixPath = tokenizeString<Strings>(getEnv("PATH").value_or(""), ":");
|
||||||
unixPath.insert(unixPath.begin(), pathAdditions.begin(), pathAdditions.end());
|
unixPath.insert(unixPath.begin(), pathAdditions.begin(), pathAdditions.end());
|
||||||
auto unixPathString = concatStringsSep(":", unixPath);
|
auto unixPathString = dropEmptyInitThenConcatStringsSep(":", unixPath);
|
||||||
setEnv("PATH", unixPathString.c_str());
|
setEnv("PATH", unixPathString.c_str());
|
||||||
|
|
||||||
Strings args;
|
Strings args;
|
||||||
|
|
|
@ -805,7 +805,7 @@ struct CmdFlakeCheck : FlakeCommand
|
||||||
warn(
|
warn(
|
||||||
"The check omitted these incompatible systems: %s\n"
|
"The check omitted these incompatible systems: %s\n"
|
||||||
"Use '--all-systems' to check all.",
|
"Use '--all-systems' to check all.",
|
||||||
concatStringsSep(", ", omittedSystems)
|
dropEmptyInitThenConcatStringsSep(", ", omittedSystems)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -1211,7 +1211,7 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
|
||||||
auto attrPathS = state->symbols.resolve(attrPath);
|
auto attrPathS = state->symbols.resolve(attrPath);
|
||||||
|
|
||||||
Activity act(*logger, lvlInfo, actUnknown,
|
Activity act(*logger, lvlInfo, actUnknown,
|
||||||
fmt("evaluating '%s'", concatStringsSep(".", attrPathS)));
|
fmt("evaluating '%s'", dropEmptyInitThenConcatStringsSep(".", attrPathS)));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto recurse = [&]()
|
auto recurse = [&]()
|
||||||
|
@ -1291,7 +1291,7 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
|
||||||
if (!json)
|
if (!json)
|
||||||
logger->cout(fmt("%s " ANSI_WARNING "omitted" ANSI_NORMAL " (use '--all-systems' to show)", headerPrefix));
|
logger->cout(fmt("%s " ANSI_WARNING "omitted" ANSI_NORMAL " (use '--all-systems' to show)", headerPrefix));
|
||||||
else {
|
else {
|
||||||
logger->warn(fmt("%s omitted (use '--all-systems' to show)", concatStringsSep(".", attrPathS)));
|
logger->warn(fmt("%s omitted (use '--all-systems' to show)", dropEmptyInitThenConcatStringsSep(".", attrPathS)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (visitor.isDerivation())
|
if (visitor.isDerivation())
|
||||||
|
@ -1315,13 +1315,13 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
|
||||||
if (!json)
|
if (!json)
|
||||||
logger->cout(fmt("%s " ANSI_WARNING "omitted" ANSI_NORMAL " (use '--legacy' to show)", headerPrefix));
|
logger->cout(fmt("%s " ANSI_WARNING "omitted" ANSI_NORMAL " (use '--legacy' to show)", headerPrefix));
|
||||||
else {
|
else {
|
||||||
logger->warn(fmt("%s omitted (use '--legacy' to show)", concatStringsSep(".", attrPathS)));
|
logger->warn(fmt("%s omitted (use '--legacy' to show)", dropEmptyInitThenConcatStringsSep(".", attrPathS)));
|
||||||
}
|
}
|
||||||
} else if (!showAllSystems && std::string(attrPathS[1]) != localSystem) {
|
} else if (!showAllSystems && std::string(attrPathS[1]) != localSystem) {
|
||||||
if (!json)
|
if (!json)
|
||||||
logger->cout(fmt("%s " ANSI_WARNING "omitted" ANSI_NORMAL " (use '--all-systems' to show)", headerPrefix));
|
logger->cout(fmt("%s " ANSI_WARNING "omitted" ANSI_NORMAL " (use '--all-systems' to show)", headerPrefix));
|
||||||
else {
|
else {
|
||||||
logger->warn(fmt("%s omitted (use '--all-systems' to show)", concatStringsSep(".", attrPathS)));
|
logger->warn(fmt("%s omitted (use '--all-systems' to show)", dropEmptyInitThenConcatStringsSep(".", attrPathS)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (visitor.isDerivation())
|
if (visitor.isDerivation())
|
||||||
|
|
|
@ -185,7 +185,7 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs, virtual RootArgs
|
||||||
auto & info = i->second;
|
auto & info = i->second;
|
||||||
if (info.status == AliasStatus::Deprecated) {
|
if (info.status == AliasStatus::Deprecated) {
|
||||||
warn("'%s' is a deprecated alias for '%s'",
|
warn("'%s' is a deprecated alias for '%s'",
|
||||||
arg, concatStringsSep(" ", info.replacement));
|
arg, dropEmptyInitThenConcatStringsSep(" ", info.replacement));
|
||||||
}
|
}
|
||||||
pos = args.erase(pos);
|
pos = args.erase(pos);
|
||||||
for (auto j = info.replacement.rbegin(); j != info.replacement.rend(); ++j)
|
for (auto j = info.replacement.rbegin(); j != info.replacement.rend(); ++j)
|
||||||
|
@ -238,7 +238,7 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs, virtual RootArgs
|
||||||
lowdown. */
|
lowdown. */
|
||||||
static void showHelp(std::vector<std::string> subcommand, NixArgs & toplevel)
|
static void showHelp(std::vector<std::string> subcommand, NixArgs & toplevel)
|
||||||
{
|
{
|
||||||
auto mdName = subcommand.empty() ? "nix" : fmt("nix3-%s", concatStringsSep("-", subcommand));
|
auto mdName = subcommand.empty() ? "nix" : fmt("nix3-%s", dropEmptyInitThenConcatStringsSep("-", subcommand));
|
||||||
|
|
||||||
evalSettings.restrictEval = false;
|
evalSettings.restrictEval = false;
|
||||||
evalSettings.pureEval = false;
|
evalSettings.pureEval = false;
|
||||||
|
@ -273,7 +273,7 @@ static void showHelp(std::vector<std::string> subcommand, NixArgs & toplevel)
|
||||||
|
|
||||||
auto attr = vRes->attrs()->get(state.symbols.create(mdName + ".md"));
|
auto attr = vRes->attrs()->get(state.symbols.create(mdName + ".md"));
|
||||||
if (!attr)
|
if (!attr)
|
||||||
throw UsageError("Nix has no subcommand '%s'", concatStringsSep("", subcommand));
|
throw UsageError("Nix has no subcommand '%s'", dropEmptyInitThenConcatStringsSep("", subcommand));
|
||||||
|
|
||||||
auto markdown = state.forceString(*attr->value, noPos, "while evaluating the lowdown help text");
|
auto markdown = state.forceString(*attr->value, noPos, "while evaluating the lowdown help text");
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,7 @@ struct CmdPathInfo : StorePathsCommand, MixJSON
|
||||||
if (info->ultimate) ss.push_back("ultimate");
|
if (info->ultimate) ss.push_back("ultimate");
|
||||||
if (info->ca) ss.push_back("ca:" + renderContentAddress(*info->ca));
|
if (info->ca) ss.push_back("ca:" + renderContentAddress(*info->ca));
|
||||||
for (auto & sig : info->sigs) ss.push_back(sig);
|
for (auto & sig : info->sigs) ss.push_back(sig);
|
||||||
std::cout << concatStringsSep(" ", ss);
|
std::cout << dropEmptyInitThenConcatStringsSep(" ", ss);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
|
@ -58,7 +58,7 @@ struct ProfileElement
|
||||||
StringSet names;
|
StringSet names;
|
||||||
for (auto & path : storePaths)
|
for (auto & path : storePaths)
|
||||||
names.insert(DrvName(path.name()).name);
|
names.insert(DrvName(path.name()).name);
|
||||||
return concatStringsSep(", ", names);
|
return dropEmptyInitThenConcatStringsSep(", ", names);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -472,7 +472,7 @@ struct CmdProfileInstall : InstallablesCommand, MixDefaultProfile
|
||||||
originalConflictingFilePath,
|
originalConflictingFilePath,
|
||||||
newConflictingFilePath,
|
newConflictingFilePath,
|
||||||
originalEntryName,
|
originalEntryName,
|
||||||
concatStringsSep(" ", newConflictingRefs),
|
dropEmptyInitThenConcatStringsSep(" ", newConflictingRefs),
|
||||||
conflictError.priority,
|
conflictError.priority,
|
||||||
conflictError.priority - 1,
|
conflictError.priority - 1,
|
||||||
conflictError.priority + 1
|
conflictError.priority + 1
|
||||||
|
@ -813,7 +813,7 @@ struct CmdProfileList : virtual EvalCommand, virtual StoreCommand, MixDefaultPro
|
||||||
logger->cout("Original flake URL: %s", element.source->originalRef.to_string());
|
logger->cout("Original flake URL: %s", element.source->originalRef.to_string());
|
||||||
logger->cout("Locked flake URL: %s", element.source->lockedRef.to_string());
|
logger->cout("Locked flake URL: %s", element.source->lockedRef.to_string());
|
||||||
}
|
}
|
||||||
logger->cout("Store paths: %s", concatStringsSep(" ", store->printStorePathSet(element.storePaths)));
|
logger->cout("Store paths: %s", dropEmptyInitThenConcatStringsSep(" ", store->printStorePathSet(element.storePaths)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ struct CmdSearch : InstallableValueCommand, MixJSON
|
||||||
auto attrPathS = state->symbols.resolve(attrPath);
|
auto attrPathS = state->symbols.resolve(attrPath);
|
||||||
|
|
||||||
Activity act(*logger, lvlInfo, actUnknown,
|
Activity act(*logger, lvlInfo, actUnknown,
|
||||||
fmt("evaluating '%s'", concatStringsSep(".", attrPathS)));
|
fmt("evaluating '%s'", dropEmptyInitThenConcatStringsSep(".", attrPathS)));
|
||||||
try {
|
try {
|
||||||
auto recurse = [&]()
|
auto recurse = [&]()
|
||||||
{
|
{
|
||||||
|
@ -115,7 +115,7 @@ struct CmdSearch : InstallableValueCommand, MixJSON
|
||||||
auto aDescription = aMeta ? aMeta->maybeGetAttr(state->sDescription) : nullptr;
|
auto aDescription = aMeta ? aMeta->maybeGetAttr(state->sDescription) : nullptr;
|
||||||
auto description = aDescription ? aDescription->getString() : "";
|
auto description = aDescription ? aDescription->getString() : "";
|
||||||
std::replace(description.begin(), description.end(), '\n', ' ');
|
std::replace(description.begin(), description.end(), '\n', ' ');
|
||||||
auto attrPath2 = concatStringsSep(".", attrPathS);
|
auto attrPath2 = dropEmptyInitThenConcatStringsSep(".", attrPathS);
|
||||||
|
|
||||||
std::vector<std::smatch> attrPathMatches;
|
std::vector<std::smatch> attrPathMatches;
|
||||||
std::vector<std::smatch> descriptionMatches;
|
std::vector<std::smatch> descriptionMatches;
|
||||||
|
|
|
@ -15,7 +15,7 @@ struct RewriteParams {
|
||||||
strRewrites.insert(from + "->" + to);
|
strRewrites.insert(from + "->" + to);
|
||||||
return os <<
|
return os <<
|
||||||
"OriginalString: " << bar.originalString << std::endl <<
|
"OriginalString: " << bar.originalString << std::endl <<
|
||||||
"Rewrites: " << concatStringsSep(",", strRewrites) << std::endl <<
|
"Rewrites: " << dropEmptyInitThenConcatStringsSep(",", strRewrites) << std::endl <<
|
||||||
"Expected result: " << bar.finalString;
|
"Expected result: " << bar.finalString;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -227,32 +227,32 @@ namespace nix {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
* concatStringsSep
|
* dropEmptyInitThenConcatStringsSep
|
||||||
* --------------------------------------------------------------------------*/
|
* --------------------------------------------------------------------------*/
|
||||||
|
|
||||||
TEST(concatStringsSep, buildCommaSeparatedString) {
|
TEST(dropEmptyInitThenConcatStringsSep, buildCommaSeparatedString) {
|
||||||
Strings strings;
|
Strings strings;
|
||||||
strings.push_back("this");
|
strings.push_back("this");
|
||||||
strings.push_back("is");
|
strings.push_back("is");
|
||||||
strings.push_back("great");
|
strings.push_back("great");
|
||||||
|
|
||||||
ASSERT_EQ(concatStringsSep(",", strings), "this,is,great");
|
ASSERT_EQ(dropEmptyInitThenConcatStringsSep(",", strings), "this,is,great");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(concatStringsSep, buildStringWithEmptySeparator) {
|
TEST(dropEmptyInitThenConcatStringsSep, buildStringWithEmptySeparator) {
|
||||||
Strings strings;
|
Strings strings;
|
||||||
strings.push_back("this");
|
strings.push_back("this");
|
||||||
strings.push_back("is");
|
strings.push_back("is");
|
||||||
strings.push_back("great");
|
strings.push_back("great");
|
||||||
|
|
||||||
ASSERT_EQ(concatStringsSep("", strings), "thisisgreat");
|
ASSERT_EQ(dropEmptyInitThenConcatStringsSep("", strings), "thisisgreat");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(concatStringsSep, buildSingleString) {
|
TEST(dropEmptyInitThenConcatStringsSep, buildSingleString) {
|
||||||
Strings strings;
|
Strings strings;
|
||||||
strings.push_back("this");
|
strings.push_back("this");
|
||||||
|
|
||||||
ASSERT_EQ(concatStringsSep(",", strings), "this");
|
ASSERT_EQ(dropEmptyInitThenConcatStringsSep(",", strings), "this");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue