From 0138b4db7c44c11a2ca01157222cf5744de99473 Mon Sep 17 00:00:00 2001 From: Stewart Addison Date: Wed, 16 Nov 2016 14:34:51 +0000 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/7802 PR-URL: https://github.com/nodejs/node/pull/7487 Reviewed-By: Alexis Campailla Reviewed-By: Michael Dawson PR-URL: https://github.com/nodejs/node/pull/9385 Reviewed-By: Ben Noordhuis Reviewed-By: Michael Dawson Reviewed-By: Myles Borins --- common.gypi | 29 ++++++++++++++++++++++++++++- node.gyp | 2 +- vcbuild.bat | 3 +++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/common.gypi b/common.gypi index f26b66e6483c58..55440bc8fde917 100644 --- a/common.gypi +++ b/common.gypi @@ -79,6 +79,20 @@ ['OS == "android"', { 'cflags': [ '-fPIE' ], 'ldflags': [ '-fPIE', '-pie' ] + }], + ['node_shared=="true"', { + 'msvs_settings': { + 'VCCLCompilerTool': { + 'RuntimeLibrary': 3 # MultiThreadedDebugDLL (/MDd) + } + } + }], + ['node_shared=="false"', { + 'msvs_settings': { + 'VCCLCompilerTool': { + 'RuntimeLibrary': 1 # MultiThreadedDebug (/MTd) + } + } }] ], 'msvs_settings': { @@ -116,11 +130,24 @@ ['OS == "android"', { 'cflags': [ '-fPIE' ], 'ldflags': [ '-fPIE', '-pie' ] + }], + ['node_shared=="true"', { + 'msvs_settings': { + 'VCCLCompilerTool': { + 'RuntimeLibrary': 2 # MultiThreadedDLL (/MD) + } + } + }], + ['node_shared=="false"', { + 'msvs_settings': { + 'VCCLCompilerTool': { + 'RuntimeLibrary': 0 # MultiThreaded (/MT) + } + } }] ], 'msvs_settings': { 'VCCLCompilerTool': { - 'RuntimeLibrary': 0, # static release 'Optimization': 3, # /Ox, full optimization 'FavorSizeOrSpeed': 1, # /Ot, favour speed over size 'InlineFunctionExpansion': 2, # /Ob2, inline anything eligible diff --git a/node.gyp b/node.gyp index 7f2afb5f25f072..ea7b17135192f3 100644 --- a/node.gyp +++ b/node.gyp @@ -242,7 +242,7 @@ 'NODE_SHARED_MODE', ], 'conditions': [ - [ 'node_module_version!=""', { + [ 'node_module_version!="" and OS!="win"', { 'product_extension': 'so.<(node_module_version)', }] ], diff --git a/vcbuild.bat b/vcbuild.bat index 77c0d01a14f486..a052504b61b639 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -37,6 +37,7 @@ set build_release= set configure_flags= set build_addons= set enable_vtune_profiling= +set dll= :next-arg if "%1"=="" goto args-done @@ -76,6 +77,7 @@ if /i "%1"=="intl-none" set i18n_arg=%1&goto arg-ok if /i "%1"=="download-all" set download_arg="--download=all"&goto arg-ok if /i "%1"=="ignore-flaky" set test_args=%test_args% --flaky-tests=dontcare&goto arg-ok if /i "%1"=="enable-vtune" set enable_vtune_profiling="--enable-vtune-profiling"&goto arg-ok +if /i "%1"=="dll" set dll=1&goto arg-ok echo Error: invalid command line option `%1`. exit /b 1 @@ -105,6 +107,7 @@ if defined noetw set configure_flags=%configure_flags% --without-etw& set noetw_ if defined noperfctr set configure_flags=%configure_flags% --without-perfctr& set noperfctr_msi_arg=/p:NoPerfCtr=1 if defined release_urlbase set configure_flags=%configure_flags% --release-urlbase=%release_urlbase% if defined download_arg set configure_flags=%configure_flags% %download_arg% +if defined dll set configure_flags=%configure_flags% --shared if "%i18n_arg%"=="full-icu" set configure_flags=%configure_flags% --with-intl=full-icu if "%i18n_arg%"=="small-icu" set configure_flags=%configure_flags% --with-intl=small-icu