From 6b911cce6e4ea566abeec3d3fae09d8c8c8acfe6 Mon Sep 17 00:00:00 2001 From: Mohamed Gaber Date: Tue, 20 Aug 2024 15:50:35 +0300 Subject: [PATCH] Nix Cleanup + Stricter ETV --- Sources/Fault/Entries/atpg.swift | 8 ++++++-- default.nix | 20 ++++++++++++++------ docs/Source/installation.md | 4 ++-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Sources/Fault/Entries/atpg.swift b/Sources/Fault/Entries/atpg.swift index 51bc6e2..31f7782 100644 --- a/Sources/Fault/Entries/atpg.swift +++ b/Sources/Fault/Entries/atpg.swift @@ -155,8 +155,12 @@ extension Fault { print("Read \(etvSetVectors.count) externally-generated vectors to verify.") } - if let tvGenerator = etvGen, ETVGFactory.validNames.contains(tvGenerator) { - let etvgen = ETVGFactory.get(name: tvGenerator)! + if let tvGenerator = etvGen { + guard let etvgen = ETVGFactory.get(name: tvGenerator) else { + Stderr.print("Unknown external test vector generator '\(tvGenerator)'.") + Foundation.exit(EX_USAGE) + } + let benchUnwrapped = bench! // Program exits if etvGen.value isn't nil and bench.value is or vice versa if !fileManager.fileExists(atPath: benchUnwrapped) { diff --git a/default.nix b/default.nix index 1f0997a..c3d21f2 100644 --- a/default.nix +++ b/default.nix @@ -58,12 +58,6 @@ stdenv.mkDerivation (finalAttrs: { ]; configurePhase = generated.configure; - - installPhase = '' - binPath="$(swiftpmBinPath)" - mkdir -p $out/bin - cp $binPath/fault $out/bin/fault - ''; # This doesn't work on Linux otherwise and I don't know why. preBuild = if stdenv.isDarwin then "" else '' @@ -81,17 +75,31 @@ stdenv.mkDerivation (finalAttrs: { ''; checkPhase = '' + runHook preCheck ${finalAttrs.faultEnv} PYTEST_FAULT_BIN="$(swiftpmBinPath)/fault" pytest + runHook postCheck + ''; + + installPhase = '' + runHook preInstall + binPath="$(swiftpmBinPath)" + mkdir -p $out/bin + cp $binPath/fault $out/bin/fault + ln -s ${nl2bench}/bin/nl2bench $out/bin/nl2bench + runHook postInstall ''; fixupPhase = '' + runHook preFixup wrapProgram $out/bin/fault\ --prefix PYTHONPATH : ${pyenv}/${pyenv.sitePackages}\ --prefix PATH : ${verilog}/bin\ + --prefix PATH : ${quaigh}/bin\ --prefix PATH : ${yosys}/bin\ --set PYTHON_LIBRARY ${pyenv}/lib/lib${pyenv.libPrefix}${swiftPackages.stdenv.hostPlatform.extensions.sharedLibrary}\ --set FAULT_IVL_BASE ${verilog}/lib/ivl + runHook postFixup ''; meta = with lib; { diff --git a/docs/Source/installation.md b/docs/Source/installation.md index 532aab0..1c3fba1 100644 --- a/docs/Source/installation.md +++ b/docs/Source/installation.md @@ -14,8 +14,8 @@ and system configuration. To install Nix, follow OpenLane 2's Nix installation guide at https://openlane2.readthedocs.io/en/stable/getting_started/common/nix_installation/index.html. -Afterwards, running Fault is simply `nix run github:AUCOHL/Fault`. To make -the `fault` command available in path, you can +Afterwards, to make the `fault` command (and the requisite `nl2bench` tool for +using alternative ATPGs) available in PATH, you can simply invoke `nix profile install github:AUCOHL/Fault`. ## Docker