File tree 5 files changed +42
-1
lines changed
5 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 34
34
# imports in tools/
35
35
sys .path .insert (0 , 'tools' )
36
36
import getmoduleversion
37
+ import getnapibuildversion
37
38
from gyp_node import run_gyp
38
39
39
40
# imports in deps/v8/tools/node
@@ -1131,6 +1132,10 @@ def configure_node(o):
1131
1132
else :
1132
1133
o ['variables' ]['node_target_type' ] = 'executable'
1133
1134
1135
+ def configure_napi (output ):
1136
+ version = getnapibuildversion .get_napi_version ()
1137
+ output ['variables' ]['napi_build_version' ] = version
1138
+
1134
1139
def configure_library (lib , output ):
1135
1140
shared_lib = 'shared_' + lib
1136
1141
output ['variables' ]['node_' + shared_lib ] = b (getattr (options , shared_lib ))
@@ -1603,6 +1608,7 @@ def make_bin_override():
1603
1608
flavor = GetFlavor (flavor_params )
1604
1609
1605
1610
configure_node (output )
1611
+ configure_napi (output )
1606
1612
configure_library ('zlib' , output )
1607
1613
configure_library ('http_parser' , output )
1608
1614
configure_library ('libuv' , output )
Original file line number Diff line number Diff line change @@ -661,6 +661,7 @@ An example of the possible output looks like:
661
661
variables:
662
662
{
663
663
host_arch: ' x64' ,
664
+ napi_build_version: 4 ,
664
665
node_install_npm: ' true' ,
665
666
node_prefix: ' ' ,
666
667
node_shared_cares: ' false' ,
Original file line number Diff line number Diff line change 9
9
// Use INT_MAX, this should only be consumed by the pre-processor anyway.
10
10
#define NAPI_VERSION 2147483647
11
11
#else
12
- // The baseline version for N-API
12
+ // The baseline version for N-API.
13
+ // The NAPI_VERSION controls which version will be used by default when
14
+ // compilling a native addon. If the addon developer specifically wants to use
15
+ // functions available in a new version of N-API that is not yet ported in all
16
+ // LTS versions, they can set NAPI_VERSION knowing that they have specifically
17
+ // depended on that version.
13
18
#define NAPI_VERSION 6
14
19
#endif
15
20
#endif
Original file line number Diff line number Diff line change @@ -43,3 +43,6 @@ for (let i = 0; i < expected_keys.length; i++) {
43
43
const descriptor = Object . getOwnPropertyDescriptor ( process . versions , key ) ;
44
44
assert . strictEqual ( descriptor . writable , false ) ;
45
45
}
46
+
47
+ assert . strictEqual ( process . config . variables . napi_build_version ,
48
+ process . versions . napi ) ;
Original file line number Diff line number Diff line change
1
+ from __future__ import print_function
2
+ import os
3
+ import re
4
+
5
+
6
+ def get_napi_version ():
7
+ napi_version_h = os .path .join (
8
+ os .path .dirname (__file__ ),
9
+ '..' ,
10
+ 'src' ,
11
+ 'node_version.h' )
12
+
13
+ f = open (napi_version_h )
14
+
15
+ regex = '^#define NAPI_VERSION'
16
+
17
+ for line in f :
18
+ if re .match (regex , line ):
19
+ napi_version = line .split ()[2 ]
20
+ return napi_version
21
+
22
+ raise Exception ('Could not find pattern matching %s' % regex )
23
+
24
+
25
+ if __name__ == '__main__' :
26
+ print (get_napi_version ())
You can’t perform that action at this time.
0 commit comments