1@if not defined DEBUG_HELPER @ECHO OFF 2 3:: Other scripts rely on the environment variables set in this script, so we 4:: explicitly allow them to persist in the calling shell. 5endlocal 6 7if /i "%1"=="help" goto help 8if /i "%1"=="--help" goto help 9if /i "%1"=="-help" goto help 10if /i "%1"=="/help" goto help 11if /i "%1"=="?" goto help 12if /i "%1"=="-?" goto help 13if /i "%1"=="--?" goto help 14if /i "%1"=="/?" goto help 15 16cd %~dp0 17 18set JS_SUITES=default 19set NATIVE_SUITES=addons js-native-api node-api 20@rem CI_* variables should be kept synchronized with the ones in Makefile 21set "CI_NATIVE_SUITES=%NATIVE_SUITES% benchmark" 22set "CI_JS_SUITES=%JS_SUITES%" 23set CI_DOC=doctool 24@rem Same as the test-ci target in Makefile 25set "common_test_suites=%JS_SUITES% %NATIVE_SUITES%&set build_addons=1&set build_js_native_api_tests=1&set build_node_api_tests=1" 26 27@rem Process arguments. 28set config=Release 29set target=Build 30set target_arch=x64 31set ltcg= 32set target_env= 33set noprojgen= 34set projgen= 35set nobuild= 36set sign= 37set nosnapshot= 38set cctest_args= 39set test_args= 40set stage_package= 41set package= 42set msi= 43set upload= 44set licensertf= 45set lint_js= 46set lint_cpp= 47set lint_md= 48set lint_md_build= 49set noetw= 50set noetw_msi_arg= 51set i18n_arg= 52set download_arg= 53set build_release= 54set configure_flags= 55set build_addons= 56set dll= 57set enable_static= 58set build_js_native_api_tests= 59set build_node_api_tests= 60set test_node_inspect= 61set test_check_deopts= 62set v8_test_options= 63set v8_build_options= 64set http2_debug= 65set nghttp2_debug= 66set link_module= 67set no_cctest= 68set cctest= 69set openssl_no_asm= 70set doc= 71set extra_msbuild_args= 72set exit_code=0 73 74:next-arg 75if "%1"=="" goto args-done 76if /i "%1"=="debug" set config=Debug&goto arg-ok 77if /i "%1"=="release" set config=Release&set ltcg=1&set cctest=1&goto arg-ok 78if /i "%1"=="clean" set target=Clean&goto arg-ok 79if /i "%1"=="testclean" set target=TestClean&goto arg-ok 80if /i "%1"=="ia32" set target_arch=x86&goto arg-ok 81if /i "%1"=="x86" set target_arch=x86&goto arg-ok 82if /i "%1"=="x64" set target_arch=x64&goto arg-ok 83if /i "%1"=="arm64" set target_arch=arm64&goto arg-ok 84if /i "%1"=="vs2017" set target_env=vs2017&goto arg-ok 85if /i "%1"=="vs2019" set target_env=vs2019&goto arg-ok 86if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok 87if /i "%1"=="projgen" set projgen=1&goto arg-ok 88if /i "%1"=="nobuild" set nobuild=1&goto arg-ok 89if /i "%1"=="nosign" set "sign="&echo Note: vcbuild no longer signs by default. "nosign" is redundant.&goto arg-ok 90if /i "%1"=="sign" set sign=1&goto arg-ok 91if /i "%1"=="nosnapshot" set nosnapshot=1&goto arg-ok 92if /i "%1"=="noetw" set noetw=1&goto arg-ok 93if /i "%1"=="ltcg" set ltcg=1&goto arg-ok 94if /i "%1"=="licensertf" set licensertf=1&goto arg-ok 95if /i "%1"=="test" set test_args=%test_args% -J %common_test_suites%&set lint_cpp=1&set lint_js=1&set lint_md=1&goto arg-ok 96if /i "%1"=="test-ci-native" set test_args=%test_args% %test_ci_args% -J -p tap --logfile test.tap %CI_NATIVE_SUITES% %CI_DOC%&set build_addons=1&set build_js_native_api_tests=1&set build_node_api_tests=1&set cctest_args=%cctest_args% --gtest_output=xml:cctest.junit.xml&goto arg-ok 97if /i "%1"=="test-ci-js" set test_args=%test_args% %test_ci_args% -J -p tap --logfile test.tap %CI_JS_SUITES%&set no_cctest=1&goto arg-ok 98if /i "%1"=="build-addons" set build_addons=1&goto arg-ok 99if /i "%1"=="build-js-native-api-tests" set build_js_native_api_tests=1&goto arg-ok 100if /i "%1"=="build-node-api-tests" set build_node_api_tests=1&goto arg-ok 101if /i "%1"=="test-addons" set test_args=%test_args% addons&set build_addons=1&goto arg-ok 102if /i "%1"=="test-doc" set test_args=%test_args% %CI_DOC%&set doc=1&&set lint_js=1&set lint_md=1&goto arg-ok 103if /i "%1"=="test-js-native-api" set test_args=%test_args% js-native-api&set build_js_native_api_tests=1&goto arg-ok 104if /i "%1"=="test-node-api" set test_args=%test_args% node-api&set build_node_api_tests=1&goto arg-ok 105if /i "%1"=="test-benchmark" set test_args=%test_args% benchmark&goto arg-ok 106if /i "%1"=="test-simple" set test_args=%test_args% sequential parallel -J&goto arg-ok 107if /i "%1"=="test-message" set test_args=%test_args% message&goto arg-ok 108if /i "%1"=="test-tick-processor" set test_args=%test_args% tick-processor&goto arg-ok 109if /i "%1"=="test-internet" set test_args=%test_args% internet&goto arg-ok 110if /i "%1"=="test-pummel" set test_args=%test_args% pummel&goto arg-ok 111if /i "%1"=="test-known-issues" set test_args=%test_args% known_issues&goto arg-ok 112if /i "%1"=="test-async-hooks" set test_args=%test_args% async-hooks&goto arg-ok 113if /i "%1"=="test-all" set test_args=%test_args% gc internet pummel %common_test_suites%&set lint_cpp=1&set lint_js=1&goto arg-ok 114if /i "%1"=="test-node-inspect" set test_node_inspect=1&goto arg-ok 115if /i "%1"=="test-check-deopts" set test_check_deopts=1&goto arg-ok 116if /i "%1"=="test-npm" set test_npm=1&goto arg-ok 117if /i "%1"=="test-v8" set test_v8=1&set custom_v8_test=1&goto arg-ok 118if /i "%1"=="test-v8-intl" set test_v8_intl=1&set custom_v8_test=1&goto arg-ok 119if /i "%1"=="test-v8-benchmarks" set test_v8_benchmarks=1&set custom_v8_test=1&goto arg-ok 120if /i "%1"=="test-v8-all" set test_v8=1&set test_v8_intl=1&set test_v8_benchmarks=1&set custom_v8_test=1&goto arg-ok 121if /i "%1"=="lint-cpp" set lint_cpp=1&goto arg-ok 122if /i "%1"=="lint-js" set lint_js=1&goto arg-ok 123if /i "%1"=="jslint" set lint_js=1&echo Please use lint-js instead of jslint&goto arg-ok 124if /i "%1"=="lint-md" set lint_md=1&goto arg-ok 125if /i "%1"=="lint-md-build" set lint_md_build=1&goto arg-ok 126if /i "%1"=="lint" set lint_cpp=1&set lint_js=1&set lint_md=1&goto arg-ok 127if /i "%1"=="lint-ci" set lint_cpp=1&set lint_js_ci=1&goto arg-ok 128if /i "%1"=="package" set package=1&goto arg-ok 129if /i "%1"=="msi" set msi=1&set licensertf=1&set download_arg="--download=all"&set i18n_arg=full-icu&goto arg-ok 130if /i "%1"=="build-release" set build_release=1&set sign=1&goto arg-ok 131if /i "%1"=="upload" set upload=1&goto arg-ok 132if /i "%1"=="small-icu" set i18n_arg=%1&goto arg-ok 133if /i "%1"=="full-icu" set i18n_arg=%1&goto arg-ok 134if /i "%1"=="intl-none" set i18n_arg=none&goto arg-ok 135if /i "%1"=="without-intl" set i18n_arg=none&goto arg-ok 136if /i "%1"=="download-all" set download_arg="--download=all"&goto arg-ok 137if /i "%1"=="ignore-flaky" set test_args=%test_args% --flaky-tests=dontcare&goto arg-ok 138if /i "%1"=="dll" set dll=1&goto arg-ok 139if /i "%1"=="static" set enable_static=1&goto arg-ok 140if /i "%1"=="no-NODE-OPTIONS" set no_NODE_OPTIONS=1&goto arg-ok 141if /i "%1"=="debug-nghttp2" set debug_nghttp2=1&goto arg-ok 142if /i "%1"=="link-module" set "link_module= --link-module=%2%link_module%"&goto arg-ok-2 143if /i "%1"=="no-cctest" set no_cctest=1&goto arg-ok 144if /i "%1"=="cctest" set cctest=1&goto arg-ok 145if /i "%1"=="openssl-no-asm" set openssl_no_asm=1&goto arg-ok 146if /i "%1"=="doc" set doc=1&goto arg-ok 147if /i "%1"=="binlog" set extra_msbuild_args=/binaryLogger:%config%\node.binlog&goto arg-ok 148 149echo Error: invalid command line option `%1`. 150exit /b 1 151 152:arg-ok-2 153shift 154:arg-ok 155shift 156goto next-arg 157 158:args-done 159 160if defined build_release ( 161 set config=Release 162 set package=1 163 set msi=1 164 set licensertf=1 165 set download_arg="--download=all" 166 set i18n_arg=full-icu 167 set projgen=1 168 set cctest=1 169 set ltcg=1 170) 171 172if defined msi set stage_package=1 173if defined package set stage_package=1 174 175:: assign path to node_exe 176set "node_exe=%config%\node.exe" 177set "node_gyp_exe="%node_exe%" deps\npm\node_modules\node-gyp\bin\node-gyp" 178set "npm_exe="%~dp0%node_exe%" %~dp0deps\npm\bin\npm-cli.js" 179if "%target_env%"=="vs2017" set "node_gyp_exe=%node_gyp_exe% --msvs_version=2017" 180if "%target_env%"=="vs2019" set "node_gyp_exe=%node_gyp_exe% --msvs_version=2019" 181 182:: skip building if the only argument received was lint 183if "%*"=="lint" if exist "%node_exe%" goto lint-cpp 184 185if "%config%"=="Debug" set configure_flags=%configure_flags% --debug 186if defined nosnapshot set configure_flags=%configure_flags% --without-snapshot 187if defined noetw set configure_flags=%configure_flags% --without-etw& set noetw_msi_arg=/p:NoETW=1 188if defined ltcg set configure_flags=%configure_flags% --with-ltcg 189if defined release_urlbase set configure_flags=%configure_flags% --release-urlbase=%release_urlbase% 190if defined download_arg set configure_flags=%configure_flags% %download_arg% 191if defined dll set configure_flags=%configure_flags% --shared 192if defined enable_static set configure_flags=%configure_flags% --enable-static 193if defined no_NODE_OPTIONS set configure_flags=%configure_flags% --without-node-options 194if defined link_module set configure_flags=%configure_flags% %link_module% 195if defined i18n_arg set configure_flags=%configure_flags% --with-intl=%i18n_arg% 196if defined config_flags set configure_flags=%configure_flags% %config_flags% 197if defined target_arch set configure_flags=%configure_flags% --dest-cpu=%target_arch% 198if defined openssl_no_asm set configure_flags=%configure_flags% --openssl-no-asm 199if defined DEBUG_HELPER set configure_flags=%configure_flags% --verbose 200if "%target_arch%"=="x86" if "%PROCESSOR_ARCHITECTURE%"=="AMD64" set configure_flags=%configure_flags% --no-cross-compiling 201if "%target_arch%"=="arm64" set configure_flags=%configure_flags% --cross-compiling 202 203if not exist "%~dp0deps\icu" goto no-depsicu 204if "%target%"=="Clean" echo deleting %~dp0deps\icu 205if "%target%"=="Clean" rmdir /S /Q %~dp0deps\icu 206:no-depsicu 207 208if "%target%"=="TestClean" ( 209 echo deleting test/.tmp* 210 if exist "test\.tmp*" for /f %%i in ('dir /a:d /s /b test\.tmp*') do rmdir /S /Q "%%i" 211 goto exit 212) 213 214 215call tools\msvs\find_python.cmd 216if errorlevel 1 goto :exit 217 218REM NASM is only needed on IA32 and x86_64. 219if not defined openssl_no_asm if "%target_arch%" NEQ "arm64" call tools\msvs\find_nasm.cmd 220if errorlevel 1 echo Could not find NASM, install it or build with openssl-no-asm. See BUILDING.md. 221 222call :getnodeversion || exit /b 1 223 224if defined TAG set configure_flags=%configure_flags% --tag=%TAG% 225 226if not "%target%"=="Clean" goto skip-clean 227rmdir /Q /S "%~dp0%config%\%TARGET_NAME%" > nul 2> nul 228:skip-clean 229 230if defined noprojgen if defined nobuild goto :after-build 231 232@rem Set environment for msbuild 233 234set msvs_host_arch=x86 235if _%PROCESSOR_ARCHITECTURE%_==_AMD64_ set msvs_host_arch=amd64 236if _%PROCESSOR_ARCHITEW6432%_==_AMD64_ set msvs_host_arch=amd64 237@rem usually vcvarsall takes an argument: host + '_' + target 238set vcvarsall_arg=%msvs_host_arch%_%target_arch% 239@rem unless both host and target are x64 240if %target_arch%==x64 if %msvs_host_arch%==amd64 set vcvarsall_arg=amd64 241@rem also if both are x86 242if %target_arch%==x86 if %msvs_host_arch%==x86 set vcvarsall_arg=x86 243 244@rem Look for Visual Studio 2019 245:vs-set-2019 246if defined target_env if "%target_env%" NEQ "vs2019" goto vs-set-2017 247echo Looking for Visual Studio 2019 248@rem VCINSTALLDIR may be set if run from a VS Command Prompt and needs to be 249@rem cleared first as vswhere_usability_wrapper.cmd doesn't when it fails to 250@rem detect the version searched for 251if not defined target_env set "VCINSTALLDIR=" 252call tools\msvs\vswhere_usability_wrapper.cmd "[16.0,17.0)" "prerelease" 253if "_%VCINSTALLDIR%_" == "__" goto vs-set-2017 254set "WIXSDKDIR=%WIX%\SDK\VS2017" 255if defined msi ( 256 echo Looking for WiX installation for Visual Studio 2019... 257 if not exist "%WIXSDKDIR%" ( 258 echo Failed to find WiX install for Visual Studio 2019 259 echo VS2019 support for WiX is only present starting at version 3.11 260 goto vs-set-2017 261 ) 262 if not exist "%VCINSTALLDIR%\..\MSBuild\Microsoft\WiX" ( 263 echo Failed to find the WiX Toolset Visual Studio 2019 Extension 264 goto vs-set-2017 265 ) 266) 267@rem check if VS2019 is already setup, and for the requested arch 268if "_%VisualStudioVersion%_" == "_16.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%target_arch%_" goto found_vs2019 269@rem need to clear VSINSTALLDIR for vcvarsall to work as expected 270set "VSINSTALLDIR=" 271@rem prevent VsDevCmd.bat from changing the current working directory 272set "VSCMD_START_DIR=%CD%" 273set vcvars_call="%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %vcvarsall_arg% 274echo calling: %vcvars_call% 275call %vcvars_call% 276if errorlevel 1 goto vs-set-2017 277if defined DEBUG_HELPER @ECHO ON 278:found_vs2019 279echo Found MSVS version %VisualStudioVersion% 280set GYP_MSVS_VERSION=2019 281set PLATFORM_TOOLSET=v142 282goto msbuild-found 283 284@rem Look for Visual Studio 2017 285:vs-set-2017 286if defined target_env if "%target_env%" NEQ "vs2017" goto msbuild-not-found 287echo Looking for Visual Studio 2017 288call tools\msvs\vswhere_usability_wrapper.cmd "[15.0,16.0)" 289if "_%VCINSTALLDIR%_" == "__" goto msbuild-not-found 290set "WIXSDKDIR=%WIX%\SDK\VS2017" 291if defined msi ( 292 echo Looking for WiX installation for Visual Studio 2017... 293 if not exist "%WIXSDKDIR%" ( 294 echo Failed to find WiX install for Visual Studio 2017 295 echo VS2017 support for WiX is only present starting at version 3.11 296 goto msbuild-not-found 297 ) 298 if not exist "%VCINSTALLDIR%\..\MSBuild\Microsoft\WiX" ( 299 echo Failed to find the WiX Toolset Visual Studio 2017 Extension 300 goto msbuild-not-found 301 ) 302) 303@rem check if VS2017 is already setup, and for the requested arch 304if "_%VisualStudioVersion%_" == "_15.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%target_arch%_" goto found_vs2017 305@rem need to clear VSINSTALLDIR for vcvarsall to work as expected 306set "VSINSTALLDIR=" 307@rem prevent VsDevCmd.bat from changing the current working directory 308set "VSCMD_START_DIR=%CD%" 309set vcvars_call="%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %vcvarsall_arg% 310echo calling: %vcvars_call% 311call %vcvars_call% 312if errorlevel 1 goto msbuild-not-found 313if defined DEBUG_HELPER @ECHO ON 314:found_vs2017 315echo Found MSVS version %VisualStudioVersion% 316set GYP_MSVS_VERSION=2017 317set PLATFORM_TOOLSET=v141 318goto msbuild-found 319 320:msbuild-not-found 321echo Failed to find a suitable Visual Studio installation. 322echo Try to run in a "Developer Command Prompt" or consult 323echo https://github.com/nodejs/node/blob/HEAD/BUILDING.md#windows 324goto exit 325 326:msbuild-found 327 328set project_generated= 329:project-gen 330@rem Skip project generation if requested. 331if defined noprojgen goto msbuild 332if defined projgen goto run-configure 333if not exist node.sln goto run-configure 334if not exist .gyp_configure_stamp goto run-configure 335echo %configure_flags% > .tmp_gyp_configure_stamp 336where /R . /T *.gyp* >> .tmp_gyp_configure_stamp 337fc .gyp_configure_stamp .tmp_gyp_configure_stamp >NUL 2>&1 338if errorlevel 1 goto run-configure 339 340:skip-configure 341del .tmp_gyp_configure_stamp 2> NUL 342echo Reusing solution generated with %configure_flags% 343goto msbuild 344 345:run-configure 346del .tmp_gyp_configure_stamp 2> NUL 347del .gyp_configure_stamp 2> NUL 348@rem Generate the VS project. 349echo configure %configure_flags% 350echo %configure_flags%> .used_configure_flags 351python configure %configure_flags% 352if errorlevel 1 goto create-msvs-files-failed 353if not exist node.sln goto create-msvs-files-failed 354set project_generated=1 355echo Project files generated. 356echo %configure_flags% > .gyp_configure_stamp 357where /R . /T *.gyp* >> .gyp_configure_stamp 358 359:msbuild 360@rem Skip build if requested. 361if defined nobuild goto :after-build 362 363@rem Build the sln with msbuild. 364set "msbcpu=/m:2" 365if "%NUMBER_OF_PROCESSORS%"=="1" set "msbcpu=/m:1" 366set "msbplatform=Win32" 367if "%target_arch%"=="x64" set "msbplatform=x64" 368if "%target_arch%"=="arm64" set "msbplatform=ARM64" 369if "%target%"=="Build" ( 370 if defined no_cctest set target=node 371 if "%test_args%"=="" set target=node 372 if defined cctest set target="Build" 373) 374if "%target%"=="node" if exist "%config%\cctest.exe" del "%config%\cctest.exe" 375if defined msbuild_args set "extra_msbuild_args=%extra_msbuild_args% %msbuild_args%" 376@rem Setup env variables to use multiprocessor build 377set UseMultiToolTask=True 378set EnforceProcessCountAcrossBuilds=True 379set MultiProcMaxCount=%NUMBER_OF_PROCESSORS% 380msbuild node.sln %msbcpu% /t:%target% /p:Configuration=%config% /p:Platform=%msbplatform% /clp:NoItemAndPropertyList;Verbosity=minimal /nologo %extra_msbuild_args% 381if errorlevel 1 ( 382 if not defined project_generated echo Building Node with reused solution failed. To regenerate project files use "vcbuild projgen" 383 exit /B 1 384) 385if "%target%" == "Clean" goto exit 386 387:after-build 388rd %config% 389if errorlevel 1 echo "Old build output exists at 'out\%config%'. Please remove." & exit /B 390:: Use /J because /D (symlink) requires special permissions. 391if EXIST out\%config% mklink /J %config% out\%config% 392if errorlevel 1 echo "Could not create junction to 'out\%config%'." & exit /B 393 394:sign 395@rem Skip signing unless the `sign` option was specified. 396if not defined sign goto licensertf 397 398call tools\sign.bat Release\node.exe 399if errorlevel 1 echo Failed to sign exe&goto exit 400 401:licensertf 402@rem Skip license.rtf generation if not requested. 403if not defined licensertf goto stage_package 404 405set "use_x64_node_exe=false" 406if "%target_arch%"=="arm64" if "%PROCESSOR_ARCHITECTURE%"=="AMD64" set "use_x64_node_exe=true" 407if "%use_x64_node_exe%"=="true" ( 408 echo Cross-compilation to ARM64 detected. We'll use the x64 Node executable for license2rtf. 409 if not defined "%x64_node_exe%" set "x64_node_exe=temp-vcbuild\node-x64-cross-compiling.exe" 410 if not exist "%x64_node_exe%" ( 411 echo Downloading x64 node.exe... 412 if not exist "temp-vcbuild" mkdir temp-vcbuild 413 powershell -c "Invoke-WebRequest -Uri 'https://nodejs.org/dist/latest/win-x64/node.exe' -OutFile 'temp-vcbuild\node-x64-cross-compiling.exe'" 414 ) 415 if not exist "%x64_node_exe%" ( 416 echo Could not find the Node executable at the given x64_node_exe path. Aborting. 417 set exit_code=1 418 goto exit 419 ) 420 %x64_node_exe% tools\license2rtf.js < LICENSE > %config%\license.rtf 421) else ( 422 %node_exe% tools\license2rtf.js < LICENSE > %config%\license.rtf 423) 424 425if errorlevel 1 echo Failed to generate license.rtf&goto exit 426 427:stage_package 428if not defined stage_package goto install-doctools 429 430echo Creating package... 431cd Release 432rmdir /S /Q %TARGET_NAME% > nul 2> nul 433mkdir %TARGET_NAME% > nul 2> nul 434mkdir %TARGET_NAME%\node_modules > nul 2>nul 435 436copy /Y node.exe %TARGET_NAME%\ > nul 437if errorlevel 1 echo Cannot copy node.exe && goto package_error 438copy /Y ..\LICENSE %TARGET_NAME%\ > nul 439if errorlevel 1 echo Cannot copy LICENSE && goto package_error 440copy /Y ..\README.md %TARGET_NAME%\ > nul 441if errorlevel 1 echo Cannot copy README.md && goto package_error 442copy /Y ..\CHANGELOG.md %TARGET_NAME%\ > nul 443if errorlevel 1 echo Cannot copy CHANGELOG.md && goto package_error 444robocopy ..\deps\npm %TARGET_NAME%\node_modules\npm /e /xd test > nul 445if errorlevel 8 echo Cannot copy npm package && goto package_error 446robocopy ..\deps\corepack %TARGET_NAME%\node_modules\corepack /e /xd test > nul 447if errorlevel 8 echo Cannot copy corepack package && goto package_error 448copy /Y ..\deps\npm\bin\npm %TARGET_NAME%\ > nul 449if errorlevel 1 echo Cannot copy npm && goto package_error 450copy /Y ..\deps\npm\bin\npm.cmd %TARGET_NAME%\ > nul 451if errorlevel 1 echo Cannot copy npm.cmd && goto package_error 452copy /Y ..\deps\npm\bin\npx %TARGET_NAME%\ > nul 453if errorlevel 1 echo Cannot copy npx && goto package_error 454copy /Y ..\deps\npm\bin\npx.cmd %TARGET_NAME%\ > nul 455if errorlevel 1 echo Cannot copy npx.cmd && goto package_error 456copy /Y ..\deps\corepack\shims\nodewin\corepack %TARGET_NAME%\ > nul 457if errorlevel 1 echo Cannot copy corepack && goto package_error 458copy /Y ..\deps\corepack\shims\nodewin\corepack.cmd %TARGET_NAME%\ > nul 459if errorlevel 1 echo Cannot copy corepack.cmd && goto package_error 460copy /Y ..\tools\msvs\nodevars.bat %TARGET_NAME%\ > nul 461if errorlevel 1 echo Cannot copy nodevars.bat && goto package_error 462copy /Y ..\tools\msvs\install_tools\*.* %TARGET_NAME%\ > nul 463if errorlevel 1 echo Cannot copy install_tools scripts && goto package_error 464if not defined noetw ( 465 copy /Y ..\src\res\node_etw_provider.man %TARGET_NAME%\ > nul 466 if errorlevel 1 echo Cannot copy node_etw_provider.man && goto package_error 467) 468cd .. 469 470:package 471if not defined package goto msi 472cd Release 473echo Creating %TARGET_NAME%.7z 474del %TARGET_NAME%.7z > nul 2> nul 4757z a -r -mx9 -t7z %TARGET_NAME%.7z %TARGET_NAME% > nul 476if errorlevel 1 echo Cannot create %TARGET_NAME%.7z && goto package_error 477 478echo Creating %TARGET_NAME%.zip 479del %TARGET_NAME%.zip > nul 2> nul 4807z a -r -mx9 -tzip %TARGET_NAME%.zip %TARGET_NAME% > nul 481if errorlevel 1 echo Cannot create %TARGET_NAME%.zip && goto package_error 482 483echo Creating node_pdb.7z 484del node_pdb.7z > nul 2> nul 4857z a -mx9 -t7z node_pdb.7z node.pdb > nul 486 487echo Creating node_pdb.zip 488del node_pdb.zip > nul 2> nul 4897z a -mx9 -tzip node_pdb.zip node.pdb > nul 490 491cd .. 492echo Package created! 493goto package_done 494:package_error 495cd .. 496exit /b 1 497:package_done 498 499:msi 500@rem Skip msi generation if not requested 501if not defined msi goto install-doctools 502 503:msibuild 504echo Building node-v%FULLVERSION%-%target_arch%.msi 505set "msbsdk=" 506if defined WindowsSDKVersion set "msbsdk=/p:WindowsTargetPlatformVersion=%WindowsSDKVersion:~0,-1%" 507msbuild "%~dp0tools\msvs\msi\nodemsi.sln" /m /t:Clean,Build %msbsdk% /p:PlatformToolset=%PLATFORM_TOOLSET% /p:WixSdkDir="%WIXSDKDIR%" /p:Configuration=%config% /p:Platform=%target_arch% /p:NodeVersion=%NODE_VERSION% /p:FullVersion=%FULLVERSION% /p:DistTypeDir=%DISTTYPEDIR% %noetw_msi_arg% /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo 508if errorlevel 1 goto exit 509 510if not defined sign goto upload 511call tools\sign.bat node-v%FULLVERSION%-%target_arch%.msi 512if errorlevel 1 echo Failed to sign msi&goto exit 513 514:upload 515@rem Skip upload if not requested 516if not defined upload goto install-doctools 517 518if not defined SSHCONFIG ( 519 echo SSHCONFIG is not set for upload 520 exit /b 1 521) 522 523if not defined STAGINGSERVER set STAGINGSERVER=node-www 524ssh -F %SSHCONFIG% %STAGINGSERVER% "mkdir -p nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%" 525if errorlevel 1 goto exit 526scp -F %SSHCONFIG% Release\node.exe %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%/node.exe 527if errorlevel 1 goto exit 528scp -F %SSHCONFIG% Release\node.lib %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%/node.lib 529if errorlevel 1 goto exit 530scp -F %SSHCONFIG% Release\node_pdb.zip %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%/node_pdb.zip 531if errorlevel 1 goto exit 532scp -F %SSHCONFIG% Release\node_pdb.7z %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%/node_pdb.7z 533if errorlevel 1 goto exit 534scp -F %SSHCONFIG% Release\%TARGET_NAME%.7z %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/%TARGET_NAME%.7z 535if errorlevel 1 goto exit 536scp -F %SSHCONFIG% Release\%TARGET_NAME%.zip %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/%TARGET_NAME%.zip 537if errorlevel 1 goto exit 538scp -F %SSHCONFIG% node-v%FULLVERSION%-%target_arch%.msi %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/ 539if errorlevel 1 goto exit 540ssh -F %SSHCONFIG% %STAGINGSERVER% "touch nodejs/%DISTTYPEDIR%/v%FULLVERSION%/node-v%FULLVERSION%-%target_arch%.msi.done nodejs/%DISTTYPEDIR%/v%FULLVERSION%/%TARGET_NAME%.zip.done nodejs/%DISTTYPEDIR%/v%FULLVERSION%/%TARGET_NAME%.7z.done nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%.done && chmod -R ug=rw-x+X,o=r+X nodejs/%DISTTYPEDIR%/v%FULLVERSION%/node-v%FULLVERSION%-%target_arch%.* nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%*" 541if errorlevel 1 goto exit 542 543 544:install-doctools 545REM only install if building doc OR testing doctool OR building addons 546if not defined doc if not defined build_addons ( 547 echo.%test_args% | findstr doctool 1>nul 548 if errorlevel 1 goto :skip-install-doctools 549) 550if exist "tools\doc\node_modules\unified\package.json" goto skip-install-doctools 551SETLOCAL 552cd tools\doc 553%npm_exe% ci 554cd ..\.. 555if errorlevel 1 goto exit 556ENDLOCAL 557:skip-install-doctools 558@rem Clear errorlevel from echo.%test_args% | findstr doctool 1>nul 559cd . 560 561:build-doc 562@rem Build documentation if requested 563if not defined doc goto run 564if not exist %node_exe% ( 565 echo Failed to find node.exe 566 goto run 567) 568mkdir %config%\doc 569robocopy /e doc\api %config%\doc\api 570robocopy /e doc\api_assets %config%\doc\api\assets 571 572for %%F in (%config%\doc\api\*.md) do ( 573 %node_exe% tools\doc\generate.mjs --node-version=v%FULLVERSION% %%F --output-directory=%%~dF%%~pF 574) 575 576:run 577@rem Run tests if requested. 578 579if not defined build_addons goto build-js-native-api-tests 580if not exist "%node_exe%" ( 581 echo Failed to find node.exe 582 goto build-js-native-api-tests 583) 584echo Building addons 585:: clear 586for /d %%F in (test\addons\??_*) do ( 587 rd /s /q %%F 588) 589:: generate 590"%node_exe%" tools\doc\addon-verify.mjs 591if %errorlevel% neq 0 exit /b %errorlevel% 592:: building addons 593setlocal 594set npm_config_nodedir=%~dp0 595"%node_exe%" "%~dp0tools\build-addons.js" "%~dp0deps\npm\node_modules\node-gyp\bin\node-gyp.js" "%~dp0test\addons" 596if errorlevel 1 exit /b 1 597endlocal 598 599:build-js-native-api-tests 600if not defined build_js_native_api_tests goto build-node-api-tests 601if not exist "%node_exe%" ( 602 echo Failed to find node.exe 603 goto build-node-api-tests 604) 605echo Building js-native-api 606:: clear 607for /d %%F in (test\js-native-api\??_*) do ( 608 rd /s /q %%F 609) 610:: building js-native-api 611setlocal 612set npm_config_nodedir=%~dp0 613"%node_exe%" "%~dp0tools\build-addons.js" "%~dp0deps\npm\node_modules\node-gyp\bin\node-gyp.js" "%~dp0test\js-native-api" 614if errorlevel 1 exit /b 1 615endlocal 616goto build-node-api-tests 617 618:build-node-api-tests 619if not defined build_node_api_tests goto run-tests 620if not exist "%node_exe%" ( 621 echo Failed to find node.exe 622 goto run-tests 623) 624echo Building node-api 625:: clear 626for /d %%F in (test\node-api\??_*) do ( 627 rd /s /q %%F 628) 629:: building node-api 630setlocal 631set npm_config_nodedir=%~dp0 632"%node_exe%" "%~dp0tools\build-addons.js" "%~dp0deps\npm\node_modules\node-gyp\bin\node-gyp.js" "%~dp0test\node-api" 633if errorlevel 1 exit /b 1 634endlocal 635goto run-tests 636 637:run-tests 638if defined test_check_deopts goto node-check-deopts 639if defined test_node_inspect goto node-test-inspect 640goto node-tests 641 642:node-check-deopts 643python tools\test.py --mode=release --check-deopts parallel sequential -J 644if defined test_node_inspect goto node-test-inspect 645goto node-tests 646 647:node-test-inspect 648set USE_EMBEDDED_NODE_INSPECT=1 649%node_exe% tools\test-npm-package.js --install deps\node-inspect test 650goto node-tests 651 652:node-tests 653if not defined test_npm goto no-test-npm 654set npm_test_cmd="%node_exe%" tools\test-npm-package.js --install --logfile=test-npm.tap deps\npm test-node 655echo %npm_test_cmd% 656%npm_test_cmd% 657if errorlevel 1 goto exit 658:no-test-npm 659 660if "%test_args%"=="" goto test-v8 661if "%config%"=="Debug" set test_args=--mode=debug %test_args% 662if "%config%"=="Release" set test_args=--mode=release %test_args% 663if defined no_cctest echo Skipping cctest because no-cctest was specified && goto run-test-py 664if not exist "%config%\cctest.exe" echo cctest.exe not found. Run "vcbuild test" or "vcbuild cctest" to build it. && goto run-test-py 665echo running 'cctest %cctest_args%' 666"%config%\cctest" %cctest_args% 667if %errorlevel% neq 0 set exit_code=%errorlevel% 668:run-test-py 669echo running 'python tools\test.py %test_args%' 670python tools\test.py %test_args% 671if %errorlevel% neq 0 set exit_code=%errorlevel% 672goto test-v8 673 674:test-v8 675if not defined custom_v8_test goto lint-cpp 676call tools/test-v8.bat 677if errorlevel 1 goto exit 678goto lint-cpp 679 680:lint-cpp 681if not defined lint_cpp goto lint-js 682if defined NODEJS_MAKE goto run-make-lint 683where make > NUL 2>&1 && make -v | findstr /C:"GNU Make" 1> NUL 684if "%ERRORLEVEL%"=="0" set "NODEJS_MAKE=make PYTHON=python" & goto run-make-lint 685where wsl > NUL 2>&1 686if "%ERRORLEVEL%"=="0" set "NODEJS_MAKE=wsl make" & goto run-make-lint 687echo Could not find GNU Make, needed for linting C/C++ 688goto lint-js 689 690:run-make-lint 691%NODEJS_MAKE% lint-cpp 692goto lint-js 693 694:lint-js 695if not defined lint_js goto lint-md-build 696if not exist tools\node_modules\eslint goto no-lint 697echo running lint-js 698%node_exe% tools\node_modules\eslint\bin\eslint.js --cache --report-unused-disable-directives --rule "linebreak-style: 0" .eslintrc.js benchmark doc lib test tools 699goto lint-md-build 700 701:no-lint 702echo Linting is not available through the source tarball. 703echo Use the git repo instead: $ git clone https://github.com/nodejs/node.git 704goto lint-md-build 705 706:lint-md-build 707if not defined lint_md_build goto lint-md 708echo "Deprecated no-op target 'lint_md_build'" 709goto lint-md 710 711:lint-md 712if not defined lint_md goto exit 713echo Running Markdown linter on docs... 714SETLOCAL ENABLEDELAYEDEXPANSION 715set lint_md_files= 716for /D %%D IN (doc\*) do ( 717 for %%F IN (%%D\*.md) do ( 718 set "lint_md_files="%%F" !lint_md_files!" 719 ) 720) 721%node_exe% tools\lint-md.mjs -q -f %lint_md_files% 722ENDLOCAL 723goto exit 724 725:create-msvs-files-failed 726echo Failed to create vc project files. 727del .used_configure_flags 728set exit_code=1 729goto exit 730 731:help 732echo vcbuild.bat [debug/release] [msi] [doc] [test/test-all/test-addons/test-doc/test-js-native-api/test-node-api/test-benchmark/test-internet/test-pummel/test-simple/test-message/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] [ltcg] [licensetf] [sign] [ia32/x86/x64/arm64] [vs2017/vs2019] [download-all] [lint/lint-ci/lint-js/lint-md] [lint-md-build] [package] [build-release] [upload] [no-NODE-OPTIONS] [link-module path-to-module] [debug-http2] [debug-nghttp2] [clean] [cctest] [no-cctest] [openssl-no-asm] 733echo Examples: 734echo vcbuild.bat : builds release build 735echo vcbuild.bat debug : builds debug build 736echo vcbuild.bat release msi : builds release build and MSI installer package 737echo vcbuild.bat test : builds debug build and runs tests 738echo vcbuild.bat build-release : builds the release distribution as used by nodejs.org 739echo vcbuild.bat link-module my_module.js : bundles my_module as built-in module 740echo vcbuild.bat lint : runs the C++, documentation and JavaScript linter 741echo vcbuild.bat no-cctest : skip building cctest.exe 742goto exit 743 744:exit 745if %errorlevel% neq 0 exit /b %errorlevel% 746exit /b %exit_code% 747 748 749rem *************** 750rem Subroutines 751rem *************** 752 753:getnodeversion 754set NODE_VERSION= 755set TAG= 756set FULLVERSION= 757 758for /F "usebackq tokens=*" %%i in (`python "%~dp0tools\getnodeversion.py"`) do set NODE_VERSION=%%i 759if not defined NODE_VERSION ( 760 echo Cannot determine current version of Node.js 761 exit /b 1 762) 763 764if not defined DISTTYPE set DISTTYPE=release 765if "%DISTTYPE%"=="release" ( 766 set FULLVERSION=%NODE_VERSION% 767 goto distexit 768) 769if "%DISTTYPE%"=="custom" ( 770 if not defined CUSTOMTAG ( 771 echo "CUSTOMTAG is not set for DISTTYPE=custom" 772 exit /b 1 773 ) 774 set TAG=%CUSTOMTAG% 775) 776if not "%DISTTYPE%"=="custom" ( 777 if not defined DATESTRING ( 778 echo "DATESTRING is not set for nightly" 779 exit /b 1 780 ) 781 if not defined COMMIT ( 782 echo "COMMIT is not set for nightly" 783 exit /b 1 784 ) 785 if not "%DISTTYPE%"=="nightly" ( 786 if not "%DISTTYPE%"=="next-nightly" ( 787 echo "DISTTYPE is not release, custom, nightly or next-nightly" 788 exit /b 1 789 ) 790 ) 791 set TAG=%DISTTYPE%%DATESTRING%%COMMIT% 792) 793set FULLVERSION=%NODE_VERSION%-%TAG% 794 795:distexit 796if not defined DISTTYPEDIR set DISTTYPEDIR=%DISTTYPE% 797set TARGET_NAME=node-v%FULLVERSION%-win-%target_arch% 798goto :EOF 799