bluespec: Add darwin support and withDocs (#389298)

This commit is contained in:
Artturin
2025-03-14 15:45:12 +02:00
committed by GitHub
+57 -25
View File
@@ -22,6 +22,11 @@
asciidoctor,
texliveFull,
which,
# install -m 644 lib/libstp.dylib /private/tmp/nix-build-bluespec-2024.07.drv-5/source/inst/lib/SAT
# install: cannot stat 'lib/libstp.dylib': No such file or directory
# https://github.com/B-Lang-org/bsc/pull/600 might fix it
stubStp ? !stdenv.hostPlatform.isDarwin,
withDocs ? true,
}:
let
@@ -54,10 +59,13 @@ stdenv.mkDerivation rec {
enableParallelBuilding = true;
outputs = [
"out"
"doc"
];
outputs =
[
"out"
]
++ lib.optionals withDocs [
"doc"
];
# https://github.com/B-Lang-org/bsc/pull/278 is still applicable, but will probably not be applied as such
# there is work ongoing: https://github.com/B-Lang-org/bsc/issues/595 https://github.com/B-Lang-org/bsc/pull/600
@@ -70,14 +78,19 @@ stdenv.mkDerivation rec {
preBuild = ''
patchShebangs \
src/vendor/stp/src/AST/genkinds.pl \
src/Verilog/copy_module.pl \
src/comp/update-build-version.sh \
src/comp/update-build-system.sh \
src/comp/wrapper.sh
substituteInPlace src/comp/Makefile \
--replace 'BINDDIR' 'BINDIR' \
--replace 'install-bsc install-bluetcl' 'install-bsc install-bluetcl $(UTILEXES) install-utils'
--replace-fail 'install-bsc install-bluetcl' 'install-bsc install-bluetcl $(UTILEXES) install-utils'
# For darwin
# ld: library not found for -ltcl8.5
substituteInPlace ./platform.sh \
--replace-fail 'TCLSH=/usr/bin/tclsh' 'TCLSH=`which tclsh`'
# allow running bsc to bootstrap
export LD_LIBRARY_PATH=$PWD/inst/lib/SAT
@@ -107,15 +120,26 @@ stdenv.mkDerivation rec {
perl
pkg-config
texliveFull
tcl
];
makeFlags = [
"release"
"NO_DEPS_CHECKS=1" # skip the subrepo check (this deriviation uses yices-src instead of the subrepo)
"NOGIT=1" # https://github.com/B-Lang-org/bsc/issues/12
"LDCONFIG=ldconfig" # https://github.com/B-Lang-org/bsc/pull/43
"STP_STUB=1" # uses yices as a SMT solver and stub out STP
];
env.NIX_CFLAGS_COMPILE = toString (
lib.optionals (stdenv.cc.isClang) [
# wide_data.cxx:1750:15: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
"-Wno-error"
]
);
makeFlags =
[
"NO_DEPS_CHECKS=1" # skip the subrepo check (this deriviation uses yices-src instead of the subrepo)
"NOGIT=1" # https://github.com/B-Lang-org/bsc/issues/12
"LDCONFIG=ldconfig" # https://github.com/SRI-CSL/yices2/blob/fda0a325ea7923f152ea9f9a5d20eddfd1d96224/Makefile.build#L66
(if withDocs then "release" else "install-src")
]
++ lib.optionals stubStp [
"STP_STUB=1" # uses yices as a SMT solver and stub out STP
];
doCheck = true;
@@ -124,25 +148,33 @@ stdenv.mkDerivation rec {
iverilog
];
checkTarget = "check-smoke"; # this is the shortest check but "check-suite" tests much more
# /nix/store/7y0vlsf6l8lr3vjsbrirqrsbx4mwqiwf-cctools-binutils-darwin-1010.6/bin/strip: error: unknown argument '-u'
# make[1]: *** [Makefile:97: smoke_test_bluesim] Error 1
checkTarget = lib.optionalString (!stdenv.hostPlatform.isDarwin) "check-smoke"; # this is the shortest check but "check-suite" tests much more
installPhase = ''
mkdir -p $out
mv inst/bin $out
mv inst/lib $out
installPhase =
''
mkdir -p $out
mv inst/bin $out
mv inst/lib $out
# fragile, I know..
mkdir -p $doc/share/doc/bsc
mv inst/README $doc/share/doc/bsc
mv inst/ReleaseNotes.* $doc/share/doc/bsc
mv inst/doc/*.pdf $doc/share/doc/bsc
'';
''
+ lib.optionalString withDocs ''
# fragile, I know..
mkdir -p $doc/share/doc/bsc
mv inst/README $doc/share/doc/bsc
mv inst/ReleaseNotes.* $doc/share/doc/bsc
mv inst/doc/*.pdf $doc/share/doc/bsc
'';
meta = {
description = "Toolchain for the Bluespec Hardware Definition Language";
homepage = "https://github.com/B-Lang-org/bsc";
license = lib.licenses.bsd3;
platforms = [ "x86_64-linux" ];
platforms = [
"x86_64-linux"
"aarch64-darwin"
];
mainProgram = "bsc";
# darwin fails at https://github.com/B-Lang-org/bsc/pull/35#issuecomment-583731562
# aarch64 fails, as GHC fails with "ghc: could not execute: opt"