Skip to content

Commit f420c5f

Browse files
committed
[nix] fix vcs data write error
Signed-off-by: unlsycn <[email protected]>
1 parent a578a38 commit f420c5f

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

templates/chisel/nix/gcd/vcs.nix

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212

1313
let
1414
binName = "gcd-vcs-simulator";
15+
vcsWrapper = out: ''
16+
# We need to carefully handle string escape here, so don't use makeWrapper
17+
tee $out/bin/${binName} <<EOF
18+
#!${bash}/bin/bash
19+
export LD_LIBRARY_PATH="$out/lib/${binName}.daidir:\$LD_LIBRARY_PATH"
20+
_argv="\$@"
21+
${vcs-fhs-env}/bin/vcs-fhs-env -c "$out/lib/${binName} \$_argv"
22+
EOF
23+
chmod +x $out/bin/${binName}
24+
'';
1525
in
1626
stdenv.mkDerivation (finalAttr: {
1727
name = "vcs";
@@ -58,9 +68,15 @@ stdenv.mkDerivation (finalAttr: {
5868
inherit rtl;
5969

6070
tests.simple-sim = runCommand "${binName}-test" { __noChroot = true; } ''
71+
mkdir -p $out/bin
72+
cp -r ${finalAttr.finalPackage}/lib $out/lib
73+
74+
${vcsWrapper "$out"}
75+
6176
# Combine stderr and stdout and redirect them to tee
6277
# So that we can have log saving to output and also printing to stdout
63-
${finalAttr.finalPackage}/bin/${binName} &> >(tee $out)
78+
ls -l $out/lib
79+
$out/bin/${binName} &> >(tee $out/result.log)
6480
'';
6581
};
6682

@@ -76,14 +92,7 @@ stdenv.mkDerivation (finalAttr: {
7692
cp ${binName} $out/lib
7793
cp -r ${binName}.daidir $out/lib
7894
79-
# We need to carefully handle string escape here, so don't use makeWrapper
80-
tee $out/bin/${binName} <<EOF
81-
#!${bash}/bin/bash
82-
export LD_LIBRARY_PATH="$out/lib/${binName}.daidir:\$LD_LIBRARY_PATH"
83-
_argv="\$@"
84-
${vcs-fhs-env}/bin/vcs-fhs-env -c "$out/lib/${binName} \$_argv"
85-
EOF
86-
chmod +x $out/bin/${binName}
95+
${vcsWrapper "$out"}
8796
8897
runHook postInstall
8998
'';

0 commit comments

Comments
 (0)