Skip to content

Commit

Permalink
yosys: Added plugins support and various fixes
Browse files Browse the repository at this point in the history
* fixed buildInputs and nativeBuildInputs for cross compilation
* don't use pkgconfig alias
* simplified patchPhase
* made the version variable overridable in preBuild
  • Loading branch information
Mihai-Drosi Câju committed Jan 10, 2021
1 parent d8c2a4f commit d81e4d9
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions pkgs/development/compilers/yosys/default.nix
Expand Up @@ -5,13 +5,14 @@
, fetchFromGitHub
, flex
, libffi
, pkgconfig
, pkg-config
, protobuf
, python3
, readline
, tcl
, verilog
, zlib
, plugins ? []
}:

# NOTE: as of late 2020, yosys has switched to an automation robot that
Expand All @@ -32,6 +33,8 @@
# ultimately less confusing than using dates.

stdenv.mkDerivation rec {
inherit plugins;

pname = "yosys";
version = "0.9+3830";

Expand All @@ -43,21 +46,16 @@ stdenv.mkDerivation rec {
};

enableParallelBuilding = true;
nativeBuildInputs = [ pkgconfig ];
buildInputs = [ tcl readline libffi python3 bison flex protobuf zlib ];
nativeBuildInputs = [ pkg-config protobuf flex bison python3 ];
buildInputs = [ tcl readline libffi python3 protobuf zlib ];

makeFlags = [ "ENABLE_PROTOBUF=1" "PREFIX=${placeholder "out"}"];

patchPhase = ''
substituteInPlace ./Makefile \
--replace 'CXX = clang' "" \
--replace 'LD = clang++' 'LD = $(CXX)' \
--replace 'CXX = gcc' "" \
--replace 'LD = gcc' 'LD = $(CXX)' \
--replace 'ABCMKARGS = CC="$(CXX)" CXX="$(CXX)"' 'ABCMKARGS =' \
--replace 'echo UNKNOWN' 'echo ${builtins.substring 0 10 src.rev}'
substituteInPlace ./misc/yosys-config.in \
--replace '/bin/bash' '${bash}/bin/bash'
chmod +x ./misc/yosys-config.in
patchShebangs ./misc/yosys-config.in
patchShebangs tests
'';

Expand All @@ -76,8 +74,8 @@ stdenv.mkDerivation rec {
exit 1
fi
if ! grep -q "YOSYS_VER := ${version}" Makefile; then
echo "ERROR: yosys version in Makefile isn't equivalent to version of the nix package (${version}), failing."
if ! grep -q "YOSYS_VER := $version" Makefile; then
echo "ERROR: yosys version in Makefile isn't equivalent to version of the nix package ($version), failing."
exit 1
fi
'';
Expand All @@ -94,7 +92,14 @@ stdenv.mkDerivation rec {
# add a symlink to fake things so that both variants work the same way. this
# is also needed at build time for the test suite.
postBuild = "ln -sfv ${abc-verifier}/bin/abc ./yosys-abc";
postInstall = "ln -sfv ${abc-verifier}/bin/abc $out/bin/yosys-abc";
postInstall = ''
ln -sfv ${abc-verifier}/bin/abc $out/bin/yosys-abc
mkdir -p $out/share/yosys/plugins
for plugin in $plugins; do
ln -sfv $plugin/share/yosys/plugins/* $out/share/yosys/plugins/
done
'';

meta = with stdenv.lib; {
description = "Open RTL synthesis framework and tools";
Expand Down

0 comments on commit d81e4d9

Please sign in to comment.