Last active
April 18, 2017 13:56
-
-
Save gabrielschulhof/2aa53679e517ad9985052d71b7f4c11e 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": "hello", | |
"sources": [ "hello.cc" ], | |
"conditions": [ | |
[ "'<!(node -p \"require('node-api').isNodeApiBuiltin\")'=='false'", { | |
"include_dirs+": ["<!(node -p \"require('node-api').include\")"], | |
"conditions": [ | |
[ "OS=='win'", { | |
"libraries+": [ "<(PRODUCT_DIR)/node-api.lib" ] | |
} ] | |
] | |
} ] | |
], | |
"dependencies": [ | |
"<!(node -p \"require('node-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 some_function(napi_env env, napi_callback_info info) { | |
napi_value return_value = 0; | |
napi_create_number(env, 42, &return_value); | |
return return_value; | |
} | |
void Init(napi_env env, napi_value exports, napi_value module, void *nothing) { | |
napi_value the_function = 0; | |
napi_create_function(env, "some_function", some_function, 0, &the_function); | |
napi_set_named_property(env, module, "exports", the_function); | |
} | |
NAPI_MODULE(hello, 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
{ | |
"name": "hello", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"bindings": "^1.2.1", | |
"node-api": "github:gabrielschulhof/node-api#backcompat2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output on Windows (among others):