forked from lix-project/lix
Warn about missing -I paths
Fixes #121. Note that we don't warn about missing $NIX_PATH entries because it's intended that some may be missing (cf. the default $NIX_PATH on NixOS, which includes paths like /etc/nixos/nixpkgs for backward compatibility).
This commit is contained in:
parent
733214144a
commit
f14ef84a51
|
@ -39,7 +39,7 @@ bool parseSearchPathArg(const string & arg, Strings::iterator & i,
|
||||||
{
|
{
|
||||||
if (arg != "-I") return false;
|
if (arg != "-I") return false;
|
||||||
if (i == argsEnd) throw UsageError(format("`%1%' requires an argument") % arg);;
|
if (i == argsEnd) throw UsageError(format("`%1%' requires an argument") % arg);;
|
||||||
state.addToSearchPath(*i++);
|
state.addToSearchPath(*i++, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ public:
|
||||||
EvalState();
|
EvalState();
|
||||||
~EvalState();
|
~EvalState();
|
||||||
|
|
||||||
void addToSearchPath(const string & s);
|
void addToSearchPath(const string & s, bool warn = false);
|
||||||
|
|
||||||
/* Parse a Nix expression from the specified file. */
|
/* Parse a Nix expression from the specified file. */
|
||||||
Expr * parseExprFromFile(const Path & path);
|
Expr * parseExprFromFile(const Path & path);
|
||||||
|
|
|
@ -608,7 +608,7 @@ Expr * EvalState::parseExprFromString(const string & s, const Path & basePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EvalState::addToSearchPath(const string & s)
|
void EvalState::addToSearchPath(const string & s, bool warn)
|
||||||
{
|
{
|
||||||
size_t pos = s.find('=');
|
size_t pos = s.find('=');
|
||||||
string prefix;
|
string prefix;
|
||||||
|
@ -624,7 +624,8 @@ void EvalState::addToSearchPath(const string & s)
|
||||||
if (pathExists(path)) {
|
if (pathExists(path)) {
|
||||||
debug(format("adding path `%1%' to the search path") % path);
|
debug(format("adding path `%1%' to the search path") % path);
|
||||||
searchPath.insert(searchPathInsertionPoint, std::pair<string, Path>(prefix, path));
|
searchPath.insert(searchPathInsertionPoint, std::pair<string, Path>(prefix, path));
|
||||||
}
|
} else if (warn)
|
||||||
|
printMsg(lvlError, format("warning: Nix search path entry `%1%' does not exist, ignoring") % path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue