nixpkgs/pkgs/development/compilers/yosys/default.nix

84 lines
2.4 KiB
Nix
Raw Normal View History

2020-01-07 15:06:23 +00:00
{ stdenv
2020-02-01 11:11:30 +00:00
, abc-verifier
, bash
2020-01-07 15:06:23 +00:00
, bison
, fetchFromGitHub
, flex
, libffi
, pkgconfig
, protobuf
, python3
, readline
, tcl
2019-09-27 15:06:42 +01:00
, verilog
2020-01-07 15:06:23 +00:00
, zlib
}:
2015-12-29 16:31:18 +00:00
2020-02-01 11:11:30 +00:00
stdenv.mkDerivation rec {
pname = "yosys";
version = "2020.06.11";
2015-12-29 16:31:18 +00:00
src = fetchFromGitHub {
2020-02-08 15:29:50 +00:00
owner = "YosysHQ";
repo = "yosys";
rev = "a1785e988b2b51dac32985dd6b0afdcedc6bda1d";
sha256 = "0987f5vm2zb0i02c3vlw21gihky2cfj5l9b78ddzhxfiv0qfkdfp";
};
2015-12-29 16:31:18 +00:00
enableParallelBuilding = true;
nativeBuildInputs = [ pkgconfig ];
2019-08-14 00:46:42 +01:00
buildInputs = [ tcl readline libffi python3 bison flex protobuf zlib ];
2020-01-07 15:06:23 +00:00
makeFlags = [ "ENABLE_PROTOBUF=1" "PREFIX=${placeholder "out"}"];
patchPhase = ''
substituteInPlace ./Makefile \
2018-04-11 21:08:51 +01:00
--replace 'CXX = clang' "" \
2019-08-20 10:43:58 +01:00
--replace 'LD = clang++' 'LD = $(CXX)' \
--replace 'CXX = gcc' "" \
--replace 'LD = gcc' 'LD = $(CXX)' \
--replace 'ABCMKARGS = CC="$(CXX)" CXX="$(CXX)"' 'ABCMKARGS =' \
2020-02-01 11:11:30 +00:00
--replace 'echo UNKNOWN' 'echo ${builtins.substring 0 10 src.rev}'
substituteInPlace ./misc/yosys-config.in \
--replace '/bin/bash' '${bash}/bin/bash'
2019-09-27 15:06:42 +01:00
patchShebangs tests
'';
preBuild = let
shortAbcRev = builtins.substring 0 7 abc-verifier.rev;
in ''
chmod -R u+w .
2018-04-11 21:08:51 +01:00
make config-${if stdenv.cc.isClang or false then "clang" else "gcc"}
2020-02-01 11:11:30 +00:00
echo 'ABCEXTERNAL = ${abc-verifier}/bin/abc' >> Makefile.conf
# we have to do this ourselves for some reason...
(cd misc && ${protobuf}/bin/protoc --cpp_out ../backends/protobuf/ ./yosys.proto)
if ! grep -q "ABCREV = ${shortAbcRev}" Makefile; then
echo "yosys isn't compatible with the provided abc (${shortAbcRev}), failing."
exit 1
fi
2015-12-29 16:31:18 +00:00
'';
2019-09-27 15:06:42 +01:00
doCheck = true;
checkInputs = [ verilog ];
# Internally, yosys knows to use the specified hardcoded ABCEXTERNAL binary.
# But other tools (like mcy or symbiyosys) can't know how yosys was built, so
# they just assume that 'yosys-abc' is available -- but it's not installed
# when using ABCEXTERNAL
#
# add a symlink to fake things so that both variants work the same way.
postInstall = ''
ln -sfv ${abc-verifier}/bin/abc $out/bin/yosys-abc
'';
meta = with stdenv.lib; {
description = "Open RTL synthesis framework and tools";
homepage = "http://www.clifford.at/yosys/";
license = licenses.isc;
platforms = platforms.all;
maintainers = with maintainers; [ shell thoughtpolice emily ];
2015-12-29 16:31:18 +00:00
};
}