Skip to content

Commit 4e4c091

Browse files
stefanmbjasnell
authored andcommitted
build: windows sharedlib support
Original Commit Message: Added "dll" option to vcbuild.bat Insure that Unix SO name is not used on Windows (i.e. produce a .dll file) Insure that Node and its V8 dependency link against the Visual C++ Runtime dynamically. Requires backported V8 patch, see PR 7802. Ref: #7802 PR-URL: #7487 Reviewed-By: Alexis Campailla <[email protected]> Reviewed-By: Michael Dawson <[email protected]> PR-URL: #8084 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 4118598 commit 4e4c091

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

common.gypi

+29-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
'python%': 'python',
1313

1414
'node_shared%': 'false',
15+
'force_dynamic_crt%': 0,
1516
'node_use_v8_platform%': 'true',
1617
'node_use_bundled_v8%': 'true',
1718
'node_module_version%': '',
@@ -78,11 +79,24 @@
7879
['OS == "android"', {
7980
'cflags': [ '-fPIE' ],
8081
'ldflags': [ '-fPIE', '-pie' ]
82+
}],
83+
['node_shared=="true"', {
84+
'msvs_settings': {
85+
'VCCLCompilerTool': {
86+
'RuntimeLibrary': 3, # MultiThreadedDebugDLL (/MDd)
87+
}
88+
}
89+
}],
90+
['node_shared=="false"', {
91+
'msvs_settings': {
92+
'VCCLCompilerTool': {
93+
'RuntimeLibrary': 1 # MultiThreadedDebug (/MTd)
94+
}
95+
}
8196
}]
8297
],
8398
'msvs_settings': {
8499
'VCCLCompilerTool': {
85-
'RuntimeLibrary': 1, # static debug
86100
'Optimization': 0, # /Od, no optimization
87101
'MinimalRebuild': 'false',
88102
'OmitFramePointers': 'false',
@@ -115,11 +129,24 @@
115129
['OS == "android"', {
116130
'cflags': [ '-fPIE' ],
117131
'ldflags': [ '-fPIE', '-pie' ]
132+
}],
133+
['node_shared=="true"', {
134+
'msvs_settings': {
135+
'VCCLCompilerTool': {
136+
'RuntimeLibrary': 2 # MultiThreadedDLL (/MD)
137+
}
138+
}
139+
}],
140+
['node_shared=="false"', {
141+
'msvs_settings': {
142+
'VCCLCompilerTool': {
143+
'RuntimeLibrary': 0 # MultiThreaded (/MT)
144+
}
145+
}
118146
}]
119147
],
120148
'msvs_settings': {
121149
'VCCLCompilerTool': {
122-
'RuntimeLibrary': 0, # static release
123150
'Optimization': 3, # /Ox, full optimization
124151
'FavorSizeOrSpeed': 1, # /Ot, favour speed over size
125152
'InlineFunctionExpansion': 2, # /Ob2, inline anything eligible

configure

+1
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,7 @@ def configure_v8(o):
893893
o['variables']['v8_use_snapshot'] = 'false' if options.without_snapshot else 'true'
894894
o['variables']['node_use_v8_platform'] = b(not options.without_v8_platform)
895895
o['variables']['node_use_bundled_v8'] = b(not options.without_bundled_v8)
896+
o['variables']['force_dynamic_crt'] = 1 if options.shared else 0
896897
o['variables']['node_enable_d8'] = b(options.enable_d8)
897898
if options.enable_d8:
898899
o['variables']['test_isolation_mode'] = 'noop' # Needed by d8.gyp.

node.gyp

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
'node_use_v8_platform%': 'true',
1010
'node_use_bundled_v8%': 'true',
1111
'node_shared%': 'false',
12+
'force_dynamic_crt%': 0,
1213
'node_module_version%': '',
1314
'node_shared_zlib%': 'false',
1415
'node_shared_http_parser%': 'false',
@@ -247,7 +248,7 @@
247248
'NODE_SHARED_MODE',
248249
],
249250
'conditions': [
250-
[ 'node_module_version!=""', {
251+
[ 'node_module_version!="" and OS!="win"', {
251252
'product_extension': '<(shlib_suffix)',
252253
}]
253254
],

vcbuild.bat

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ set build_release=
3838
set enable_vtune_arg=
3939
set configure_flags=
4040
set build_addons=
41+
set dll=
4142

4243
:next-arg
4344
if "%1"=="" goto args-done
@@ -79,6 +80,7 @@ if /i "%1"=="without-intl" set i18n_arg=%1&goto arg-ok
7980
if /i "%1"=="download-all" set download_arg="--download=all"&goto arg-ok
8081
if /i "%1"=="ignore-flaky" set test_args=%test_args% --flaky-tests=dontcare&goto arg-ok
8182
if /i "%1"=="enable-vtune" set enable_vtune_arg=1&goto arg-ok
83+
if /i "%1"=="dll" set dll=1&goto arg-ok
8284

8385
echo Warning: ignoring invalid command line option `%1`.
8486

@@ -108,6 +110,7 @@ if defined noperfctr set configure_flags=%configure_flags% --without-perfctr& se
108110
if defined release_urlbase set release_urlbase_arg=--release-urlbase=%release_urlbase%
109111
if defined download_arg set configure_flags=%configure_flags% %download_arg%
110112
if defined enable_vtune_arg set configure_flags=%configure_flags% --enable-vtune-profiling
113+
if defined dll set configure_flags=%configure_flags% --shared
111114

112115
if "%i18n_arg%"=="full-icu" set configure_flags=%configure_flags% --with-intl=full-icu
113116
if "%i18n_arg%"=="small-icu" set configure_flags=%configure_flags% --with-intl=small-icu

0 commit comments

Comments
 (0)