mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-12-04 03:16:16 +02:00
* Allow multiple --attr / -A arguments in nix-build / nix-instantiate
(NIX-74).
This commit is contained in:
parent
215505bb46
commit
f25f900045
1 changed files with 20 additions and 15 deletions
|
@ -64,16 +64,19 @@ static void printResult(EvalState & state, Expr e,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Expr doEval(EvalState & state, string attrPath, bool parseOnly, bool strict,
|
void processExpr(EvalState & state, const Strings & attrPaths,
|
||||||
const ATermMap & autoArgs, Expr e)
|
bool parseOnly, bool strict, const ATermMap & autoArgs,
|
||||||
|
bool evalOnly, bool xmlOutput, Expr e)
|
||||||
{
|
{
|
||||||
e = findAlongAttrPath(state, attrPath, autoArgs, e);
|
for (Strings::const_iterator i = attrPaths.begin(); i != attrPaths.end(); ++i) {
|
||||||
if (!parseOnly)
|
Expr e2 = findAlongAttrPath(state, *i, autoArgs, e);
|
||||||
if (strict)
|
if (!parseOnly)
|
||||||
e = strictEvalExpr(state, e);
|
if (strict)
|
||||||
else
|
e2 = strictEvalExpr(state, e2);
|
||||||
e = evalExpr(state, e);
|
else
|
||||||
return e;
|
e2 = evalExpr(state, e2);
|
||||||
|
printResult(state, e2, evalOnly, xmlOutput, autoArgs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,7 +89,7 @@ void run(Strings args)
|
||||||
bool parseOnly = false;
|
bool parseOnly = false;
|
||||||
bool xmlOutput = false;
|
bool xmlOutput = false;
|
||||||
bool strict = false;
|
bool strict = false;
|
||||||
string attrPath;
|
Strings attrPaths;
|
||||||
ATermMap autoArgs(128);
|
ATermMap autoArgs(128);
|
||||||
|
|
||||||
for (Strings::iterator i = args.begin();
|
for (Strings::iterator i = args.begin();
|
||||||
|
@ -107,7 +110,7 @@ void run(Strings args)
|
||||||
else if (arg == "--attr" || arg == "-A") {
|
else if (arg == "--attr" || arg == "-A") {
|
||||||
if (i == args.end())
|
if (i == args.end())
|
||||||
throw UsageError("`--attr' requires an argument");
|
throw UsageError("`--attr' requires an argument");
|
||||||
attrPath = *i++;
|
attrPaths.push_back(*i++);
|
||||||
}
|
}
|
||||||
else if (arg == "--arg") {
|
else if (arg == "--arg") {
|
||||||
if (i == args.end())
|
if (i == args.end())
|
||||||
|
@ -135,12 +138,14 @@ void run(Strings args)
|
||||||
files.push_back(arg);
|
files.push_back(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (attrPaths.empty()) attrPaths.push_back("");
|
||||||
|
|
||||||
store = openStore();
|
store = openStore();
|
||||||
|
|
||||||
if (readStdin) {
|
if (readStdin) {
|
||||||
Expr e = parseStdin(state);
|
Expr e = parseStdin(state);
|
||||||
e = doEval(state, attrPath, parseOnly, strict, autoArgs, e);
|
processExpr(state, attrPaths, parseOnly, strict, autoArgs,
|
||||||
printResult(state, e, evalOnly, xmlOutput, autoArgs);
|
evalOnly, xmlOutput, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Strings::iterator i = files.begin();
|
for (Strings::iterator i = files.begin();
|
||||||
|
@ -148,8 +153,8 @@ void run(Strings args)
|
||||||
{
|
{
|
||||||
Path path = absPath(*i);
|
Path path = absPath(*i);
|
||||||
Expr e = parseExprFromFile(state, path);
|
Expr e = parseExprFromFile(state, path);
|
||||||
e = doEval(state, attrPath, parseOnly, strict, autoArgs, e);
|
processExpr(state, attrPaths, parseOnly, strict, autoArgs,
|
||||||
printResult(state, e, evalOnly, xmlOutput, autoArgs);
|
evalOnly, xmlOutput, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
printEvalStats(state);
|
printEvalStats(state);
|
||||||
|
|
Loading…
Reference in a new issue