Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emscriptenStdenv: create writable cache directory #172207

Merged
merged 2 commits into from
May 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions pkgs/development/em-modules/generic/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, lib, emscripten, python2 }:
{ pkgs, lib, emscripten, python3 }:

{ buildInputs ? [], nativeBuildInputs ? []

Expand All @@ -12,8 +12,8 @@ pkgs.stdenv.mkDerivation (

pname = "emscripten-${lib.getName args}";
version = lib.getVersion args;
buildInputs = [ emscripten python2 ] ++ buildInputs;
nativeBuildInputs = [ emscripten python2 ] ++ nativeBuildInputs;
buildInputs = [ emscripten python3 ] ++ buildInputs;
nativeBuildInputs = [ emscripten python3 ] ++ nativeBuildInputs;

# fake conftest results with emscripten's python magic
EMCONFIGURE_JS=2;
Expand All @@ -25,13 +25,17 @@ pkgs.stdenv.mkDerivation (

emconfigure ./configure --prefix=$out

mkdir -p .emscriptencache
export EM_CACHE=$(pwd)/.emscriptencache

runHook postConfigure
'';

buildPhase = args.buildPhase or ''
runHook preBuild

HOME=$TMPDIR

emmake make

runHook postBuild
Expand Down
18 changes: 7 additions & 11 deletions pkgs/top-level/emscripten-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ rec {
propagatedBuildInputs = [ zlib ];
configurePhase = ''
HOME=$TMPDIR
mkdir -p .emscriptencache
export EM_CACHE=$(pwd)/.emscriptencache
emcmake cmake . $cmakeFlags -DCMAKE_INSTALL_PREFIX=$out -DCMAKE_INSTALL_INCLUDEDIR=$dev/include
'';
checkPhase = ''
Expand Down Expand Up @@ -54,6 +56,8 @@ rec {
autoreconfPhase = "echo autoreconfPhase not used...";
configurePhase = ''
HOME=$TMPDIR
mkdir -p .emscriptencache
export EM_CACHE=$(pwd)/.emscriptencache
emconfigure ./configure --prefix=$out --without-python
'';
checkPhase = ''
Expand Down Expand Up @@ -102,6 +106,8 @@ rec {
sed -e "s/\$(JSONC_LDFLAGS) \$(ZLIB_LDFLAGS) \$(LIBXML20_LDFLAGS)/\$(JSONC_LDFLAGS) \$(LIBXML20_LDFLAGS) \$(ZLIB_LDFLAGS) /g" -i Makefile.emEnv
# https://gitlab.com/odfplugfest/xmlmirror/issues/11
sed -e "s/-o fastXmlLint.js/-s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]' -o fastXmlLint.js/g" -i Makefile.emEnv
mkdir -p .emscriptencache
export EM_CACHE=$(pwd)/.emscriptencache
'';

buildPhase = ''
Expand Down Expand Up @@ -137,16 +143,6 @@ rec {
buildInputs = old.buildInputs ++ [ pkg-config ];
# we need to reset this setting!
NIX_CFLAGS_COMPILE="";
configurePhase = ''
# FIXME: Some tests require writing at $HOME
HOME=$TMPDIR
runHook preConfigure

#export EMCC_DEBUG=2
emconfigure ./configure --prefix=$out --shared

runHook postConfigure
'';
dontStrip = true;
outputs = [ "out" ];
buildPhase = ''
Expand All @@ -161,7 +157,7 @@ rec {
echo "Compiling a custom test"
set -x
emcc -O2 -s EMULATE_FUNCTION_POINTER_CASTS=1 test/example.c -DZ_SOLO \
-L. libz.so.${old.version} -I . -o example.js
-L. libz.a -I . -o example.js

echo "Using node to execute the test"
${pkgs.nodejs}/bin/node ./example.js
Expand Down