Skip to content

Commit 13a88d1

Browse files
authored
ghcjs: copy and run tests (#494)
1 parent b921ff8 commit 13a88d1

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

builder/comp-builder.nix

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, ghcForComponent, hsPkgs, runCommand, libffi, gmp }:
1+
{ stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, ghcForComponent, hsPkgs, runCommand, libffi, gmp, nodejs }:
22

33
{ componentId
44
, component
@@ -142,7 +142,8 @@ let
142142
&& (haskellLib.isLibrary componentId)
143143
&& !haskellLib.isCrossHost;
144144

145-
exeExt = lib.optionalString stdenv.hostPlatform.isWindows ".exe";
145+
exeExt = if stdenv.hostPlatform.isGhcjs then ".jsexe/all.js" else
146+
if stdenv.hostPlatform.isWindows then ".exe" else "";
146147
exeName = componentId.cname + exeExt;
147148
testExecutable = "dist/build/${componentId.cname}/${exeName}";
148149

@@ -313,7 +314,13 @@ stdenv.mkDerivation ({
313314
${(lib.optionalString (haskellLib.isTest componentId || haskellLib.isBenchmark componentId || haskellLib.isAll componentId) ''
314315
mkdir -p $out/bin
315316
if [ -f ${testExecutable} ]; then
316-
cp ${testExecutable} $out/bin/
317+
mkdir -p $(dirname $out/bin/${exeName})
318+
${if stdenv.hostPlatform.isGhcjs then ''
319+
cat <(echo \#!${lib.getBin buildPackages.nodejs}/bin/node) ${testExecutable} >| $out/bin/${exeName}
320+
chmod +x $out/bin/${exeName}
321+
'' else ''
322+
cp -r ${testExecutable} $(dirname $out/bin/${exeName})
323+
''}
317324
fi
318325
'')
319326
# In case `setup copy` did not creat this

0 commit comments

Comments
 (0)