2021-03-29 21:09:25 +02:00
|
|
|
TERMUX_PKG_HOMEPAGE=https://emscripten.org
|
|
|
|
TERMUX_PKG_DESCRIPTION="Emscripten: An LLVM-to-WebAssembly Compiler"
|
|
|
|
TERMUX_PKG_LICENSE="MIT"
|
|
|
|
TERMUX_PKG_MAINTAINER="@truboxl"
|
2022-03-27 14:19:53 +02:00
|
|
|
TERMUX_PKG_VERSION=3.1.8
|
2022-04-02 15:07:59 +02:00
|
|
|
TERMUX_PKG_REVISION=1
|
2021-03-29 21:09:25 +02:00
|
|
|
TERMUX_PKG_SRCURL=https://github.com/emscripten-core/emscripten.git
|
|
|
|
TERMUX_PKG_GIT_BRANCH=$TERMUX_PKG_VERSION
|
|
|
|
TERMUX_PKG_PLATFORM_INDEPENDENT=true
|
2021-11-01 21:41:44 +01:00
|
|
|
TERMUX_PKG_RECOMMENDS="emscripten-llvm, emscripten-binaryen, python, nodejs-lts | nodejs"
|
2021-03-29 21:09:25 +02:00
|
|
|
TERMUX_PKG_HOSTBUILD=true
|
|
|
|
TERMUX_PKG_NO_STATICSPLIT=true
|
|
|
|
|
2021-11-01 21:41:44 +01:00
|
|
|
# remove files according to emsdk/upstream directory after running
|
|
|
|
# ./emsdk install latest
|
|
|
|
TERMUX_PKG_RM_AFTER_INSTALL="
|
|
|
|
opt/emscripten-llvm/bin/clang-check
|
|
|
|
opt/emscripten-llvm/bin/clang-cl
|
|
|
|
opt/emscripten-llvm/bin/clang-cpp
|
|
|
|
opt/emscripten-llvm/bin/clang-extdef-mapping
|
|
|
|
opt/emscripten-llvm/bin/clang-format
|
|
|
|
opt/emscripten-llvm/bin/clang-func-mapping
|
|
|
|
opt/emscripten-llvm/bin/clang-import-test
|
2022-02-27 10:58:01 +01:00
|
|
|
opt/emscripten-llvm/bin/clang-linker-wrapper
|
2021-11-27 04:26:39 +01:00
|
|
|
opt/emscripten-llvm/bin/clang-nvlink-wrapper
|
2021-11-01 21:41:44 +01:00
|
|
|
opt/emscripten-llvm/bin/clang-offload-bundler
|
2021-11-27 04:26:39 +01:00
|
|
|
opt/emscripten-llvm/bin/clang-offload-wrapper
|
2022-02-27 10:58:01 +01:00
|
|
|
opt/emscripten-llvm/bin/clang-pseudo
|
2021-11-01 21:41:44 +01:00
|
|
|
opt/emscripten-llvm/bin/clang-refactor
|
|
|
|
opt/emscripten-llvm/bin/clang-rename
|
2022-02-27 10:58:01 +01:00
|
|
|
opt/emscripten-llvm/bin/clang-repl
|
2021-11-01 21:41:44 +01:00
|
|
|
opt/emscripten-llvm/bin/clang-scan-deps
|
2021-11-27 04:26:39 +01:00
|
|
|
opt/emscripten-llvm/bin/diagtool
|
|
|
|
opt/emscripten-llvm/bin/git-clang-format
|
|
|
|
opt/emscripten-llvm/bin/hmaptool
|
2021-11-01 21:41:44 +01:00
|
|
|
opt/emscripten-llvm/bin/ld.lld
|
|
|
|
opt/emscripten-llvm/bin/ld64.lld
|
|
|
|
opt/emscripten-llvm/bin/ld64.lld.darwin*
|
|
|
|
opt/emscripten-llvm/bin/lld-link
|
2022-02-27 10:58:01 +01:00
|
|
|
opt/emscripten-llvm/bin/llvm-cov
|
2021-11-01 21:41:44 +01:00
|
|
|
opt/emscripten-llvm/bin/llvm-lib
|
2022-02-27 10:58:01 +01:00
|
|
|
opt/emscripten-llvm/bin/llvm-ml
|
|
|
|
opt/emscripten-llvm/bin/llvm-pdbutil
|
|
|
|
opt/emscripten-llvm/bin/llvm-profdata
|
|
|
|
opt/emscripten-llvm/bin/llvm-rc
|
|
|
|
opt/emscripten-llvm/bin/llvm-strip
|
2021-11-01 21:41:44 +01:00
|
|
|
opt/emscripten-llvm/lib/libclang.so*
|
|
|
|
opt/emscripten-llvm/share
|
|
|
|
opt/emscripten/LICENSE
|
|
|
|
"
|
|
|
|
|
2021-03-29 21:09:25 +02:00
|
|
|
# https://github.com/emscripten-core/emscripten/blob/main/docs/packaging.md
|
|
|
|
# https://github.com/archlinux/svntogit-community/tree/packages/emscripten/trunk
|
|
|
|
# below generates commit hash for the deps according to emscripten releases
|
2021-08-29 09:56:03 +02:00
|
|
|
#RELEASES_TAGS=$(curl -s https://raw.githubusercontent.com/emscripten-core/emsdk/main/emscripten-releases-tags.json)
|
2021-03-29 21:09:25 +02:00
|
|
|
#RELEASE_TAG=$(echo $RELEASES_TAGS | python3 -c "import json,sys;print(json.load(sys.stdin)[\"releases\"][\"$TERMUX_PKG_VERSION\"])")
|
|
|
|
#DEPS_REVISION=$(curl -s https://chromium.googlesource.com/emscripten-releases/+/$RELEASE_TAG/DEPS?format=text | base64 -d | grep "_revision':" | sed -e "s|'|\"|g")
|
|
|
|
#DEPS_JSON=$(echo -e "{\n${DEPS_REVISION}EOL" | sed -e "s|,EOL|\n}|")
|
|
|
|
#LLVM_COMMIT=$(echo $DEPS_JSON | python3 -c "import json,sys;print(json.load(sys.stdin)[\"llvm_project_revision\"])")
|
|
|
|
#BINARYEN_COMMIT=$(echo $DEPS_JSON | python3 -c "import json,sys;print(json.load(sys.stdin)[\"binaryen_revision\"])")
|
2021-08-07 18:07:37 +02:00
|
|
|
#curl -LOC - https://github.com/llvm/llvm-project/archive/$LLVM_COMMIT.tar.gz
|
|
|
|
#curl -LOC - https://github.com/WebAssembly/binaryen/archive/$BINARYEN_COMMIT.tar.gz
|
|
|
|
#sha256sum $LLVM_COMMIT.tar.gz $BINARYEN_COMMIT.tar.gz
|
2021-03-29 21:09:25 +02:00
|
|
|
|
|
|
|
# https://github.com/emscripten-core/emscripten/issues/11362
|
|
|
|
# can switch to stable LLVM to save space once above is fixed
|
2022-03-27 14:19:53 +02:00
|
|
|
LLVM_COMMIT=80ec0ebfdc5692a58e0832125f2c6a991df9d63f
|
|
|
|
LLVM_TGZ_SHA256=adc89de66fb60133a1debb52e45e9e7d73b8ce6c0e8b02a338978437eac6407f
|
2021-03-29 21:09:25 +02:00
|
|
|
|
|
|
|
# https://github.com/emscripten-core/emscripten/issues/12252
|
|
|
|
# upstream says better bundle the right binaryen revision for now
|
2022-03-27 14:19:53 +02:00
|
|
|
BINARYEN_COMMIT=22d24fda983d471ebf73ebadbc37ef1741a5594d
|
|
|
|
BINARYEN_TGZ_SHA256=fa29ce17c16bc59f761df7f8d60155a71d8f756086b632651e3ffc2e2228195b
|
2021-03-29 21:09:25 +02:00
|
|
|
|
2021-05-05 13:45:54 +02:00
|
|
|
# https://github.com/emscripten-core/emsdk/blob/main/emsdk.py
|
|
|
|
# https://chromium.googlesource.com/emscripten-releases/+/refs/heads/main/src/build.py
|
2021-05-08 07:10:49 +02:00
|
|
|
# https://github.com/llvm/llvm-project
|
2021-03-29 21:09:25 +02:00
|
|
|
LLVM_BUILD_ARGS="
|
2021-10-08 11:13:20 +02:00
|
|
|
-DCMAKE_BUILD_TYPE=MinSizeRel
|
2021-05-08 07:10:49 +02:00
|
|
|
-DCMAKE_CROSSCOMPILING=ON
|
2021-10-08 11:13:20 +02:00
|
|
|
-DCMAKE_INSTALL_PREFIX=$TERMUX_PREFIX/opt/emscripten-llvm
|
2021-05-08 07:10:49 +02:00
|
|
|
|
|
|
|
-DDEFAULT_SYSROOT=$(dirname $TERMUX_PREFIX)
|
|
|
|
-DGENERATOR_IS_MULTI_CONFIG=ON
|
2021-10-08 11:13:20 +02:00
|
|
|
-DLLVM_ENABLE_ASSERTIONS=ON
|
2021-03-29 21:09:25 +02:00
|
|
|
-DLLVM_ENABLE_BINDINGS=OFF
|
2021-05-29 04:35:06 +02:00
|
|
|
-DLLVM_ENABLE_LIBEDIT=OFF
|
|
|
|
-DLLVM_ENABLE_LIBPFM=OFF
|
2021-05-08 07:10:49 +02:00
|
|
|
-DLLVM_ENABLE_LIBXML2=OFF
|
2022-02-26 12:53:42 +01:00
|
|
|
-DLLVM_ENABLE_PROJECTS=clang;compiler-rt;lld
|
2021-05-29 04:35:06 +02:00
|
|
|
-DLLVM_ENABLE_TERMINFO=OFF
|
2021-10-08 11:13:20 +02:00
|
|
|
-DLLVM_INCLUDE_EXAMPLES=OFF
|
|
|
|
-DLLVM_INCLUDE_TESTS=OFF
|
|
|
|
-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON
|
|
|
|
-DLLVM_LINK_LLVM_DYLIB=ON
|
2021-05-08 07:10:49 +02:00
|
|
|
-DLLVM_TABLEGEN=$TERMUX_PKG_HOSTBUILD_DIR/bin/llvm-tblgen
|
|
|
|
|
2021-11-01 21:41:44 +01:00
|
|
|
-DCLANG_DEFAULT_LINKER=lld
|
2021-03-29 21:09:25 +02:00
|
|
|
-DCLANG_ENABLE_ARCMT=OFF
|
|
|
|
-DCLANG_ENABLE_STATIC_ANALYZER=OFF
|
2021-05-08 07:10:49 +02:00
|
|
|
-DCLANG_TABLEGEN=$TERMUX_PKG_HOSTBUILD_DIR/bin/clang-tblgen
|
|
|
|
|
|
|
|
-DCOMPILER_RT_BUILD_CRT=OFF
|
|
|
|
-DCOMPILER_RT_BUILD_LIBFUZZER=OFF
|
|
|
|
-DCOMPILER_RT_BUILD_MEMPROF=OFF
|
|
|
|
-DCOMPILER_RT_BUILD_PROFILE=OFF
|
|
|
|
-DCOMPILER_RT_BUILD_SANITIZERS=OFF
|
|
|
|
-DCOMPILER_RT_BUILD_XRAY=OFF
|
|
|
|
-DCOMPILER_RT_INCLUDE_TESTS=OFF
|
2021-03-29 21:09:25 +02:00
|
|
|
"
|
|
|
|
|
|
|
|
# https://github.com/WebAssembly/binaryen/blob/main/CMakeLists.txt
|
|
|
|
BINARYEN_BUILD_ARGS="
|
2021-10-08 11:13:20 +02:00
|
|
|
-DCMAKE_INSTALL_PREFIX=$TERMUX_PREFIX/opt/emscripten-binaryen
|
2022-03-27 14:21:06 +02:00
|
|
|
-DBUILD_TESTS=OFF
|
2021-03-29 21:09:25 +02:00
|
|
|
"
|
|
|
|
|
|
|
|
termux_step_post_get_source() {
|
|
|
|
termux_download \
|
2021-08-07 18:07:37 +02:00
|
|
|
"https://github.com/llvm/llvm-project/archive/$LLVM_COMMIT.tar.gz" \
|
|
|
|
"$TERMUX_PKG_CACHEDIR/llvm.tar.gz" \
|
|
|
|
"$LLVM_TGZ_SHA256"
|
2021-03-29 21:09:25 +02:00
|
|
|
termux_download \
|
2021-08-07 18:07:37 +02:00
|
|
|
"https://github.com/WebAssembly/binaryen/archive/$BINARYEN_COMMIT.tar.gz" \
|
|
|
|
"$TERMUX_PKG_CACHEDIR/binaryen.tar.gz" \
|
|
|
|
"$BINARYEN_TGZ_SHA256"
|
|
|
|
tar -xf "$TERMUX_PKG_CACHEDIR/llvm.tar.gz" -C "$TERMUX_PKG_CACHEDIR"
|
|
|
|
tar -xf "$TERMUX_PKG_CACHEDIR/binaryen.tar.gz" -C "$TERMUX_PKG_CACHEDIR"
|
2021-10-08 11:13:20 +02:00
|
|
|
|
|
|
|
cd "$TERMUX_PKG_CACHEDIR/llvm-project-$LLVM_COMMIT"
|
2021-11-26 16:06:24 +01:00
|
|
|
for patch in $TERMUX_PKG_BUILDER_DIR/llvm-project-*.patch.diff; do
|
2021-11-01 21:41:44 +01:00
|
|
|
patch -p1 -i "$patch"
|
|
|
|
done
|
2022-02-26 12:53:42 +01:00
|
|
|
|
|
|
|
cd "$TERMUX_PKG_CACHEDIR/binaryen-$BINARYEN_COMMIT"
|
|
|
|
for patch in $TERMUX_PKG_BUILDER_DIR/binaryen-*.patch.diff; do
|
|
|
|
patch -p1 -i "$patch"
|
|
|
|
done
|
2021-03-29 21:09:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
termux_step_host_build() {
|
|
|
|
termux_setup_cmake
|
|
|
|
termux_setup_ninja
|
|
|
|
|
|
|
|
cmake \
|
|
|
|
-G Ninja \
|
2021-10-08 11:13:20 +02:00
|
|
|
-S "$TERMUX_PKG_CACHEDIR/llvm-project-$LLVM_COMMIT/llvm" \
|
|
|
|
-DLLVM_ENABLE_PROJECTS=clang
|
2021-03-29 21:09:25 +02:00
|
|
|
cmake \
|
|
|
|
--build "$TERMUX_PKG_HOSTBUILD_DIR" \
|
|
|
|
-j "$TERMUX_MAKE_PROCESSES" \
|
|
|
|
--target llvm-tblgen clang-tblgen
|
|
|
|
}
|
|
|
|
|
|
|
|
termux_step_make() {
|
|
|
|
termux_setup_cmake
|
|
|
|
termux_setup_ninja
|
|
|
|
|
|
|
|
# from packages/libllvm/build.sh
|
|
|
|
export LLVM_DEFAULT_TARGET_TRIPLE=${CCTERMUX_HOST_PLATFORM/-/-unknown-}
|
|
|
|
export LLVM_TARGET_ARCH
|
|
|
|
if [ $TERMUX_ARCH = "arm" ]; then
|
|
|
|
LLVM_TARGET_ARCH=ARM
|
|
|
|
elif [ $TERMUX_ARCH = "aarch64" ]; then
|
|
|
|
LLVM_TARGET_ARCH=AArch64
|
|
|
|
elif [ $TERMUX_ARCH = "i686" ] || [ $TERMUX_ARCH = "x86_64" ]; then
|
|
|
|
LLVM_TARGET_ARCH=X86
|
|
|
|
else
|
|
|
|
termux_error_exit "Invalid arch: $TERMUX_ARCH"
|
|
|
|
fi
|
|
|
|
|
|
|
|
LLVM_BUILD_ARGS+=" -DLLVM_TARGET_ARCH=$LLVM_TARGET_ARCH"
|
|
|
|
LLVM_BUILD_ARGS+=" -DLLVM_TARGETS_TO_BUILD=WebAssembly;$LLVM_TARGET_ARCH"
|
|
|
|
LLVM_BUILD_ARGS+=" -DLLVM_HOST_TRIPLE=$LLVM_DEFAULT_TARGET_TRIPLE"
|
|
|
|
|
|
|
|
cmake \
|
|
|
|
-G Ninja \
|
|
|
|
-S "$TERMUX_PKG_CACHEDIR/llvm-project-$LLVM_COMMIT/llvm" \
|
2022-03-27 14:27:47 +02:00
|
|
|
-B "$TERMUX_PKG_BUILDDIR/build-llvm" \
|
2021-10-08 11:13:20 +02:00
|
|
|
$LLVM_BUILD_ARGS
|
2021-03-29 21:09:25 +02:00
|
|
|
cmake \
|
2022-03-27 14:27:47 +02:00
|
|
|
--build "$TERMUX_PKG_BUILDDIR/build-llvm" \
|
2021-03-29 21:09:25 +02:00
|
|
|
-j "$TERMUX_MAKE_PROCESSES" \
|
|
|
|
--target install
|
|
|
|
|
|
|
|
cmake \
|
|
|
|
-G Ninja \
|
|
|
|
-S "$TERMUX_PKG_CACHEDIR/binaryen-$BINARYEN_COMMIT" \
|
2022-03-27 14:27:47 +02:00
|
|
|
-B "$TERMUX_PKG_BUILDDIR/build-binaryen" \
|
2021-10-08 11:13:20 +02:00
|
|
|
$BINARYEN_BUILD_ARGS
|
2021-03-29 21:09:25 +02:00
|
|
|
cmake \
|
2022-03-27 14:27:47 +02:00
|
|
|
--build "$TERMUX_PKG_BUILDDIR/build-binaryen" \
|
2021-03-29 21:09:25 +02:00
|
|
|
-j "$TERMUX_MAKE_PROCESSES" \
|
|
|
|
--target install
|
|
|
|
}
|
|
|
|
|
|
|
|
termux_step_make_install() {
|
2022-03-27 14:27:47 +02:00
|
|
|
cd "$TERMUX_PKG_SRCDIR"
|
|
|
|
|
2022-01-18 03:14:17 +01:00
|
|
|
# https://github.com/emscripten-core/emscripten/pull/15840
|
|
|
|
sed -e "s|-git||" -i "$TERMUX_PKG_SRCDIR/emscripten-version.txt"
|
|
|
|
|
2021-11-01 21:41:44 +01:00
|
|
|
# skip using Makefile which does host npm install
|
2021-10-08 11:13:20 +02:00
|
|
|
rm -fr "$TERMUX_PREFIX/opt/emscripten"
|
|
|
|
./tools/install.py "$TERMUX_PREFIX/opt/emscripten"
|
2021-03-29 21:09:25 +02:00
|
|
|
|
2021-11-01 21:41:44 +01:00
|
|
|
# subpackage optional third party test suite files
|
|
|
|
cp -fr "$TERMUX_PKG_SRCDIR/tests/third_party" "$TERMUX_PREFIX/opt/emscripten/tests/third_party"
|
|
|
|
|
2021-03-29 21:09:25 +02:00
|
|
|
# first run generates .emscripten and exits immediately
|
2021-05-05 13:45:54 +02:00
|
|
|
rm -f "$TERMUX_PKG_SRCDIR/.emscripten"
|
2022-02-27 09:03:08 +01:00
|
|
|
./emcc --generate-config
|
2021-10-08 11:13:20 +02:00
|
|
|
sed -i .emscripten -e "s|^EMSCRIPTEN_ROOT.*|EMSCRIPTEN_ROOT = '$TERMUX_PREFIX/opt/emscripten' # directory|"
|
|
|
|
sed -i .emscripten -e "s|^LLVM_ROOT.*|LLVM_ROOT = '$TERMUX_PREFIX/opt/emscripten-llvm/bin' # directory|"
|
|
|
|
sed -i .emscripten -e "s|^BINARYEN_ROOT.*|BINARYEN_ROOT = '$TERMUX_PREFIX/opt/emscripten-binaryen' # directory|"
|
2021-05-05 13:45:54 +02:00
|
|
|
sed -i .emscripten -e "s|^NODE_JS.*|NODE_JS = '$TERMUX_PREFIX/bin/node' # executable|"
|
|
|
|
grep "$TERMUX_PREFIX" "$TERMUX_PKG_SRCDIR/.emscripten"
|
2021-10-08 11:13:20 +02:00
|
|
|
install -Dm644 "$TERMUX_PKG_SRCDIR/.emscripten" "$TERMUX_PREFIX/opt/emscripten/.emscripten"
|
2021-03-29 21:09:25 +02:00
|
|
|
|
2021-11-01 21:41:44 +01:00
|
|
|
# add emscripten directory to PATH var
|
2021-03-29 21:09:25 +02:00
|
|
|
cat <<- EOF > "$TERMUX_PKG_TMPDIR/emscripten.sh"
|
|
|
|
#!$TERMUX_PREFIX/bin/sh
|
2021-10-08 11:13:20 +02:00
|
|
|
export PATH=\$PATH:$TERMUX_PREFIX/opt/emscripten
|
2021-03-29 21:09:25 +02:00
|
|
|
EOF
|
|
|
|
install -Dm644 "$TERMUX_PKG_TMPDIR/emscripten.sh" "$TERMUX_PREFIX/etc/profile.d/emscripten.sh"
|
|
|
|
|
|
|
|
# add useful tools not installed by LLVM_INSTALL_TOOLCHAIN_ONLY=ON
|
2022-02-27 10:58:01 +01:00
|
|
|
for tool in llc llvm-{addr2line,dwarfdump,dwp,link,mc,nm,objdump,ranlib,readobj,size} opt; do
|
2022-03-27 14:27:47 +02:00
|
|
|
install -Dm755 "$TERMUX_PKG_BUILDDIR/build-llvm/bin/$tool" "$TERMUX_PREFIX/opt/emscripten-llvm/bin/$tool"
|
2021-03-29 21:09:25 +02:00
|
|
|
done
|
2021-11-01 21:41:44 +01:00
|
|
|
|
2021-11-27 04:26:39 +01:00
|
|
|
# wasm32 triplets
|
|
|
|
ln -fsT "clang" "$TERMUX_PREFIX/opt/emscripten-llvm/bin/wasm32-clang"
|
|
|
|
ln -fsT "clang++" "$TERMUX_PREFIX/opt/emscripten-llvm/bin/wasm32-clang++"
|
|
|
|
ln -fsT "clang" "$TERMUX_PREFIX/opt/emscripten-llvm/bin/wasm32-wasi-clang"
|
|
|
|
ln -fsT "clang++" "$TERMUX_PREFIX/opt/emscripten-llvm/bin/wasm32-wasi-clang++"
|
2022-02-27 10:58:01 +01:00
|
|
|
ln -fsT "lld" "$TERMUX_PREFIX/opt/emscripten-llvm/bin/wasm-ld"
|
2021-11-27 04:26:39 +01:00
|
|
|
|
2021-11-01 21:41:44 +01:00
|
|
|
# unable to determine the reason why different linker searches for
|
|
|
|
# libclang_rt.builtins-*-android.a in different paths even after adding
|
|
|
|
# the patches from libllvm (also which one is more correct?)
|
|
|
|
#
|
2022-02-26 12:53:42 +01:00
|
|
|
# binutils LD searches lib/clang/15.0.0/lib/linux (exist)
|
|
|
|
# LLVM LD.LLD searches lib/clang/15.0.0/lib/android (not exist)
|
|
|
|
ln -fsT "linux" "$TERMUX_PREFIX/opt/emscripten-llvm/lib/clang/15.0.0/lib/android"
|
2021-03-29 21:09:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
termux_step_create_debscripts() {
|
2022-01-03 02:20:53 +01:00
|
|
|
# emscripten's package-lock.json is generated with nodejs v12.13.0
|
|
|
|
# which comes with npm v6 which used lockfile version 1
|
|
|
|
# which isn't compatible with lockfile version 2 used in npm v7 and v8
|
2021-03-29 21:09:25 +02:00
|
|
|
cat <<- EOF > postinst
|
2022-01-03 02:20:53 +01:00
|
|
|
#!$TERMUX_PREFIX/bin/bash
|
2021-11-01 21:41:44 +01:00
|
|
|
if [ -n "\$(command -v npm)" ]; then
|
2021-10-08 11:13:20 +02:00
|
|
|
cd "$TERMUX_PREFIX/opt/emscripten"
|
2022-01-03 02:20:53 +01:00
|
|
|
NPM_VERSION=\$(npm --version)
|
|
|
|
NPM_MAJOR_VERSION=\${NPM_VERSION:0:1}
|
|
|
|
if [ 6 = \$NPM_MAJOR_VERSION ]; then
|
|
|
|
echo 'Running "npm ci --no-optional --production" in $TERMUX_PREFIX/opt/emscripten ...'
|
2021-05-29 12:53:25 +02:00
|
|
|
npm ci --no-optional --production
|
2021-10-08 11:13:20 +02:00
|
|
|
else
|
2022-01-03 02:20:53 +01:00
|
|
|
echo 'Running "npm install --no-optional --production" in $TERMUX_PREFIX/opt/emscripten ...'
|
|
|
|
rm package-lock.json
|
|
|
|
npm install --no-optional --production
|
|
|
|
fi
|
|
|
|
else
|
2021-10-08 11:13:20 +02:00
|
|
|
echo 'Warning: npm is not installed! Emscripten may not work properly without installing node modules!' >&2
|
|
|
|
fi
|
|
|
|
echo '
|
|
|
|
====================
|
|
|
|
Post-install notice:
|
|
|
|
If this is the first time installing Emscripten,
|
|
|
|
please start a new session to take effect.
|
|
|
|
If you are upgrading, you may want to clear the
|
|
|
|
cache by running the command below to fix issues.
|
|
|
|
|
2021-11-26 16:06:24 +01:00
|
|
|
emcc --clear-cache
|
2021-11-01 21:41:44 +01:00
|
|
|
|
2021-10-08 11:13:20 +02:00
|
|
|
===================='
|
2021-03-29 21:09:25 +02:00
|
|
|
EOF
|
|
|
|
|
|
|
|
cat <<- EOF > postrm
|
|
|
|
#!$TERMUX_PREFIX/bin/sh
|
|
|
|
case "\$1" in
|
|
|
|
purge|remove)
|
2021-10-08 11:13:20 +02:00
|
|
|
rm -fr "$TERMUX_PREFIX/opt/emscripten"
|
2021-03-29 21:09:25 +02:00
|
|
|
esac
|
|
|
|
EOF
|
|
|
|
}
|
2021-11-01 21:41:44 +01:00
|
|
|
|
|
|
|
# Emscripten Test Suite (Optional)
|
|
|
|
# Some preparations need to be made in Emscripten directory before running
|
|
|
|
# test suite on Android / Termux. Refer docs below:
|
|
|
|
# https://emscripten.org/docs/getting_started/test-suite.html
|
|
|
|
# https://github.com/emscripten-core/emscripten/pull/13493
|
|
|
|
# https://github.com/emscripten-core/emscripten/issues/9098
|
|
|
|
#
|
|
|
|
# Steps:
|
2022-02-28 16:41:50 +01:00
|
|
|
# - pkg install emscripten-tests-third-party ndk-sysroot openjdk-17
|
2021-11-01 21:41:44 +01:00
|
|
|
# - cd $PREFIX/opt/emscripten
|
2022-02-26 12:53:42 +01:00
|
|
|
# - npm install --no-optional
|
2021-11-01 21:41:44 +01:00
|
|
|
# - export EMTEST_SKIP_V8=1
|
|
|
|
# - tests/runner {test_name}
|