forked from lix-project/nix-eval-jobs
Merge pull request #57 from jsoo1/refactor-top-level-value-finding
Refactor top-level value finding.
This commit is contained in:
commit
55d91140be
|
@ -116,16 +116,19 @@ struct MyArgs : MixEvalArgs, MixCommonArgs
|
|||
|
||||
static MyArgs myArgs;
|
||||
|
||||
static void worker(
|
||||
EvalState & state,
|
||||
Bindings & autoArgs,
|
||||
AutoCloseFD & to,
|
||||
AutoCloseFD & from,
|
||||
const Path &gcRootsDir)
|
||||
{
|
||||
static Value* releaseExprTopLevelValue(EvalState & state, Bindings & autoArgs) {
|
||||
Value vTop;
|
||||
|
||||
if (myArgs.flake) {
|
||||
state.evalFile(lookupFileArg(state, myArgs.releaseExpr), vTop);
|
||||
|
||||
auto vRoot = state.allocValue();
|
||||
|
||||
state.autoCallFunction(autoArgs, vTop, *vRoot);
|
||||
|
||||
return vRoot;
|
||||
}
|
||||
|
||||
static Value* flakeTopLevelValue(EvalState & state, Bindings & autoArgs) {
|
||||
using namespace flake;
|
||||
|
||||
auto [flakeRef, fragment] = parseFlakeRefWithFragment(myArgs.releaseExpr, absPath("."));
|
||||
|
@ -143,7 +146,7 @@ static void worker(
|
|||
|
||||
auto vOutputs = vFlake->attrs->get(state.symbols.create("outputs"))->value;
|
||||
state.forceValue(*vOutputs, noPos);
|
||||
vTop = *vOutputs;
|
||||
auto vTop = *vOutputs;
|
||||
|
||||
if (fragment.length() > 0) {
|
||||
Bindings & bindings(*state.allocBindings(0));
|
||||
|
@ -153,13 +156,27 @@ static void worker(
|
|||
vTop = *nTop;
|
||||
}
|
||||
|
||||
} else {
|
||||
state.evalFile(lookupFileArg(state, myArgs.releaseExpr), vTop);
|
||||
}
|
||||
|
||||
auto vRoot = state.allocValue();
|
||||
state.autoCallFunction(autoArgs, vTop, *vRoot);
|
||||
|
||||
return vRoot;
|
||||
}
|
||||
|
||||
Value * topLevelValue(EvalState & state, Bindings & autoArgs) {
|
||||
return myArgs.flake
|
||||
? flakeTopLevelValue(state, autoArgs)
|
||||
: releaseExprTopLevelValue(state, autoArgs);
|
||||
}
|
||||
|
||||
static void worker(
|
||||
EvalState & state,
|
||||
Bindings & autoArgs,
|
||||
AutoCloseFD & to,
|
||||
AutoCloseFD & from,
|
||||
const Path &gcRootsDir)
|
||||
{
|
||||
auto vRoot = topLevelValue(state, autoArgs);
|
||||
|
||||
while (true) {
|
||||
/* Wait for the master to send us a job name. */
|
||||
writeLine(to.get(), "next");
|
||||
|
|
Loading…
Reference in a new issue