Skip to content

Commit

Permalink
log all ifd
Browse files Browse the repository at this point in the history
  • Loading branch information
cleverca22 committed Mar 5, 2020
1 parent 2e953b5 commit 8dc4d0b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/libexpr/eval.hh
Expand Up @@ -281,7 +281,7 @@ public:
/* Print statistics. */
void printStats();

void realiseContext(const PathSet & context);
void realiseContext(const PathSet & context, const Pos &pos, const string reason);

private:

Expand Down
21 changes: 13 additions & 8 deletions src/libexpr/primops.cc
Expand Up @@ -46,17 +46,22 @@ std::pair<string, string> decodeContext(const string & s)
InvalidPathError::InvalidPathError(const Path & path) :
EvalError("path '%s' is not valid", path), path(path) {}

void EvalState::realiseContext(const PathSet & context)
void EvalState::realiseContext(const PathSet & context, const Pos &pos, const string reason)
{
std::vector<StorePathWithOutputs> drvs;

if (context.size() > 0) {
//printInfo(format("realiseContext %1% %2% %3%") % pos % reason % context.size());
}

for (auto & i : context) {
std::pair<string, string> decoded = decodeContext(i);
auto ctx = store->parseStorePath(decoded.first);
if (!store->isValidPath(ctx))
throw InvalidPathError(store->printStorePath(ctx));
if (!decoded.second.empty() && ctx.isDerivation()) {
drvs.push_back(StorePathWithOutputs{ctx.clone(), {decoded.second}});
printInfo(format("%1% depends on %2% via %3%") % pos % decoded.first % reason);

/* Add the output of this derivation to the allowed
paths. */
Expand Down Expand Up @@ -92,7 +97,7 @@ static void prim_scopedImport(EvalState & state, const Pos & pos, Value * * args
Path path = state.coerceToPath(pos, *args[1], context);

try {
state.realiseContext(context);
state.realiseContext(context, pos, "scopedImport");
} catch (InvalidPathError & e) {
throw EvalError(format("cannot import '%1%', since path '%2%' is not valid, at %3%")
% path % e.path % pos);
Expand Down Expand Up @@ -162,7 +167,7 @@ void prim_importNative(EvalState & state, const Pos & pos, Value * * args, Value
Path path = state.coerceToPath(pos, *args[0], context);

try {
state.realiseContext(context);
state.realiseContext(context, pos, "importNative");
} catch (InvalidPathError & e) {
throw EvalError(format("cannot import '%1%', since path '%2%' is not valid, at %3%")
% path % e.path % pos);
Expand Down Expand Up @@ -209,7 +214,7 @@ void prim_exec(EvalState & state, const Pos & pos, Value * * args, Value & v)
commandArgs.emplace_back(state.coerceToString(pos, *elems[i], context, false, false));
}
try {
state.realiseContext(context);
state.realiseContext(context, pos, "exec");
} catch (InvalidPathError & e) {
throw EvalError(format("cannot execute '%1%', since path '%2%' is not valid, at %3%")
% program % e.path % pos);
Expand Down Expand Up @@ -825,7 +830,7 @@ static void prim_pathExists(EvalState & state, const Pos & pos, Value * * args,
PathSet context;
Path path = state.coerceToPath(pos, *args[0], context);
try {
state.realiseContext(context);
state.realiseContext(context, pos, "pathExists");
} catch (InvalidPathError & e) {
throw EvalError(format(
"cannot check the existence of '%1%', since path '%2%' is not valid, at %3%")
Expand Down Expand Up @@ -870,7 +875,7 @@ static void prim_readFile(EvalState & state, const Pos & pos, Value * * args, Va
PathSet context;
Path path = state.coerceToPath(pos, *args[0], context);
try {
state.realiseContext(context);
state.realiseContext(context, pos, "readFile");
} catch (InvalidPathError & e) {
throw EvalError(format("cannot read '%1%', since path '%2%' is not valid, at %3%")
% path % e.path % pos);
Expand Down Expand Up @@ -907,7 +912,7 @@ static void prim_findFile(EvalState & state, const Pos & pos, Value * * args, Va
string path = state.coerceToString(pos, *i->value, context, false, false);

try {
state.realiseContext(context);
state.realiseContext(context, pos, "findFile");
} catch (InvalidPathError & e) {
throw EvalError(format("cannot find '%1%', since path '%2%' is not valid, at %3%")
% path % e.path % pos);
Expand Down Expand Up @@ -941,7 +946,7 @@ static void prim_readDir(EvalState & state, const Pos & pos, Value * * args, Val
PathSet ctx;
Path path = state.coerceToPath(pos, *args[0], ctx);
try {
state.realiseContext(ctx);
state.realiseContext(ctx, pos, "readDir");
} catch (InvalidPathError & e) {
throw EvalError(format("cannot read '%1%', since path '%2%' is not valid, at %3%")
% path % e.path % pos);
Expand Down

0 comments on commit 8dc4d0b

Please sign in to comment.