kicad: Rename <feature>Support arguments to with<Feature>

Also: Use assertions instead of silently ignoring arguments that don't cooperate
(occ+oce) / won't compile (aarch64 + oce).

base.nix no longer provides default argument values since these are
provided by default.nix.
This commit is contained in:
Matt Huszagh 2020-10-10 14:44:56 -07:00
parent 85d5195f70
commit 9d13164b27
2 changed files with 41 additions and 30 deletions

View File

@ -22,37 +22,36 @@
, lndir , lndir
, callPackages , callPackages
, stable ? true , stable
, baseName ? "kicad" , baseName
, versions ? { } , versions
, oceSupport ? false , withOCE
, opencascade , opencascade
, withOCCT ? true , withOCC
, opencascade-occt , opencascade-occt
, ngspiceSupport ? true , withNgspice
, libngspice , libngspice
, scriptingSupport ? true , withScripting
, swig , swig
, python , python
, wxPython , wxPython
, debug ? false , debug
, valgrind , valgrind
, withI18n ? true , withI18n
, gtk3 , gtk3
}: }:
assert ngspiceSupport -> libngspice != null; assert stdenv.lib.asserts.assertMsg (!(withOCE && stdenv.isAarch64)) "OCE fails a test on Aarch64";
assert stdenv.lib.asserts.assertMsg (!(withOCC && withOCE))
"Only one of OCC and OCE may be enabled";
let let
versionConfig = versions.${baseName}; versionConfig = versions.${baseName};
# oce on aarch64 fails a test
withOCE = oceSupport && !stdenv.isAarch64;
withOCC = (withOCCT && !withOCE) || (oceSupport && stdenv.isAarch64);
libraries = callPackages ./libraries.nix versionConfig.libVersion; libraries = callPackages ./libraries.nix versionConfig.libVersion;
inherit (stdenv.lib) optional optionals; inherit (stdenv.lib) optional optionals;
versionConfig = versions.${baseName};
libraries = callPackages ./libraries.nix versionConfig.libVersion;
in in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
@ -93,15 +92,15 @@ stdenv.mkDerivation rec {
makeFlags = optional (debug) [ "CFLAGS+=-Og" "CFLAGS+=-ggdb" ]; makeFlags = optional (debug) [ "CFLAGS+=-Og" "CFLAGS+=-ggdb" ];
cmakeFlags = cmakeFlags =
optionals (scriptingSupport) [ optionals (withScripting) [
"-DKICAD_SCRIPTING=ON" "-DKICAD_SCRIPTING=ON"
"-DKICAD_SCRIPTING_MODULES=ON" "-DKICAD_SCRIPTING_MODULES=ON"
"-DKICAD_SCRIPTING_PYTHON3=ON" "-DKICAD_SCRIPTING_PYTHON3=ON"
"-DKICAD_SCRIPTING_WXPYTHON_PHOENIX=ON" "-DKICAD_SCRIPTING_WXPYTHON_PHOENIX=ON"
] ]
++ optional (!scriptingSupport) ++ optional (!withScripting)
"-DKICAD_SCRIPTING=OFF" "-DKICAD_SCRIPTING=OFF"
++ optional (ngspiceSupport) "-DKICAD_SPICE=ON" ++ optional (withNgspice) "-DKICAD_SPICE=ON"
++ optional (!withOCE) "-DKICAD_USE_OCE=OFF" ++ optional (!withOCE) "-DKICAD_USE_OCE=OFF"
++ optional (!withOCC) "-DKICAD_USE_OCC=OFF" ++ optional (!withOCC) "-DKICAD_USE_OCC=OFF"
++ optionals (withOCE) [ ++ optionals (withOCE) [
@ -139,8 +138,8 @@ stdenv.mkDerivation rec {
boost boost
gtk3 gtk3
] ]
++ optionals (scriptingSupport) [ swig python wxPython ] ++ optionals (withScripting) [ swig python wxPython ]
++ optional (ngspiceSupport) libngspice ++ optional (withNgspice) libngspice
++ optional (withOCE) opencascade ++ optional (withOCE) opencascade
++ optional (withOCC) opencascade-occt ++ optional (withOCC) opencascade-occt
++ optional (debug) valgrind ++ optional (debug) valgrind

View File

@ -14,12 +14,16 @@
, pname ? "kicad" , pname ? "kicad"
, stable ? true , stable ? true
, oceSupport ? false , oceSupport ? false
, withOCE ? false
, opencascade , opencascade
, withOCCT ? true , withOCCT ? false
, withOCC ? true
, opencascade-occt , opencascade-occt
, ngspiceSupport ? true , ngspiceSupport ? false
, withNgspice ? true
, libngspice , libngspice
, scriptingSupport ? true , scriptingSupport ? false
, withScripting ? true
, swig , swig
, python3 , python3
, debug ? false , debug ? false
@ -28,7 +32,15 @@
, withI18n ? true , withI18n ? true
}: }:
assert ngspiceSupport -> libngspice != null; assert withNgspice -> libngspice != null;
assert stdenv.lib.assertMsg (!ngspiceSupport)
"`nspiceSupport` was renamed to `withNgspice` for the sake of consistency with other kicad nix arguments.";
assert stdenv.lib.assertMsg (!oceSupport)
"`oceSupport` was renamed to `withOCE` for the sake of consistency with other kicad nix arguments.";
assert stdenv.lib.assertMsg (!scriptingSupport)
"`scriptingSupport` was renamed to `withScripting` for the sake of consistency with other kicad nix arguments.";
assert stdenv.lib.assertMsg (!withOCCT)
"`withOCCT` was renamed to `withOCC` for the sake of consistency with upstream cmake options.";
let let
baseName = if (stable) then "kicad" else "kicad-unstable"; baseName = if (stable) then "kicad" else "kicad-unstable";
@ -61,7 +73,7 @@ stdenv.mkDerivation rec {
base = callPackage ./base.nix { base = callPackage ./base.nix {
inherit versions stable baseName; inherit versions stable baseName;
inherit wxGTK python wxPython; inherit wxGTK python wxPython;
inherit debug withI18n withOCCT oceSupport ngspiceSupport scriptingSupport; inherit debug withI18n withOCC withOCE withNgspice withScripting;
}; };
inherit pname; inherit pname;
@ -73,11 +85,11 @@ stdenv.mkDerivation rec {
dontBuild = true; dontBuild = true;
dontFixup = true; dontFixup = true;
pythonPath = optionals (scriptingSupport) pythonPath = optionals (withScripting)
[ wxPython python.pkgs.six ]; [ wxPython python.pkgs.six ];
nativeBuildInputs = [ makeWrapper ] nativeBuildInputs = [ makeWrapper ]
++ optionals (scriptingSupport) ++ optionals (withScripting)
[ python.pkgs.wrapPython ]; [ python.pkgs.wrapPython ];
# We are emulating wrapGAppsHook, along with other variables to the # We are emulating wrapGAppsHook, along with other variables to the
@ -99,7 +111,7 @@ stdenv.mkDerivation rec {
"--prefix KICAD_TEMPLATE_DIR : ${footprints}/share/kicad/template" "--prefix KICAD_TEMPLATE_DIR : ${footprints}/share/kicad/template"
] ]
++ optionals (with3d) [ "--set KISYS3DMOD ${packages3d}/share/kicad/modules/packages3d" ] ++ optionals (with3d) [ "--set KISYS3DMOD ${packages3d}/share/kicad/modules/packages3d" ]
++ optionals (ngspiceSupport) [ "--prefix LD_LIBRARY_PATH : ${libngspice}/lib" ] ++ optionals (withNgspice) [ "--prefix LD_LIBRARY_PATH : ${libngspice}/lib" ]
# infinisil's workaround for #39493 # infinisil's workaround for #39493
++ [ "--set GDK_PIXBUF_MODULE_FILE ${librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache" ] ++ [ "--set GDK_PIXBUF_MODULE_FILE ${librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache" ]
@ -115,12 +127,12 @@ stdenv.mkDerivation rec {
in in
(concatStringsSep "\n" (concatStringsSep "\n"
(flatten [ (flatten [
(optionalString (scriptingSupport) "buildPythonPath \"${base} $pythonPath\" \n") (optionalString (withScripting) "buildPythonPath \"${base} $pythonPath\" \n")
# wrap each of the directly usable tools # wrap each of the directly usable tools
(map (map
(tool: "makeWrapper ${base}/bin/${tool} $out/bin/${tool} $makeWrapperArgs" (tool: "makeWrapper ${base}/bin/${tool} $out/bin/${tool} $makeWrapperArgs"
+ optionalString (scriptingSupport) " --set PYTHONPATH \"$program_PYTHONPATH\"" + optionalString (withScripting) " --set PYTHONPATH \"$program_PYTHONPATH\""
) )
tools) tools)