yosys: add option to build with Python binding

This commit is contained in:
Martin Povišer 2023-11-30 17:59:28 +01:00 committed by Austin Seipp
parent 3cf86d366e
commit e55ea6167f
3 changed files with 17 additions and 1 deletions

View File

@ -3,6 +3,7 @@
, abc-verifier
, bash
, bison
, boost
, fetchFromGitHub
, flex
, libffi
@ -18,6 +19,7 @@
, yosys-bluespec
, yosys-ghdl
, yosys-symbiflow
, enablePython ? false # enable python binding
}:
# NOTE: as of late 2020, yosys has switched to an automation robot that
@ -68,6 +70,10 @@ let
ghdl = yosys-ghdl;
} // (yosys-symbiflow);
boost_python = boost.override {
enablePython = true;
python = python3;
};
in stdenv.mkDerivation (finalAttrs: {
pname = "yosys";
@ -90,7 +96,7 @@ in stdenv.mkDerivation (finalAttrs: {
(python3.withPackages (pp: with pp; [
click
]))
];
] ++ lib.optional enablePython boost_python;
makeFlags = [ "PREFIX=${placeholder "out"}"];
@ -123,6 +129,10 @@ in stdenv.mkDerivation (finalAttrs: {
echo "ERROR: yosys version in Makefile isn't equivalent to version of the nix package (allegedly ${finalAttrs.version}), failing."
exit 1
fi
'' + lib.optionalString enablePython ''
echo "ENABLE_PYOSYS := 1" >> Makefile.conf
echo "PYTHON_DESTDIR := $out/${python3.sitePackages}" >> Makefile.conf
echo "BOOST_PYTHON_LIB := -lboost_python${lib.versions.major python3.version}${lib.versions.minor python3.version}" >> Makefile.conf
'';
checkTarget = "test";

View File

@ -17414,6 +17414,7 @@ with pkgs;
yasm = callPackage ../development/compilers/yasm { };
yosys = callPackage ../development/compilers/yosys { };
yosysWithPython = callPackage ../development/compilers/yosys { enablePython = true; };
yosys-bluespec = callPackage ../development/compilers/yosys/plugins/bluespec.nix { };
yosys-ghdl = callPackage ../development/compilers/yosys/plugins/ghdl.nix { };
yosys-synlig = callPackage ../development/compilers/yosys/plugins/synlig.nix { };

View File

@ -16061,6 +16061,11 @@ self: super: with self; {
yolink-api = callPackage ../development/python-modules/yolink-api { };
yosys = toPythonModule (pkgs.yosys.override {
python3 = python;
enablePython = true;
});
youless-api = callPackage ../development/python-modules/youless-api { };
youtube-dl = callPackage ../tools/misc/youtube-dl { };