-
-
Save NickNaso/20f3c9f2c0cbde16edc19c0dc68d9f0e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"targets": [ | |
{ | |
"target_name": "example_addon", | |
"sources": [ "example_addon.c" ], | |
"include_dirs": [ "<!@(node -p \"require('node-addon-api').include\")" ], | |
"dependencies": [ "<!@(node -p \"require('node-addon-api').gyp\")" ] | |
} | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <node_api.h> | |
napi_value Init(napi_env env, napi_value exports) { | |
napi_status status; | |
napi_value value; | |
status = napi_create_uint32(env, 42, &value); | |
if (status != napi_ok) { | |
napi_fatal_error("Init", NAPI_AUTO_LENGTH, "Failed to create number", | |
NAPI_AUTO_LENGTH); | |
} | |
status = napi_set_named_property(env, exports, "answer", value); | |
if (status != napi_ok) { | |
napi_fatal_error("Init", NAPI_AUTO_LENGTH, "Failed to assign property", | |
NAPI_AUTO_LENGTH); | |
} | |
return exports; | |
} | |
NAPI_MODULE(NODE_GYP_MODULE_NAME, Init) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = require('./build/Release/example_addon.node'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "example", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"install": "node-gyp rebuild" | |
}, | |
"author": "", | |
"license": "Apache-2.0", | |
"gypfile": true, | |
"dependencies": { | |
"node-addon-api": "^1.2.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment