Skip to content

Commit

Permalink
Add current state of verilogae derivation
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonodoom committed Sep 5, 2024
1 parent f8dca5f commit 2c9383f
Showing 1 changed file with 69 additions and 18 deletions.
87 changes: 69 additions & 18 deletions pkgs/development/python-modules/verilogae/default.nix
Original file line number Diff line number Diff line change
@@ -1,37 +1,88 @@
{
buildPythonPackage,
fetchurl,
lib,
python,
fetchFromSourcehut,
stdenv,
unzip,
llvmPackages,
rustc,
patchelf,
python,
setuptools-rust,
cargo,
clang,
rustPlatform,
lib,
zlib,
ncurses,
libxml2,
pkg-config,
pkgs,
}:

buildPythonPackage rec {
pname = "verilogae";
version = "1.0.0";
version = "0.9-beta-8";

src = fetchurl {
url = "https://files.pythonhosted.org/packages/aa/a6/9daea00745844faba44c2917c66838adfc315269f38518ecca49e6eb5fb5/verilogae-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl";
hash = "sha256-QsEVq/4c44xCkovOhXOj8Zh6rp4Ipq+NGjbTW25Fd6E=";
src = fetchFromSourcehut {
owner = "~dspom";
repo = "OpenVAF";
rev = "b800153e84a8a640b07048d580fabafc25bbc841";
hash = "sha256-NKiJrXnxwghNYtKL4s3YjvQd/r3QWe5saCYp4N4aQ8w=";
};

format = "other";

unpackPhase = ''
tmp_dir=$(mktemp -d)
mkdir -p $out/${python.sitePackages}
${unzip}/bin/unzip $src -d $tmp_dir
mv $tmp_dir/* $out/${python.sitePackages}
'';
cargoDeps = rustPlatform.importCargoLock {
lockFile = "${src}/Cargo.lock";
outputHashes = {
"salsa-0.17.0-pre.2" = "sha256-6GssvV76lFr5OzAUekz2h6f82Tn7usz5E8MSZ5DmgJw=";
};
};

buildInputs = [
llvmPackages.libllvm
pkgs.libxml2
ncurses.dev
zlib
];

installCheckPhase = ''
export PYTHONPATH="$out/${python.sitePackages}:$PYTHONPATH"
nativeBuildInputs = [
cargo
clang
rustPlatform.cargoSetupHook
rustc
llvmPackages.libllvm
llvmPackages.clang
setuptools-rust
libxml2
ncurses
zlib
patchelf
pkg-config
];

configurePhase = "true";

buildPhase = ''
export CC="${llvmPackages.clang}/bin/clang"
export CXX="${llvmPackages.clang}/bin/clang++"
export CARGO_BUILD_RUSTFLAGS="-L${llvmPackages.libllvm}/lib -lLLVMCore -lLLVMCodeGen -lLLVMTarget -lLLVMAnalysis -lLLVMSupport -lLLVMInstCombine -lLLVMTransformUtils -lLLVMScalarOpts -lLLVMInstrumentation"
export LD_LIBRARY_PATH="${llvmPackages.libllvm}/lib:${pkgs.libxml2}/lib:${ncurses.dev}/lib:$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="${pkgs.libxml2}/lib/pkgconfig:${ncurses.dev}/lib/pkgconfig:$PKG_CONFIG_PATH"
cargo build --release
'';

nativeBuildInputs = [ unzip ];
installPhase = ''
mkdir -p $out/${python.sitePackages}/verilogae
cp target/release/*.so $out/${python.sitePackages}/verilogae/ || echo "Failed to find shared objects in target/release"
LD_LIBRARY_PATH = "${stdenv.cc.cc.lib}/lib/";
# Apply patchelf to fix the dynamic linker and rpath
for bin in $out/${python.sitePackages}/verilogae/*.so; do
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" --set-rpath $LD_LIBRARY_PATH $bin
done
'';

pythonImportsCheck = [ "verilogae" ];

Expand Down

0 comments on commit 2c9383f

Please sign in to comment.