fix(buildLisp): Perform a topological sort of dependencies
This ensures that dependencies are loaded in the correct order in larger dependency graphs.
This commit is contained in:
parent
06362a812e
commit
2a170f1ed7
1 changed files with 7 additions and 8 deletions
|
@ -61,15 +61,14 @@ let
|
||||||
))
|
))
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
# 'dependsOn' determines whether Lisp library 'b' depends on 'a'.
|
||||||
|
dependsOn = a: b: builtins.elem a b.lispDeps;
|
||||||
|
|
||||||
# 'allDeps' flattens the list of dependencies (and their
|
# 'allDeps' flattens the list of dependencies (and their
|
||||||
# dependencies) into one list of unique deps.
|
# dependencies) into one ordered list of unique deps.
|
||||||
#
|
allDeps = deps: (lib.toposort dependsOn (lib.unique (
|
||||||
# TODO(tazjin): Ordering needs to be stable (first occurences from
|
lib.flatten (deps ++ (map (d: d.lispDeps) deps))
|
||||||
# innermost to outer), I don't know if this works accidentally or is
|
))).result;
|
||||||
# guaranteed by these lib functions.
|
|
||||||
allDeps = deps: lib.reverseList (
|
|
||||||
lib.unique (lib.flatten (deps ++ (map (d: d.lispDeps) deps)))
|
|
||||||
);
|
|
||||||
|
|
||||||
# 'genDumpLisp' generates a Lisp file that instructs SBCL to dump
|
# 'genDumpLisp' generates a Lisp file that instructs SBCL to dump
|
||||||
# the currently loaded image as an executable to $out/bin/$name.
|
# the currently loaded image as an executable to $out/bin/$name.
|
||||||
|
|
Loading…
Reference in a new issue