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