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

View File

@ -161,6 +161,7 @@ rec {
(tail x))))) condList)) ; (tail x))))) condList)) ;
# !!! This function has O(n^2) performance, so you probably don't want to use it!
uniqList = {inputList, outputList ? []}: uniqList = {inputList, outputList ? []}:
if (inputList == []) then outputList else if (inputList == []) then outputList else
let x=head inputList; 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 See trace/nixpkgs/trunk/pkgs/top-level/builder-defs.nix for some predefined build steps
*/ */
args:
with args; {stdenv, lib}:
with lib; with lib;
let
inherit (builtins) head tail isList isAttrs;
in
rec { rec {
textClosureDupList = arg: /* !!! The interface of this function is kind of messed up, since
if isList arg then it's way too overloaded and almost but not quite computes a
textClosureDupList {text = ""; deps = arg;} topological sort of the depstrings. */
textClosureList = predefined: arg:
let
f = done: todo:
if todo == [] then {result = []; inherit done;}
else else
concatLists (map textClosureDupList arg.deps) ++ [arg]; 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;
textClosureDupListOverridable = predefined: arg: textClosureMap = f: predefined: names:
if isList arg then concatStringsSep "\n" (map f (textClosureList predefined names));
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));
noDepEntry = text: {inherit text; deps = [];}; noDepEntry = text: {inherit text; deps = [];};
fullDepEntry = text: deps: {inherit text deps;}; fullDepEntry = text: deps: {inherit text deps;};