diff --git a/lib/fusesocLib.nix b/lib/fusesocLib.nix index 0fe720f..df62d61 100644 --- a/lib/fusesocLib.nix +++ b/lib/fusesocLib.nix @@ -105,6 +105,17 @@ rec { in parsed // { inherit condition; }; + stripCond = + cond: + let + # extract the argument from conditional syntax + # e.g. + # "tool_quartus ? (data/fifo.sdc)" -> ["data/fifo.sdc"] + # "rtl/fifo.v" -> Null + stripped = builtins.match ''^!?[_a-zA-Z]*[[:space:]]*\??[[:space:]]*\((.*)\)$'' cond; + in + if (isNull stripped) then cond else builtins.head stripped; + resolveDeps = import ./resolveDeps.nix { inherit lib parseDependency; }; mkCoreSet = @@ -215,12 +226,13 @@ rec { importCore = import ./importCore.nix { inherit - lib formats - readYAML - stdenvNoCC + lib mkRunners parseVlnv + readYAML + stdenvNoCC + stripCond ; }; diff --git a/lib/importCore.nix b/lib/importCore.nix index 6d043d0..d399668 100644 --- a/lib/importCore.nix +++ b/lib/importCore.nix @@ -1,10 +1,11 @@ { - lib, formats, - readYAML, - stdenvNoCC, + lib, mkRunners, parseVlnv, + readYAML, + stdenvNoCC, + stripCond, }: lib.extendMkDerivation { constructDrv = stdenvNoCC.mkDerivation; @@ -25,13 +26,15 @@ lib.extendMkDerivation { }: let useCoreFile = isNull core; - core' = if useCoreFile then readYAML "${coreRoot}/${coreName}" else core; + core' = if useCoreFile then (readYAML "${coreRoot}/${coreName}") else core; parsed = parseVlnv finalAttrs.passthru.core.name; + coreFileset = builtins.concatLists ( lib.mapAttrsToList ( n: v: map ( - relPath: if builtins.isAttrs relPath then (builtins.head (builtins.attrNames relPath)) else relPath + entry: + stripCond (if builtins.isAttrs entry then (builtins.head (builtins.attrNames entry)) else entry) ) (v.files or [ ]) ) finalAttrs.passthru.core.filesets );