Skip to content

Commit

Permalink
feat: add basic gyp support (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
toyobayashi authored Jan 29, 2024
1 parent 507ca1a commit d9ac1b5
Show file tree
Hide file tree
Showing 20 changed files with 791 additions and 196 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
38 changes: 22 additions & 16 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 @@ -209,35 +209,41 @@ if(LIB_ARCH)
endif()

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
DESTINATION "include/${PROJECT_NAME}")
${CMAKE_CURRENT_SOURCE_DIR}/common.gypi
${CMAKE_CURRENT_SOURCE_DIR}/emnapi.gyp
DESTINATION ".")

install(FILES
${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
DESTINATION "include/${PROJECT_NAME}")
${CMAKE_CURRENT_SOURCE_DIR}/include/node/uv
DESTINATION "include/node")

install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/dist/library_napi.js
DESTINATION "lib/${PROJECT_NAME}")
DESTINATION "dist")

if(EMNAPI_INSTALL_SRC)
install(FILES
${EMNAPI_SRC}
"${CMAKE_CURRENT_SOURCE_DIR}/src/emnapi_internal.h"
DESTINATION "src/${PROJECT_NAME}")
DESTINATION "src")
install(DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/src/uv
DESTINATION "src/${PROJECT_NAME}")
DESTINATION "src")
install(DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/src/malloc
DESTINATION "src/${PROJECT_NAME}")
DESTINATION "src")
install(DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/src/thread
DESTINATION "src/${PROJECT_NAME}")
DESTINATION "src")
endif()
Loading

0 comments on commit d9ac1b5

Please sign in to comment.