Skip to content

Commit

Permalink
breaking change: change include directory structure
Browse files Browse the repository at this point in the history
  • Loading branch information
toyobayashi committed Jan 24, 2024
1 parent 9c99d45 commit 373a561
Show file tree
Hide file tree
Showing 18 changed files with 19 additions and 30 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
/test/CMakefiles
node_modules
!example/node_modules
/include/node_api_full.h
package-lock.json
/example/build
out
Expand Down
2 changes: 1 addition & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"includePath": [
"${default}",
// "${env:USERPROFILE}/AppData/Local/node-gyp/Cache/16.15.0/include/node"
"${workspaceFolder}/packages/emnapi/include",
"${workspaceFolder}/packages/emnapi/include/node",
"${workspaceFolder}/node_modules/node-addon-api"
],
"defines": ["NAPI_DISABLE_CPP_EXCEPTIONS", "NODE_ADDON_API_ENABLE_MAYBE"],
Expand Down
18 changes: 9 additions & 9 deletions packages/emnapi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ set(EMNAPI_THREADS_SRC
)
set(EMNAPI_SRC ${ENAPI_BASIC_SRC} ${EMNAPI_THREADS_SRC})

set(EMNAPI_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/include")
set(EMNAPI_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/include/node")
set(EMNAPI_DEFINES "BUILDING_NODE_EXTENSION")

set(EMNAPI_JS_LIB "${CMAKE_CURRENT_SOURCE_DIR}/dist/library_napi.js")
Expand Down Expand Up @@ -214,18 +214,18 @@ install(FILES
DESTINATION ".")

install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/include/emnapi_common.h
${CMAKE_CURRENT_SOURCE_DIR}/include/emnapi.h
${CMAKE_CURRENT_SOURCE_DIR}/include/js_native_api_types.h
${CMAKE_CURRENT_SOURCE_DIR}/include/js_native_api.h
${CMAKE_CURRENT_SOURCE_DIR}/include/node_api_types.h
${CMAKE_CURRENT_SOURCE_DIR}/include/node_api.h
${CMAKE_CURRENT_SOURCE_DIR}/include/uv.h
${CMAKE_CURRENT_SOURCE_DIR}/include/node/emnapi_common.h
${CMAKE_CURRENT_SOURCE_DIR}/include/node/emnapi.h
${CMAKE_CURRENT_SOURCE_DIR}/include/node/js_native_api_types.h
${CMAKE_CURRENT_SOURCE_DIR}/include/node/js_native_api.h
${CMAKE_CURRENT_SOURCE_DIR}/include/node/node_api_types.h
${CMAKE_CURRENT_SOURCE_DIR}/include/node/node_api.h
${CMAKE_CURRENT_SOURCE_DIR}/include/node/uv.h
${CMAKE_CURRENT_SOURCE_DIR}/include/node/config.gypi
DESTINATION "include/node")

install(DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/include/uv
${CMAKE_CURRENT_SOURCE_DIR}/include/node/uv
DESTINATION "include/node")

install(FILES
Expand Down
12 changes: 6 additions & 6 deletions packages/emnapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ module.exports = (function (exports) {
emcc -O3 \
-DBUILDING_NODE_EXTENSION \
"-DNAPI_EXTERN=__attribute__((__import_module__(\"env\")))" \
-I./node_modules/emnapi/include \
-I./node_modules/emnapi/include/node \
-L./node_modules/emnapi/lib/wasm32-emscripten \
--js-library=./node_modules/emnapi/dist/library_napi.js \
-sEXPORTED_FUNCTIONS="['_malloc','_free','_napi_register_wasm_v1','_node_api_module_get_api_version_v1']" \
Expand All @@ -184,7 +184,7 @@ emcc -O3 \
```bash
clang -O3 \
-DBUILDING_NODE_EXTENSION \
-I./node_modules/emnapi/include \
-I./node_modules/emnapi/include/node \
-L./node_modules/emnapi/lib/wasm32-wasi \
--target=wasm32-wasi \
--sysroot=$WASI_SDK_PATH/share/wasi-sysroot \
Expand Down Expand Up @@ -212,7 +212,7 @@ Choose `libdlmalloc.a` or `libemmalloc.a` for `malloc` and `free`.
```bash
clang -O3 \
-DBUILDING_NODE_EXTENSION \
-I./node_modules/emnapi/include \
-I./node_modules/emnapi/include/node \
-L./node_modules/emnapi/lib/wasm32 \
--target=wasm32 \
-nostdlib \
Expand Down Expand Up @@ -456,7 +456,7 @@ em++ -O3 \
"-DNAPI_EXTERN=__attribute__((__import_module__(\"env\")))" \
-DNAPI_DISABLE_CPP_EXCEPTIONS \
-DNODE_ADDON_API_ENABLE_MAYBE \
-I./node_modules/emnapi/include \
-I./node_modules/emnapi/include/node \
-I./node_modules/node-addon-api \
-L./node_modules/emnapi/lib/wasm32-emscripten \
--js-library=./node_modules/emnapi/dist/library_napi.js \
Expand All @@ -476,7 +476,7 @@ clang++ -O3 \
-DBUILDING_NODE_EXTENSION \
-DNAPI_DISABLE_CPP_EXCEPTIONS \
-DNODE_ADDON_API_ENABLE_MAYBE \
-I./node_modules/emnapi/include \
-I./node_modules/emnapi/include/node \
-I./node_modules/node-addon-api \
-L./node_modules/emnapi/lib/wasm32-wasi \
--target=wasm32-wasi \
Expand Down Expand Up @@ -508,7 +508,7 @@ You can still use `wasm32-unknown-unknown` target if you use Node-API C API only
```bash
clang++ -O3 \
-DBUILDING_NODE_EXTENSION \
-I./node_modules/emnapi/include \
-I./node_modules/emnapi/include/node \
-L./node_modules/emnapi/lib/wasm32 \
--target=wasm32 \
-fno-exceptions \
Expand Down
4 changes: 0 additions & 4 deletions packages/emnapi/common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@
}
},

'include_dirs+': [
'include',
],

'conditions': [
['OS == "emscripten"', {
'defines': [
Expand Down
6 changes: 0 additions & 6 deletions packages/emnapi/emnapi.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@
'src/async_cleanup_hook.c',
'src/async_context.c',
],
'direct_dependent_settings': {
'include_dirs+': [ 'include' ],
},
'link_settings': {
'target_conditions': [
['_type == "executable" and OS == "emscripten"', {
Expand Down Expand Up @@ -93,9 +90,6 @@
'src/async_work.c',
'src/threadsafe_function.c',
],
'direct_dependent_settings': {
'include_dirs+': [ 'include' ],
},
'link_settings': {
'target_conditions': [
['_type == "executable" and OS == "emscripten"', {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/emnapi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Object.defineProperty(exports, '__esModule', { value: true })

const path = require('path')

const include = path.join(__dirname, 'include')
const include = path.join(__dirname, 'include/node')
const includeDir = path.relative(process.cwd(), include)
const jsLibrary = path.join(__dirname, './dist/library_napi.js').replace(/\\|\\\\/g, '/')
const sources = [
Expand Down
2 changes: 1 addition & 1 deletion packages/emnapi/script/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const path = require('path')

async function main () {
const [major, minor, patch] = JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json'), 'utf8')).version.split('.').map(Number)
const headerPath = path.join(__dirname, '../include/emnapi.h')
const headerPath = path.join(__dirname, '../include/node/emnapi.h')
const emnapiHeader = fs.readFileSync(headerPath, 'utf8')
fs.writeFileSync(
headerPath,
Expand Down
2 changes: 1 addition & 1 deletion packages/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ endif()
math(EXPR PTHREAD_POOL_SIZE "${UV_THREADPOOL_SIZE} * 4")

if(IS_WASM)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../emnapi/include")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../emnapi/include/node")
else()
include_directories(${CMAKE_JS_INC})
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../node_modules/node-addon-api")
Expand Down

0 comments on commit 373a561

Please # to comment.