зеркало из https://github.com/microsoft/vcpkg.git
[node-api-headers] add usage (#31186)
* [node-api-headers] add usage * port-ver * . * . * Update usage * Update node-api-headers.json
This commit is contained in:
Родитель
daeaf2c209
Коммит
7c4f51feb0
|
@ -16,4 +16,6 @@ file(INSTALL "${SOURCE_PATH}/include" DESTINATION "${CURRENT_PACKAGES_DIR}/inclu
|
|||
|
||||
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
|
||||
|
||||
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
|
||||
|
||||
configure_file("${CMAKE_CURRENT_LIST_DIR}/unofficial-${PORT}-config.cmake.in" "${CURRENT_PACKAGES_DIR}/share/unofficial-${PORT}/unofficial-${PORT}-config.cmake" @ONLY)
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
node-api-headers provides CMake targets:
|
||||
|
||||
find_package(unofficial-node-api-headers CONFIG REQUIRED)
|
||||
target_link_libraries(main PRIVATE unofficial::node-api-headers::node-api-headers)
|
||||
|
||||
Add this to your CMakeLists.txt to build a Node.js addon:
|
||||
add_library(addon SHARED main.cpp ...)
|
||||
set_target_properties(addon PROPERTIES OUTPUT_NAME "my-addon" PREFIX "" SUFFIX ".node")
|
||||
|
||||
find_package(unofficial-node-api-headers CONFIG REQUIRED)
|
||||
target_link_libraries(addon PRIVATE unofficial::node-api-headers::node-api-headers)
|
||||
|
||||
You will be able to load your addon in JavaScript code:
|
||||
const addon = require("/path/to/addon/my-addon.node");
|
||||
|
||||
Make sure that your Node.js OS/architecture matches vcpkg triplet you use.
|
||||
|
||||
Also, make sure to register a module in your C/C++ code like official example does:
|
||||
https://github.com/nodejs/node-addon-examples/blob/main/1_hello_world/napi/hello.c
|
||||
|
||||
This port doesn't have specific functionality for publishing npm packages.
|
||||
|
||||
See https://nodejs.org/api/n-api.html
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"name": "node-api-headers",
|
||||
"version": "1.0.0",
|
||||
"port-version": 1,
|
||||
"description": "NodeJS API for writing modules in C++",
|
||||
"homepage": "https://nodejs.org/api/addons.html",
|
||||
"license": "MIT",
|
||||
|
|
|
@ -5594,7 +5594,7 @@
|
|||
},
|
||||
"node-api-headers": {
|
||||
"baseline": "1.0.0",
|
||||
"port-version": 0
|
||||
"port-version": 1
|
||||
},
|
||||
"nonius": {
|
||||
"baseline": "2019-04-20",
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
{
|
||||
"versions": [
|
||||
{
|
||||
"git-tree": "273191974015356594e8288781f46c01fd882d43",
|
||||
"version": "1.0.0",
|
||||
"port-version": 1
|
||||
},
|
||||
{
|
||||
"git-tree": "a38314df5ed9495e8e15abc596a5cd75e0116824",
|
||||
"version": "1.0.0",
|
||||
|
|
Загрузка…
Ссылка в новой задаче