Skip to content

Commit

Permalink
test auto detect flavor
Browse files Browse the repository at this point in the history
  • Loading branch information
toyobayashi committed Apr 1, 2024
1 parent d7f4b87 commit de11e0b
Show file tree
Hide file tree
Showing 9 changed files with 260 additions and 33 deletions.
2 changes: 1 addition & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
]
},
],
["OS in ' unknown'", {
["OS in ' wasm unknown'", {
'conditions': [
['emnapi_manual_linking != 0', {
'dependencies': [
Expand Down
2 changes: 1 addition & 1 deletion build-wasi.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set AR_target=%WASI_SDK_PATH%/bin/ar.exe
set CC_target=%WASI_SDK_PATH%/bin/clang.exe
set CXX_target=%WASI_SDK_PATH%/bin/clang++.exe

call npx.cmd node-gyp rebuild -C %~dp0 --verbose --arch=wasm32 --nodedir=%~dp0node_modules/emnapi -- -f make-linux -Demnapi_manual_linking=1 %*
call npx.cmd node-gyp rebuild -C %~dp0 --verbose --arch=wasm32 --nodedir=%~dp0node_modules/emnapi -- -f make -Demnapi_manual_linking=1 %*

@REM call npx.cmd node-gyp clean -C %~dp0
@REM call npx.cmd node-gyp configure -C %~dp0 --arch=wasm32 --nodedir=%~dp0node_modules/emnapi -- -f make %*
Expand Down
2 changes: 1 addition & 1 deletion build-wasi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export AR_target="$WASI_SDK_PATH/bin/ar"
export CC_target="$WASI_SDK_PATH/bin/clang"
export CXX_target="$WASI_SDK_PATH/bin/clang++"

npx node-gyp rebuild -C $__dirname --verbose --arch=wasm32 --nodedir=$__dirname/node_modules/emnapi -- -f make-linux -Demnapi_manual_linking=1 "$@"
npx node-gyp rebuild -C $__dirname --verbose --arch=wasm32 --nodedir=$__dirname/node_modules/emnapi -- -f make -Demnapi_manual_linking=1 "$@"

# node-gyp clean -C $__dirname
# node-gyp configure -C $__dirname --nodedir=$__dirname/node_modules/emnapi -- -f make -DOS=wasi -Dwasm_threads=1
Expand Down
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set AR_target=emar.bat
set CC_target=emcc.bat
set CXX_target=em++.bat

call emmake.bat npx node-gyp rebuild -C %~dp0 --verbose --arch=wasm32 --nodedir=%~dp0node_modules/emnapi -- -f make-linux -Demnapi_manual_linking=1 %*
call emmake.bat npx node-gyp rebuild -C %~dp0 --verbose --arch=wasm32 --nodedir=%~dp0node_modules/emnapi -- -f make -Demnapi_manual_linking=1 %*

@REM call npx.cmd node-gyp clean -C %~dp0
@REM call npx.cmd node-gyp configure -C %~dp0 --arch=wasm32 --nodedir=%~dp0node_modules/emnapi -- -f make %*
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export AR_target=emar
export CC_target=emcc
export CXX_target=em++

emmake node-gyp rebuild -C $__dirname --verbose --arch=wasm32 --nodedir=$__dirname/node_modules/emnapi -- -f make-linux -Demnapi_manual_linking=1 "$@"
emmake node-gyp rebuild -C $__dirname --verbose --arch=wasm32 --nodedir=$__dirname/node_modules/emnapi -- -f make -Demnapi_manual_linking=1 "$@"

# node-gyp clean -C $__dirname
# node-gyp configure -C $__dirname --nodedir=$__dirname/node_modules/emnapi -- -f make -DOS=emscripten
Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
"main": "index.js",
"scripts": {
"postinstall": "node ./scripts/patch.js",
"build-emscripten:win": "build.bat -DOS=emscripten",
"build-emscripten-threads:win": "build.bat -DOS=emscripten -Dwasm_threads=1",
"build-wasi:win": "build-wasi.bat -DOS=wasi",
"build-wasi-threads:win": "build-wasi.bat -DOS=wasi -Dwasm_threads=1",
"build-wasm32:win": "build-wasi.bat -DOS=unknown",
"build-wasm32-threads:win": "build-wasi.bat -DOS=unknown -Dwasm_threads=1",
"build-emscripten:unix": "./build.sh -DOS=emscripten",
"build-emscripten-threads:unix": "./build.sh -DOS=emscripten -Dwasm_threads=1",
"build-wasi:unix": "./build-wasi.sh -DOS=wasi",
"build-wasi-threads:unix": "./build-wasi.sh -DOS=wasi -Dwasm_threads=1",
"build-wasm32:unix": "./build-wasi.sh -DOS=unknown",
"build-wasm32-threads:unix": "./build-wasi.sh -DOS=unknown -Dwasm_threads=1",
"build-emscripten:win": "build.bat",
"build-emscripten-threads:win": "build.bat -Dwasm_threads=1",
"build-wasi:win": "build-wasi.bat",
"build-wasi-threads:win": "build-wasi.bat -Dwasm_threads=1",
"build-wasm32:win": "CFLAGS=--target=wasm32 build-wasi.bat",
"build-wasm32-threads:win": "CFLAGS=--target=wasm32 build-wasi.bat -Dwasm_threads=1",
"build-emscripten:unix": "./build.sh",
"build-emscripten-threads:unix": "./build.sh -Dwasm_threads=1",
"build-wasi:unix": "./build-wasi.sh",
"build-wasi-threads:unix": "./build-wasi.sh -Dwasm_threads=1",
"build-wasm32:unix": "CFLAGS=--target=wasm32 ./build-wasi.sh",
"build-wasm32-threads:unix": "CFLAGS=--target=wasm32 ./build-wasi.sh -Dwasm_threads=1",
"start": "node ./main.js"
},
"dependencies": {
Expand Down
63 changes: 63 additions & 0 deletions patches/emnapi.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
From 84a6937329072249595f5b77ce92b0406577877b Mon Sep 17 00:00:00 2001
From: toyobayashi <[email protected]>
Date: Mon, 1 Apr 2024 18:13:44 +0800
Subject: [PATCH] feat: add OS `wasm` alias

---
packages/emnapi/common.gypi | 8 ++++----
packages/emnapi/emnapi.gyp | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/packages/emnapi/common.gypi b/packages/emnapi/common.gypi
index 26909569..058f9e43 100644
--- a/packages/emnapi/common.gypi
+++ b/packages/emnapi/common.gypi
@@ -2,7 +2,7 @@
# in https://github.com/lovell/sharp/pull/3522
{
'variables': {
- # OS: 'emscripten' | 'wasi' | 'unknown'
+ # OS: 'emscripten' | 'wasi' | 'unknown' | 'wasm'
'clang': 1,
'target_arch%': 'wasm32',
'wasm_threads%': 0,
@@ -139,7 +139,7 @@
}],
],
}],
- ['OS in "wasi unknown "', {
+ ['OS in "wasi wasm unknown "', {
'configurations': {
'Release': {
'ldflags': [ '-Wl,--strip-debug' ],
@@ -239,7 +239,7 @@
'target_conditions': [
['_type=="executable"', {
'conditions': [
- ['OS in "wasi unknown "', {
+ ['OS in "wasi wasm unknown "', {
'product_extension': 'wasm',

'ldflags': [
@@ -326,7 +326,7 @@
}]
],
}],
- ['OS in "wasi unknown "', {
+ ['OS in "wasi wasm unknown "', {
'product_extension': 'wasm',

'ldflags': [
diff --git a/packages/emnapi/emnapi.gyp b/packages/emnapi/emnapi.gyp
index edb81c1c..53089fed 100644
--- a/packages/emnapi/emnapi.gyp
+++ b/packages/emnapi/emnapi.gyp
@@ -63,7 +63,7 @@
]
},
'conditions': [
- ['wasm_threads != 0 and OS in " unknown wasi"', {
+ ['wasm_threads != 0 and OS in " unknown wasm wasi"', {
'sources': [
'src/thread/async_worker_create.c',
'src/thread/async_worker_init.S',
Loading

0 comments on commit de11e0b

Please sign in to comment.