Skip to content

Commit 97b2186

Browse files
bzoztargos
authored andcommitted
win, build: generate .sln only when necessary
When generating sln, store flags passed to configure. Next time, if node.sln exists and configure flags match those stored, skip building .sln files. Adds projgen vcbuild option to force .sln regeneration. PR-URL: #21284 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent d1b750d commit 97b2186

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

vcbuild.bat

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ set target=Build
1717
set target_arch=x64
1818
set target_env=
1919
set noprojgen=
20+
set projgen=
2021
set nobuild=
2122
set sign=
2223
set nosnapshot=
@@ -67,6 +68,7 @@ if /i "%1"=="x86" set target_arch=x86&goto arg-ok
6768
if /i "%1"=="x64" set target_arch=x64&goto arg-ok
6869
if /i "%1"=="vs2017" set target_env=vs2017&goto arg-ok
6970
if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok
71+
if /i "%1"=="projgen" set projgen=1&goto arg-ok
7072
if /i "%1"=="nobuild" set nobuild=1&goto arg-ok
7173
if /i "%1"=="nosign" set "sign="&echo Note: vcbuild no longer signs by default. "nosign" is redundant.&goto arg-ok
7274
if /i "%1"=="sign" set sign=1&goto arg-ok
@@ -147,6 +149,7 @@ if defined build_release (
147149
set licensertf=1
148150
set download_arg="--download=all"
149151
set i18n_arg=small-icu
152+
set projgen=1
150153
)
151154

152155
:: assign path to node_exe
@@ -252,16 +255,36 @@ goto build-doc
252255

253256
:msbuild-found
254257

258+
set project_generated=
255259
:project-gen
256260
@rem Skip project generation if requested.
257261
if defined noprojgen goto msbuild
258-
262+
if defined projgen goto run-configure
263+
if not exist node.sln goto run-configure
264+
if not exist .gyp_configure_stamp goto run-configure
265+
echo %configure_flags% > .tmp_gyp_configure_stamp
266+
where /R . /T *.gyp? >> .tmp_gyp_configure_stamp
267+
fc .gyp_configure_stamp .tmp_gyp_configure_stamp >NUL 2>&1
268+
if errorlevel 1 goto run-configure
269+
270+
:skip-configure
271+
del .tmp_gyp_configure_stamp
272+
echo Reusing solution generated with %configure_flags%
273+
goto msbuild
274+
275+
:run-configure
276+
del .tmp_gyp_configure_stamp
277+
del .gyp_configure_stamp
259278
@rem Generate the VS project.
260279
echo configure %configure_flags%
280+
echo %configure_flags%> .used_configure_flags
261281
python configure %configure_flags%
262282
if errorlevel 1 goto create-msvs-files-failed
263283
if not exist node.sln goto create-msvs-files-failed
284+
set project_generated=1
264285
echo Project files generated.
286+
echo %configure_flags% > .gyp_configure_stamp
287+
where /R . /T *.gyp? >> .gyp_configure_stamp
265288

266289
:msbuild
267290
@rem Skip build if requested.
@@ -274,7 +297,10 @@ set "msbplatform=Win32"
274297
if "%target_arch%"=="x64" set "msbplatform=x64"
275298
if "%target%"=="Build" if defined no_cctest set target=node
276299
msbuild node.sln %msbcpu% /t:%target% /p:Configuration=%config% /p:Platform=%msbplatform% /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
277-
if errorlevel 1 goto exit
300+
if errorlevel 1 (
301+
if not defined project_generated echo Building Node with reused solution failed. To regenerate project files use "vcbuild projgen"
302+
goto exit
303+
)
278304
if "%target%" == "Clean" goto exit
279305

280306
:sign
@@ -626,10 +652,11 @@ goto exit
626652

627653
:create-msvs-files-failed
628654
echo Failed to create vc project files.
655+
del .used_configure_flags
629656
goto exit
630657

631658
:help
632-
echo vcbuild.bat [debug/release] [msi] [doc] [test/test-ci/test-all/test-addons/test-addons-napi/test-internet/test-pummel/test-simple/test-message/test-gc/test-tick-processor/test-known-issues/test-node-inspect/test-check-deopts/test-npm/test-async-hooks/test-v8/test-v8-intl/test-v8-benchmarks/test-v8-all] [ignore-flaky] [static/dll] [noprojgen] [small-icu/full-icu/without-intl] [nobuild] [nosnapshot] [noetw] [noperfctr] [licensetf] [sign] [ia32/x86/x64] [vs2017] [download-all] [enable-vtune] [lint/lint-ci/lint-js/lint-js-ci/lint-md] [lint-md-build] [package] [build-release] [upload] [no-NODE-OPTIONS] [link-module path-to-module] [debug-http2] [debug-nghttp2] [clean] [no-cctest] [openssl-no-asm]
659+
echo vcbuild.bat [debug/release] [msi] [doc] [test/test-ci/test-all/test-addons/test-addons-napi/test-internet/test-pummel/test-simple/test-message/test-gc/test-tick-processor/test-known-issues/test-node-inspect/test-check-deopts/test-npm/test-async-hooks/test-v8/test-v8-intl/test-v8-benchmarks/test-v8-all] [ignore-flaky] [static/dll] [noprojgen] [projgen] [small-icu/full-icu/without-intl] [nobuild] [nosnapshot] [noetw] [noperfctr] [licensetf] [sign] [ia32/x86/x64] [vs2017] [download-all] [enable-vtune] [lint/lint-ci/lint-js/lint-js-ci/lint-md] [lint-md-build] [package] [build-release] [upload] [no-NODE-OPTIONS] [link-module path-to-module] [debug-http2] [debug-nghttp2] [clean] [no-cctest] [openssl-no-asm]
633660
echo Examples:
634661
echo vcbuild.bat : builds release build
635662
echo vcbuild.bat debug : builds debug build

0 commit comments

Comments
 (0)