* textClosure: don't use uniqList, and don't rely on buggy behaviour

in the Nix expression evaluator (namely that comparison of attribute
  sets works properly).
* Removed some redundant parentheses in builder-defs.

svn path=/nixpkgs/trunk/; revision=15551
This commit is contained in:
Eelco Dolstra 2009-05-11 15:21:42 +00:00
parent 2f33cdec38
commit abf71d5352
3 changed files with 38 additions and 42 deletions

View File

@ -90,8 +90,7 @@ args: with args; with stringsWithDeps; with lib;
NIX_GCC=${stdenv.gcc}
export SHELL=${stdenv.shell}
PATH_DELIMITER=':'
" + (if ((stdenv ? preHook) && (stdenv.preHook != null) &&
((toString stdenv.preHook) != "")) then
" + (if stdenv ? preHook && stdenv.preHook != null && toString stdenv.preHook != "" then
"
param1=${stdenv.param1}
param2=${stdenv.param2}
@ -354,24 +353,24 @@ args: with args; with stringsWithDeps; with lib;
/*debug = x:(__trace x x);
debugX = x:(__trace (__toXML x) x);*/
replaceScriptVar = file: name: value: ("sed -e 's`^${name}=.*`${name}='\\''${value}'\\''`' -i ${file}");
replaceInScript = file: l: (concatStringsSep "\n" ((pairMap (replaceScriptVar file) l)));
replaceScripts = l:(concatStringsSep "\n" (pairMap replaceInScript l));
doReplaceScripts = FullDepEntry (replaceScripts (getAttr ["shellReplacements"] [] args)) [minInit];
makeNest = x:(if x==defNest.text then x else "startNest\n" + x + "\nstopNest\n");
textClosure = a : steps : textClosureMapOveridable makeNest a (["defNest"] ++ steps);
replaceScriptVar = file: name: value: "sed -e 's`^${name}=.*`${name}='\\''${value}'\\''`' -i ${file}";
replaceInScript = file: l: concatStringsSep "\n" ((pairMap (replaceScriptVar file) l));
replaceScripts = l: concatStringsSep "\n" (pairMap replaceInScript l);
doReplaceScripts = FullDepEntry (replaceScripts (getAttr ["shellReplacements"] [] args)) ["minInit"];
makeNest = x: if x == defNest.text then x else "startNest\n" + x + "\nstopNest\n";
textClosure = a: steps: textClosureMap makeNest a (["defNest"] ++ steps);
inherit noDepEntry FullDepEntry PackEntry;
defList = (getAttr ["defList"] [] args);
defList = getAttr ["defList"] [] args;
getVal = getValue args defList;
check = checkFlag args;
reqsList = getAttr ["reqsList"] [] args;
buildInputsNames = filter (x: (null != getVal x))
buildInputsNames = filter (x: null != getVal x)
(uniqList {inputList =
(concatLists (map
(x:(if (x==[]) then [] else builtins.tail x))
reqsList));});
(concatLists (map
(x: if x==[] then [] else builtins.tail x)
reqsList));});
configFlags = getAttr ["configFlags"] [] args;
buildFlags = getAttr ["buildFlags"] [] args;
nameSuffixes = getAttr ["nameSuffixes"] [] args;
@ -440,8 +439,7 @@ args: with args; with stringsWithDeps; with lib;
stdenv.mkDerivation ((rec {
inherit (localDefs) name;
builder = writeScript (name + "-builder")
(textClosure localDefs localDefs.realPhaseNames);
buildCommand = textClosure localDefs localDefs.realPhaseNames;
meta = localDefs.meta;
passthru = localDefs.passthru // {inherit (localDefs) src; };
}) // (if localDefs ? propagatedBuildInputs then {

View File

@ -160,7 +160,8 @@ rec {
(val!=null) && (val!=false))
(tail x))))) condList)) ;
# !!! This function has O(n^2) performance, so you probably don't want to use it!
uniqList = {inputList, outputList ? []}:
if (inputList == []) then outputList else
let x=head inputList;

View File

@ -13,38 +13,35 @@ Usage:
See trace/nixpkgs/trunk/pkgs/top-level/builder-defs.nix for some predefined build steps
*/
args:
with args;
{stdenv, lib}:
with lib;
let
inherit (builtins) head tail isList isAttrs;
in
rec {
textClosureDupList = arg:
if isList arg then
textClosureDupList {text = ""; deps = arg;}
else
concatLists (map textClosureDupList arg.deps) ++ [arg];
/* !!! The interface of this function is kind of messed up, since
it's way too overloaded and almost but not quite computes a
topological sort of the depstrings. */
textClosureDupListOverridable = predefined: arg:
if isList arg then
textClosureDupListOverridable predefined {text = ""; deps = arg;}
else if isAttrs arg then
concatLists (map (textClosureDupListOverridable predefined) arg.deps) ++ [arg]
else
textClosureDupListOverridable predefined (getAttr [arg] [] predefined);
textClosureListOverridable = predefined: arg:
map (x: x.text) (uniqList {inputList = textClosureDupListOverridable predefined arg;});
textClosureOverridable = predefined: arg: concatStringsSep "\n" (textClosureListOverridable predefined arg);
textClosureMapOveridable = f: predefined: arg:
concatStringsSep "\n" (map f (textClosureListOverridable predefined arg));
textClosureList = predefined: arg:
let
f = done: todo:
if todo == [] then {result = []; inherit done;}
else
let entry = head todo; in
if isAttrs entry then
let x = f done entry.deps;
y = f x.done (tail todo);
in { result = x.result ++ [entry.text] ++ y.result;
done = y.done;
}
else if hasAttr entry done then f done (tail todo)
else f (done // listToAttrs [{name = entry; value = 1;}]) ([(builtins.getAttr entry predefined)] ++ tail todo);
in (f {} arg).result;
textClosureMap = f: predefined: names:
concatStringsSep "\n" (map f (textClosureList predefined names));
noDepEntry = text: {inherit text; deps = [];};
fullDepEntry = text: deps: {inherit text deps;};