Skip to content

Commit 9af69da

Browse files
author
Gabriel Schulhof
committed
remove N-API implementation, v6.x and v8.x support
Remove the followings: * the files associated with the external implementation of N-API * Travis CI jobs for v8.x and v6.x * documentation instructing users to add the external N-API implementation to their dependencies. * conversion tool code that adds the external N-API implementation as a dependency to the user's addon. This move is possible because of v8.x EOL, which means that all supported versions of Node.js now have an internal implementation of N-API. Fixes: #463 Fixes: #509 Fixes: #640 PR-URL: #643 Reviewed-By: Nicola Del Gobbo <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
1 parent 920d544 commit 9af69da

18 files changed

+15
-4779
lines changed

.travis.yml

-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ env:
1212
# https://github.com/jasongin/nvs/blob/master/doc/CI.md
1313
- NVS_VERSION=1.4.2
1414
matrix:
15-
- NODEJS_VERSION=node/6
16-
- NODEJS_VERSION=node/8
1715
- NODEJS_VERSION=node/10
1816
- NODEJS_VERSION=node/12
1917
- NODEJS_VERSION=node/13
@@ -22,7 +20,6 @@ matrix:
2220
fast_finish: true
2321
allow_failures:
2422
- env: NODEJS_VERSION=nightly
25-
- env: NODEJS_VERSION=node/6
2623
sudo: false
2724
cache:
2825
directories:

common.gypi

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
],
1919
'defines': ['NODE_MAJOR_VERSION=<@(NODE_MAJOR_VERSION)'],
2020
'include_dirs': ["<!@(node -p \"require('../').include\")"],
21-
'dependencies': ["<!(node -p \"require('../').gyp\")"],
2221
'cflags': [ '-Werror', '-Wall', '-Wextra', '-Wpedantic', '-Wunused-parameter' ],
2322
'cflags_cc': [ '-Werror', '-Wall', '-Wextra', '-Wpedantic', '-Wunused-parameter' ]
2423
}

doc/setup.md

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ To use **N-API** in a native module:
2727

2828
```gyp
2929
'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"],
30-
'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"],
3130
```
3231

3332
3. Decide whether the package will enable C++ exceptions in the N-API wrapper.

external-napi/node_api.h

-7
This file was deleted.

index.js

+5-42
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,8 @@
1-
var path = require('path');
2-
3-
var versionArray = process.version
4-
.substr(1)
5-
.replace(/-.*$/, '')
6-
.split('.')
7-
.map(function(item) {
8-
return +item;
9-
});
10-
11-
// TODO: Check if the main node semantic version is within multiple ranges,
12-
// or detect presence of built-in N-API by some other mechanism TBD.
13-
14-
// We know which version of Node.js first shipped the incarnation of the API
15-
// available in *this* package. So, if we find that the Node.js version is below
16-
// that, we indicate that the API is missing from Node.js.
17-
var isNodeApiBuiltin = (
18-
versionArray[0] > 8 ||
19-
(versionArray[0] == 8 && versionArray[1] >= 6) ||
20-
(versionArray[0] == 6 && versionArray[1] >= 15) ||
21-
(versionArray[0] == 6 && versionArray[1] >= 14 && versionArray[2] >= 2));
22-
23-
// The flag is not needed when the Node version is not 8, nor if the API is
24-
// built-in, because we removed the flag at the same time as creating the final
25-
// incarnation of the built-in API.
26-
var needsFlag = (!isNodeApiBuiltin && versionArray[0] == 8);
27-
28-
var include = [__dirname];
29-
var gyp = path.join(__dirname, 'src', 'node_api.gyp');
30-
31-
if (isNodeApiBuiltin) {
32-
gyp += ':nothing';
33-
} else {
34-
gyp += ':node-api';
35-
include.unshift(path.join(__dirname, 'external-napi'));
36-
}
1+
const path = require('path');
372

383
module.exports = {
39-
include: include.map(function(item) {
40-
return '"' + item + '"';
41-
}).join(' '),
42-
gyp: gyp,
43-
isNodeApiBuiltin: isNodeApiBuiltin,
44-
needsFlag: needsFlag
4+
include: `"${__dirname}"`,
5+
gyp: path.join(__dirname, 'nothing.gyp:nothing'),
6+
isNodeApiBuiltin: true,
7+
needsFlag: false
458
};

node_api.gyp

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
'targets': [
3+
{
4+
'target_name': 'nothing',
5+
'type': 'static_library',
6+
'sources': [ 'nothing.c' ]
7+
}
8+
]
9+
}

src/nothing.c renamed to nothing.c

File renamed without changes.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@
211211
"safe-buffer": "^5.1.1"
212212
},
213213
"directories": {},
214+
"gypfile": false,
214215
"homepage": "https://github.com/nodejs/node-addon-api",
215216
"keywords": [
216217
"n-api",

src/.gitignore

-4
This file was deleted.

0 commit comments

Comments
 (0)