Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: added test case to check the addon building process. #808

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Introduce include_dir for use with gyp in a scalar context
Deprecate use of `include` in an gyp array context, which
happens to work when paths are absolute, but can fail on Windows
when paths are relative and a gyp file contains multiple entries
in its `include_dirs` directive.

This change corrects documentation and tooling, adds support for
relative paths (e.g. those containing whitespace) in a backwards
compatible manner and makes the approach holistically consistent
with that used by nan.
  • Loading branch information
lovell committed Jul 14, 2020
commit e9f8fc74da2e6f3f4849d5907071bcad7ca2ab78
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
}]
],
'include_dirs': ["<!@(node -p \"require('../').include\")"],
'include_dirs': ["<!(node -p \"require('../').include_dir\")"],
'cflags': [ '-Werror', '-Wall', '-Wextra', '-Wpedantic', '-Wunused-parameter' ],
'cflags_cc': [ '-Werror', '-Wall', '-Wextra', '-Wpedantic', '-Wunused-parameter' ]
}
2 changes: 1 addition & 1 deletion doc/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ To use **N-API** in a native module:
2. Reference this package's include directory and gyp file in `binding.gyp`:

```gyp
'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"],
'include_dirs': ["<!(node -p \"require('node-addon-api').include_dir\")"],
```

3. Decide whether the package will enable C++ exceptions in the N-API wrapper.
Expand Down
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const path = require('path');

const include = path.relative('.', __dirname);
const include_dir = path.relative('.', __dirname);

module.exports = {
include: include,
gyp: path.join(include, 'node_api.gyp:nothing'),
include: `"${__dirname}"`, // deprecated, can be removed as part of 4.0.0
include_dir,
gyp: path.join(include_dir, 'node_api.gyp:nothing'),
isNodeApiBuiltin: true,
needsFlag: false
};
8 changes: 4 additions & 4 deletions tools/conversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ if (disable != "--disable" && dir != "--disable") {
[ /[ ]*"nan": *"[^"]+"(,|)[\n\r]/g, '' ]
],
'binding.gyp': [
[ /([ ]*)'include_dirs': \[/g, '$1\'include_dirs\': [\n$1 \'<!@(node -p "require(\\\'node-addon-api\\\').include")\',' ],
[ /([ ]*)"include_dirs": \[/g, '$1"include_dirs": [\n$1 "<!@(node -p \\"require(\'node-addon-api\').include\\")",' ],
[ /([ ]*)'include_dirs': \[/g, '$1\'include_dirs\': [\n$1 \'<!(node -p "require(\\\'node-addon-api\\\').include_dir")\',' ],
[ /([ ]*)"include_dirs": \[/g, '$1"include_dirs": [\n$1 "<!(node -p \\"require(\'node-addon-api\').include_dir\\")",' ],
[ /[ ]*("|')<!\(node -e ("|'|\\"|\\')require\(("|'|\\"|\\')nan("|'|\\"|\\')\)("|'|\\"|\\')\)("|')(,|)[\r\n]/g, '' ],
[ /([ ]*)("|')target_name("|'): ("|')(.+?)("|'),/g, '$1$2target_name$2: $4$5$6,\n $2cflags!$2: [ $2-fno-exceptions$2 ],\n $2cflags_cc!$2: [ $2-fno-exceptions$2 ],\n $2xcode_settings$2: { $2GCC_ENABLE_CPP_EXCEPTIONS$2: $2YES$2,\n $2CLANG_CXX_LIBRARY$2: $2libc++$2,\n $2MACOSX_DEPLOYMENT_TARGET$2: $210.7$2,\n },\n $2msvs_settings$2: {\n $2VCCLCompilerTool$2: { $2ExceptionHandling$2: 1 },\n },' ],
]
Expand All @@ -35,8 +35,8 @@ if (disable != "--disable" && dir != "--disable") {
[ /[ ]*"nan": *"[^"]+"(,|)[\n\r]/g, '' ]
],
'binding.gyp': [
[ /([ ]*)'include_dirs': \[/g, '$1\'include_dirs\': [\n$1 \'<!@(node -p "require(\\\'node-addon-api\\\').include")\',' ],
[ /([ ]*)"include_dirs": \[/g, '$1"include_dirs": [\n$1 "<!@(node -p \'require(\\\"node-addon-api\\\").include\')",' ],
[ /([ ]*)'include_dirs': \[/g, '$1\'include_dirs\': [\n$1 \'<!(node -p "require(\\\'node-addon-api\\\').include_dir")\',' ],
[ /([ ]*)"include_dirs": \[/g, '$1"include_dirs": [\n$1 "<!(node -p \'require(\\\"node-addon-api\\\").include_dir\')",' ],
[ /[ ]*("|')<!\(node -e ("|'|\\"|\\')require\(("|'|\\"|\\')nan("|'|\\"|\\')\)("|'|\\"|\\')\)("|')(,|)[\r\n]/g, '' ],
[ /([ ]*)("|')target_name("|'): ("|')(.+?)("|'),/g, '$1$2target_name$2: $4$5$6,\n $2cflags!$2: [ $2-fno-exceptions$2 ],\n $2cflags_cc!$2: [ $2-fno-exceptions$2 ],\n $2defines$2: [ $2NAPI_DISABLE_CPP_EXCEPTIONS$2 ],\n $2conditions$2: [\n [\'OS==\"win\"\', { $2defines$2: [ $2_HAS_EXCEPTIONS=1$2 ] }]\n ]' ],
]
Expand Down