File tree 6 files changed +44
-2
lines changed
6 files changed +44
-2
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
@@ -1147,6 +1148,10 @@ def configure_node(o):
1147
1148
else :
1148
1149
o ['variables' ]['node_target_type' ] = 'executable'
1149
1150
1151
+ def configure_napi (output ):
1152
+ version = getnapibuildversion .get_napi_version ()
1153
+ output ['variables' ]['napi_build_version' ] = version
1154
+
1150
1155
def configure_library (lib , output ):
1151
1156
shared_lib = 'shared_' + lib
1152
1157
output ['variables' ]['node_' + shared_lib ] = b (getattr (options , shared_lib ))
@@ -1626,6 +1631,7 @@ def make_bin_override():
1626
1631
flavor = GetFlavor (flavor_params )
1627
1632
1628
1633
configure_node (output )
1634
+ configure_napi (output )
1629
1635
configure_library ('zlib' , output )
1630
1636
configure_library ('http_parser' , output )
1631
1637
configure_library ('libuv' , output )
Original file line number Diff line number Diff line change @@ -662,6 +662,7 @@ An example of the possible output looks like:
662
662
variables:
663
663
{
664
664
host_arch: ' x64' ,
665
+ napi_build_version: 4 ,
665
666
node_install_npm: ' true' ,
666
667
node_prefix: ' ' ,
667
668
node_shared_cares: ' false' ,
Original file line number Diff line number Diff line change 12
12
#ifdef NAPI_EXPERIMENTAL
13
13
#define NAPI_VERSION NAPI_VERSION_EXPERIMENTAL
14
14
#else
15
- // The baseline version for N-API
15
+ // The baseline version for N-API.
16
+ // The NAPI_VERSION controls which version will be used by default when
17
+ // compilling a native addon. If the addon developer specifically wants to use
18
+ // functions available in a new version of N-API that is not yet ported in all
19
+ // LTS versions, they can set NAPI_VERSION knowing that they have specifically
20
+ // depended on that version.
16
21
#define NAPI_VERSION 4
17
22
#endif
18
23
#endif
Original file line number Diff line number Diff line change 91
91
*/
92
92
#define NODE_MODULE_VERSION 72
93
93
94
- // the NAPI_VERSION provided by this version of the runtime
94
+ // The NAPI_VERSION provided by this version of the runtime. This is the version
95
+ // which the Node binary being built supports.
95
96
#define NAPI_VERSION 4
96
97
97
98
#endif // SRC_NODE_VERSION_H_
Original file line number Diff line number Diff line change @@ -45,3 +45,6 @@ for (let i = 0; i < expected_keys.length; i++) {
45
45
const descriptor = Object . getOwnPropertyDescriptor ( process . versions , key ) ;
46
46
assert . strictEqual ( descriptor . writable , false ) ;
47
47
}
48
+
49
+ assert . strictEqual ( process . config . variables . napi_build_version ,
50
+ 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