Skip to content

Commit

Permalink
[nix] fix vcs data write error
Browse files Browse the repository at this point in the history
Signed-off-by: unlsycn <[email protected]>
  • Loading branch information
unlsycn committed Sep 10, 2024
1 parent a578a38 commit f420c5f
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions templates/chisel/nix/gcd/vcs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@

let
binName = "gcd-vcs-simulator";
vcsWrapper = out: ''
# We need to carefully handle string escape here, so don't use makeWrapper
tee $out/bin/${binName} <<EOF
#!${bash}/bin/bash
export LD_LIBRARY_PATH="$out/lib/${binName}.daidir:\$LD_LIBRARY_PATH"
_argv="\$@"
${vcs-fhs-env}/bin/vcs-fhs-env -c "$out/lib/${binName} \$_argv"
EOF
chmod +x $out/bin/${binName}
'';
in
stdenv.mkDerivation (finalAttr: {
name = "vcs";
Expand Down Expand Up @@ -58,9 +68,15 @@ stdenv.mkDerivation (finalAttr: {
inherit rtl;

tests.simple-sim = runCommand "${binName}-test" { __noChroot = true; } ''
mkdir -p $out/bin
cp -r ${finalAttr.finalPackage}/lib $out/lib
${vcsWrapper "$out"}
# Combine stderr and stdout and redirect them to tee
# So that we can have log saving to output and also printing to stdout
${finalAttr.finalPackage}/bin/${binName} &> >(tee $out)
ls -l $out/lib
$out/bin/${binName} &> >(tee $out/result.log)
'';
};

Expand All @@ -76,14 +92,7 @@ stdenv.mkDerivation (finalAttr: {
cp ${binName} $out/lib
cp -r ${binName}.daidir $out/lib
# We need to carefully handle string escape here, so don't use makeWrapper
tee $out/bin/${binName} <<EOF
#!${bash}/bin/bash
export LD_LIBRARY_PATH="$out/lib/${binName}.daidir:\$LD_LIBRARY_PATH"
_argv="\$@"
${vcs-fhs-env}/bin/vcs-fhs-env -c "$out/lib/${binName} \$_argv"
EOF
chmod +x $out/bin/${binName}
${vcsWrapper "$out"}
runHook postInstall
'';
Expand Down

0 comments on commit f420c5f

Please sign in to comment.