11cb0ef41Sopenharmony_ci@if not defined DEBUG_HELPER @ECHO OFF
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci:: Other scripts rely on the environment variables set in this script, so we
41cb0ef41Sopenharmony_ci:: explicitly allow them to persist in the calling shell.
51cb0ef41Sopenharmony_ciendlocal
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciif /i "%1"=="help" goto help
81cb0ef41Sopenharmony_ciif /i "%1"=="--help" goto help
91cb0ef41Sopenharmony_ciif /i "%1"=="-help" goto help
101cb0ef41Sopenharmony_ciif /i "%1"=="/help" goto help
111cb0ef41Sopenharmony_ciif /i "%1"=="?" goto help
121cb0ef41Sopenharmony_ciif /i "%1"=="-?" goto help
131cb0ef41Sopenharmony_ciif /i "%1"=="--?" goto help
141cb0ef41Sopenharmony_ciif /i "%1"=="/?" goto help
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_cicd %~dp0
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ciset JS_SUITES=default
191cb0ef41Sopenharmony_ciset NATIVE_SUITES=addons js-native-api node-api
201cb0ef41Sopenharmony_ci@rem CI_* variables should be kept synchronized with the ones in Makefile
211cb0ef41Sopenharmony_ciset "CI_NATIVE_SUITES=%NATIVE_SUITES% benchmark"
221cb0ef41Sopenharmony_ciset "CI_JS_SUITES=%JS_SUITES% pummel"
231cb0ef41Sopenharmony_ciset CI_DOC=doctool
241cb0ef41Sopenharmony_ci@rem Same as the test-ci target in Makefile
251cb0ef41Sopenharmony_ciset "common_test_suites=%JS_SUITES% %NATIVE_SUITES%&set build_addons=1&set build_js_native_api_tests=1&set build_node_api_tests=1"
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ci@rem Process arguments.
281cb0ef41Sopenharmony_ciset config=Release
291cb0ef41Sopenharmony_ciset target=Build
301cb0ef41Sopenharmony_ciset target_arch=x64
311cb0ef41Sopenharmony_ciset ltcg=
321cb0ef41Sopenharmony_ciset target_env=
331cb0ef41Sopenharmony_ciset noprojgen=
341cb0ef41Sopenharmony_ciset projgen=
351cb0ef41Sopenharmony_ciset nobuild=
361cb0ef41Sopenharmony_ciset sign=
371cb0ef41Sopenharmony_ciset nosnapshot=
381cb0ef41Sopenharmony_ciset nonpm=
391cb0ef41Sopenharmony_ciset nocorepack=
401cb0ef41Sopenharmony_ciset cctest_args=
411cb0ef41Sopenharmony_ciset test_args=
421cb0ef41Sopenharmony_ciset stage_package=
431cb0ef41Sopenharmony_ciset package=
441cb0ef41Sopenharmony_ciset msi=
451cb0ef41Sopenharmony_ciset upload=
461cb0ef41Sopenharmony_ciset licensertf=
471cb0ef41Sopenharmony_ciset lint_js=
481cb0ef41Sopenharmony_ciset lint_cpp=
491cb0ef41Sopenharmony_ciset lint_md=
501cb0ef41Sopenharmony_ciset lint_md_build=
511cb0ef41Sopenharmony_ciset noetw=
521cb0ef41Sopenharmony_ciset noetw_msi_arg=
531cb0ef41Sopenharmony_ciset i18n_arg=
541cb0ef41Sopenharmony_ciset download_arg=
551cb0ef41Sopenharmony_ciset build_release=
561cb0ef41Sopenharmony_ciset configure_flags=
571cb0ef41Sopenharmony_ciset enable_vtune_arg=
581cb0ef41Sopenharmony_ciset build_addons=
591cb0ef41Sopenharmony_ciset dll=
601cb0ef41Sopenharmony_ciset enable_static=
611cb0ef41Sopenharmony_ciset build_js_native_api_tests=
621cb0ef41Sopenharmony_ciset build_node_api_tests=
631cb0ef41Sopenharmony_ciset test_node_inspect=
641cb0ef41Sopenharmony_ciset test_check_deopts=
651cb0ef41Sopenharmony_ciset v8_test_options=
661cb0ef41Sopenharmony_ciset v8_build_options=
671cb0ef41Sopenharmony_ciset http2_debug=
681cb0ef41Sopenharmony_ciset nghttp2_debug=
691cb0ef41Sopenharmony_ciset link_module=
701cb0ef41Sopenharmony_ciset no_cctest=
711cb0ef41Sopenharmony_ciset cctest=
721cb0ef41Sopenharmony_ciset openssl_no_asm=
731cb0ef41Sopenharmony_ciset no_shared_roheap=
741cb0ef41Sopenharmony_ciset doc=
751cb0ef41Sopenharmony_ciset extra_msbuild_args=
761cb0ef41Sopenharmony_ciset exit_code=0
771cb0ef41Sopenharmony_ci
781cb0ef41Sopenharmony_ci:next-arg
791cb0ef41Sopenharmony_ciif "%1"=="" goto args-done
801cb0ef41Sopenharmony_ciif /i "%1"=="debug"         set config=Debug&goto arg-ok
811cb0ef41Sopenharmony_ciif /i "%1"=="release"       set config=Release&set ltcg=1&set cctest=1&goto arg-ok
821cb0ef41Sopenharmony_ciif /i "%1"=="clean"         set target=Clean&goto arg-ok
831cb0ef41Sopenharmony_ciif /i "%1"=="testclean"     set target=TestClean&goto arg-ok
841cb0ef41Sopenharmony_ciif /i "%1"=="ia32"          set target_arch=x86&goto arg-ok
851cb0ef41Sopenharmony_ciif /i "%1"=="x86"           set target_arch=x86&goto arg-ok
861cb0ef41Sopenharmony_ciif /i "%1"=="x64"           set target_arch=x64&goto arg-ok
871cb0ef41Sopenharmony_ciif /i "%1"=="arm64"         set target_arch=arm64&goto arg-ok
881cb0ef41Sopenharmony_ciif /i "%1"=="vs2019"        set target_env=vs2019&goto arg-ok
891cb0ef41Sopenharmony_ciif /i "%1"=="vs2022"        set target_env=vs2022&goto arg-ok
901cb0ef41Sopenharmony_ciif /i "%1"=="noprojgen"     set noprojgen=1&goto arg-ok
911cb0ef41Sopenharmony_ciif /i "%1"=="projgen"       set projgen=1&goto arg-ok
921cb0ef41Sopenharmony_ciif /i "%1"=="nobuild"       set nobuild=1&goto arg-ok
931cb0ef41Sopenharmony_ciif /i "%1"=="nosign"        set "sign="&echo Note: vcbuild no longer signs by default. "nosign" is redundant.&goto arg-ok
941cb0ef41Sopenharmony_ciif /i "%1"=="sign"          set sign=1&goto arg-ok
951cb0ef41Sopenharmony_ciif /i "%1"=="nosnapshot"    set nosnapshot=1&goto arg-ok
961cb0ef41Sopenharmony_ciif /i "%1"=="nonpm"         set nonpm=1&goto arg-ok
971cb0ef41Sopenharmony_ciif /i "%1"=="nocorepack"    set nocorepack=1&goto arg-ok
981cb0ef41Sopenharmony_ciif /i "%1"=="noetw"         set noetw=1&goto arg-ok
991cb0ef41Sopenharmony_ciif /i "%1"=="ltcg"          set ltcg=1&goto arg-ok
1001cb0ef41Sopenharmony_ciif /i "%1"=="licensertf"    set licensertf=1&goto arg-ok
1011cb0ef41Sopenharmony_ciif /i "%1"=="test"          set test_args=%test_args% %common_test_suites%&set lint_cpp=1&set lint_js=1&set lint_md=1&goto arg-ok
1021cb0ef41Sopenharmony_ciif /i "%1"=="test-ci-native" set test_args=%test_args% %test_ci_args% -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
1031cb0ef41Sopenharmony_ciif /i "%1"=="test-ci-js"    set test_args=%test_args% %test_ci_args% -p tap --logfile test.tap %CI_JS_SUITES%&set no_cctest=1&goto arg-ok
1041cb0ef41Sopenharmony_ciif /i "%1"=="build-addons"   set build_addons=1&goto arg-ok
1051cb0ef41Sopenharmony_ciif /i "%1"=="build-js-native-api-tests"   set build_js_native_api_tests=1&goto arg-ok
1061cb0ef41Sopenharmony_ciif /i "%1"=="build-node-api-tests"   set build_node_api_tests=1&goto arg-ok
1071cb0ef41Sopenharmony_ciif /i "%1"=="test-addons"   set test_args=%test_args% addons&set build_addons=1&goto arg-ok
1081cb0ef41Sopenharmony_ciif /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
1091cb0ef41Sopenharmony_ciif /i "%1"=="test-js-native-api"   set test_args=%test_args% js-native-api&set build_js_native_api_tests=1&goto arg-ok
1101cb0ef41Sopenharmony_ciif /i "%1"=="test-node-api"   set test_args=%test_args% node-api&set build_node_api_tests=1&goto arg-ok
1111cb0ef41Sopenharmony_ciif /i "%1"=="test-benchmark" set test_args=%test_args% benchmark&goto arg-ok
1121cb0ef41Sopenharmony_ciif /i "%1"=="test-simple"   set test_args=%test_args% sequential parallel&goto arg-ok
1131cb0ef41Sopenharmony_ciif /i "%1"=="test-message"  set test_args=%test_args% message&goto arg-ok
1141cb0ef41Sopenharmony_ciif /i "%1"=="test-tick-processor" set test_args=%test_args% tick-processor&goto arg-ok
1151cb0ef41Sopenharmony_ciif /i "%1"=="test-internet" set test_args=%test_args% internet&goto arg-ok
1161cb0ef41Sopenharmony_ciif /i "%1"=="test-pummel"   set test_args=%test_args% pummel&goto arg-ok
1171cb0ef41Sopenharmony_ciif /i "%1"=="test-known-issues" set test_args=%test_args% known_issues&goto arg-ok
1181cb0ef41Sopenharmony_ciif /i "%1"=="test-async-hooks"  set test_args=%test_args% async-hooks&goto arg-ok
1191cb0ef41Sopenharmony_ciif /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
1201cb0ef41Sopenharmony_ciif /i "%1"=="test-node-inspect" set test_node_inspect=1&goto arg-ok
1211cb0ef41Sopenharmony_ciif /i "%1"=="test-check-deopts" set test_check_deopts=1&goto arg-ok
1221cb0ef41Sopenharmony_ciif /i "%1"=="test-npm"      set test_npm=1&goto arg-ok
1231cb0ef41Sopenharmony_ciif /i "%1"=="test-v8"       set test_v8=1&set custom_v8_test=1&goto arg-ok
1241cb0ef41Sopenharmony_ciif /i "%1"=="test-v8-intl"  set test_v8_intl=1&set custom_v8_test=1&goto arg-ok
1251cb0ef41Sopenharmony_ciif /i "%1"=="test-v8-benchmarks" set test_v8_benchmarks=1&set custom_v8_test=1&goto arg-ok
1261cb0ef41Sopenharmony_ciif /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
1271cb0ef41Sopenharmony_ciif /i "%1"=="lint-cpp"      set lint_cpp=1&goto arg-ok
1281cb0ef41Sopenharmony_ciif /i "%1"=="lint-js"       set lint_js=1&goto arg-ok
1291cb0ef41Sopenharmony_ciif /i "%1"=="jslint"        set lint_js=1&echo Please use lint-js instead of jslint&goto arg-ok
1301cb0ef41Sopenharmony_ciif /i "%1"=="lint-md"       set lint_md=1&goto arg-ok
1311cb0ef41Sopenharmony_ciif /i "%1"=="lint-md-build" set lint_md_build=1&goto arg-ok
1321cb0ef41Sopenharmony_ciif /i "%1"=="lint"          set lint_cpp=1&set lint_js=1&set lint_md=1&goto arg-ok
1331cb0ef41Sopenharmony_ciif /i "%1"=="lint-ci"       set lint_cpp=1&set lint_js_ci=1&goto arg-ok
1341cb0ef41Sopenharmony_ciif /i "%1"=="package"       set package=1&goto arg-ok
1351cb0ef41Sopenharmony_ciif /i "%1"=="msi"           set msi=1&set licensertf=1&set download_arg="--download=all"&set i18n_arg=full-icu&goto arg-ok
1361cb0ef41Sopenharmony_ciif /i "%1"=="build-release" set build_release=1&set sign=1&goto arg-ok
1371cb0ef41Sopenharmony_ciif /i "%1"=="upload"        set upload=1&goto arg-ok
1381cb0ef41Sopenharmony_ciif /i "%1"=="small-icu"     set i18n_arg=%1&goto arg-ok
1391cb0ef41Sopenharmony_ciif /i "%1"=="full-icu"      set i18n_arg=%1&goto arg-ok
1401cb0ef41Sopenharmony_ciif /i "%1"=="intl-none"     set i18n_arg=none&goto arg-ok
1411cb0ef41Sopenharmony_ciif /i "%1"=="without-intl"  set i18n_arg=none&goto arg-ok
1421cb0ef41Sopenharmony_ciif /i "%1"=="download-all"  set download_arg="--download=all"&goto arg-ok
1431cb0ef41Sopenharmony_ciif /i "%1"=="ignore-flaky"  set test_args=%test_args% --flaky-tests=dontcare&goto arg-ok
1441cb0ef41Sopenharmony_ciif /i "%1"=="dll"           set dll=1&goto arg-ok
1451cb0ef41Sopenharmony_ciif /i "%1"=="enable-vtune" set enable_vtune_arg=1&goto arg-ok
1461cb0ef41Sopenharmony_ciif /i "%1"=="static"           set enable_static=1&goto arg-ok
1471cb0ef41Sopenharmony_ciif /i "%1"=="no-NODE-OPTIONS"	set no_NODE_OPTIONS=1&goto arg-ok
1481cb0ef41Sopenharmony_ciif /i "%1"=="debug-nghttp2" set debug_nghttp2=1&goto arg-ok
1491cb0ef41Sopenharmony_ciif /i "%1"=="link-module"   set "link_module= --link-module=%2%link_module%"&goto arg-ok-2
1501cb0ef41Sopenharmony_ciif /i "%1"=="no-cctest"     set no_cctest=1&goto arg-ok
1511cb0ef41Sopenharmony_ciif /i "%1"=="cctest"        set cctest=1&goto arg-ok
1521cb0ef41Sopenharmony_ciif /i "%1"=="openssl-no-asm"   set openssl_no_asm=1&goto arg-ok
1531cb0ef41Sopenharmony_ciif /i "%1"=="no-shared-roheap" set no_shared_roheap=1&goto arg-ok
1541cb0ef41Sopenharmony_ciif /i "%1"=="doc"           set doc=1&goto arg-ok
1551cb0ef41Sopenharmony_ciif /i "%1"=="binlog"        set extra_msbuild_args=/binaryLogger:%config%\node.binlog&goto arg-ok
1561cb0ef41Sopenharmony_ci
1571cb0ef41Sopenharmony_ciecho Error: invalid command line option `%1`.
1581cb0ef41Sopenharmony_ciexit /b 1
1591cb0ef41Sopenharmony_ci
1601cb0ef41Sopenharmony_ci:arg-ok-2
1611cb0ef41Sopenharmony_cishift
1621cb0ef41Sopenharmony_ci:arg-ok
1631cb0ef41Sopenharmony_cishift
1641cb0ef41Sopenharmony_cigoto next-arg
1651cb0ef41Sopenharmony_ci
1661cb0ef41Sopenharmony_ci:args-done
1671cb0ef41Sopenharmony_ci
1681cb0ef41Sopenharmony_ciif defined build_release (
1691cb0ef41Sopenharmony_ci  set config=Release
1701cb0ef41Sopenharmony_ci  set package=1
1711cb0ef41Sopenharmony_ci  set msi=1
1721cb0ef41Sopenharmony_ci  set licensertf=1
1731cb0ef41Sopenharmony_ci  set download_arg="--download=all"
1741cb0ef41Sopenharmony_ci  set i18n_arg=full-icu
1751cb0ef41Sopenharmony_ci  set projgen=1
1761cb0ef41Sopenharmony_ci  set cctest=1
1771cb0ef41Sopenharmony_ci  set ltcg=1
1781cb0ef41Sopenharmony_ci)
1791cb0ef41Sopenharmony_ci
1801cb0ef41Sopenharmony_ciif defined msi     set stage_package=1
1811cb0ef41Sopenharmony_ciif defined package set stage_package=1
1821cb0ef41Sopenharmony_ci
1831cb0ef41Sopenharmony_ci:: assign path to node_exe
1841cb0ef41Sopenharmony_ciset "node_exe=%config%\node.exe"
1851cb0ef41Sopenharmony_ciset "node_gyp_exe="%node_exe%" deps\npm\node_modules\node-gyp\bin\node-gyp"
1861cb0ef41Sopenharmony_ciset "npm_exe="%~dp0%node_exe%" %~dp0deps\npm\bin\npm-cli.js"
1871cb0ef41Sopenharmony_ciif "%target_env%"=="vs2019" set "node_gyp_exe=%node_gyp_exe% --msvs_version=2019"
1881cb0ef41Sopenharmony_ciif "%target_env%"=="vs2022" set "node_gyp_exe=%node_gyp_exe% --msvs_version=2022"
1891cb0ef41Sopenharmony_ci
1901cb0ef41Sopenharmony_ci:: skip building if the only argument received was lint
1911cb0ef41Sopenharmony_ciif "%*"=="lint" if exist "%node_exe%" goto lint-cpp
1921cb0ef41Sopenharmony_ci
1931cb0ef41Sopenharmony_ciif "%config%"=="Debug"      set configure_flags=%configure_flags% --debug
1941cb0ef41Sopenharmony_ciif defined nosnapshot       set configure_flags=%configure_flags% --without-snapshot
1951cb0ef41Sopenharmony_ciif defined nonpm            set configure_flags=%configure_flags% --without-npm
1961cb0ef41Sopenharmony_ciif defined nocorepack       set configure_flags=%configure_flags% --without-corepack
1971cb0ef41Sopenharmony_ciif defined noetw            set configure_flags=%configure_flags% --without-etw& set noetw_msi_arg=/p:NoETW=1
1981cb0ef41Sopenharmony_ciif defined ltcg             set configure_flags=%configure_flags% --with-ltcg
1991cb0ef41Sopenharmony_ciif defined release_urlbase  set configure_flags=%configure_flags% --release-urlbase=%release_urlbase%
2001cb0ef41Sopenharmony_ciif defined download_arg     set configure_flags=%configure_flags% %download_arg%
2011cb0ef41Sopenharmony_ciif defined enable_vtune_arg set configure_flags=%configure_flags% --enable-vtune-profiling
2021cb0ef41Sopenharmony_ciif defined dll              set configure_flags=%configure_flags% --shared
2031cb0ef41Sopenharmony_ciif defined enable_static    set configure_flags=%configure_flags% --enable-static
2041cb0ef41Sopenharmony_ciif defined no_NODE_OPTIONS  set configure_flags=%configure_flags% --without-node-options
2051cb0ef41Sopenharmony_ciif defined link_module      set configure_flags=%configure_flags% %link_module%
2061cb0ef41Sopenharmony_ciif defined i18n_arg         set configure_flags=%configure_flags% --with-intl=%i18n_arg%
2071cb0ef41Sopenharmony_ciif defined config_flags     set configure_flags=%configure_flags% %config_flags%
2081cb0ef41Sopenharmony_ciif defined target_arch      set configure_flags=%configure_flags% --dest-cpu=%target_arch%
2091cb0ef41Sopenharmony_ciif defined debug_nghttp2    set configure_flags=%configure_flags% --debug-nghttp2
2101cb0ef41Sopenharmony_ciif defined openssl_no_asm   set configure_flags=%configure_flags% --openssl-no-asm
2111cb0ef41Sopenharmony_ciif defined no_shared_roheap set configure_flags=%configure_flags% --disable-shared-readonly-heap
2121cb0ef41Sopenharmony_ciif defined DEBUG_HELPER     set configure_flags=%configure_flags% --verbose
2131cb0ef41Sopenharmony_ciif "%target_arch%"=="x86" if "%PROCESSOR_ARCHITECTURE%"=="AMD64" set configure_flags=%configure_flags% --no-cross-compiling
2141cb0ef41Sopenharmony_ci
2151cb0ef41Sopenharmony_ciif not exist "%~dp0deps\icu" goto no-depsicu
2161cb0ef41Sopenharmony_ciif "%target%"=="Clean" echo deleting %~dp0deps\icu
2171cb0ef41Sopenharmony_ciif "%target%"=="Clean" rmdir /S /Q %~dp0deps\icu
2181cb0ef41Sopenharmony_ci:no-depsicu
2191cb0ef41Sopenharmony_ci
2201cb0ef41Sopenharmony_ciif "%target%"=="TestClean" (
2211cb0ef41Sopenharmony_ci  echo deleting test/.tmp*
2221cb0ef41Sopenharmony_ci  if exist "test\.tmp*" for /f %%i in ('dir /a:d /s /b test\.tmp*') do rmdir /S /Q "%%i"
2231cb0ef41Sopenharmony_ci  goto exit
2241cb0ef41Sopenharmony_ci)
2251cb0ef41Sopenharmony_ci
2261cb0ef41Sopenharmony_ci
2271cb0ef41Sopenharmony_cicall tools\msvs\find_python.cmd
2281cb0ef41Sopenharmony_ciif errorlevel 1 goto :exit
2291cb0ef41Sopenharmony_ci
2301cb0ef41Sopenharmony_ciREM NASM is only needed on IA32 and x86_64.
2311cb0ef41Sopenharmony_ciif not defined openssl_no_asm if "%target_arch%" NEQ "arm64" call tools\msvs\find_nasm.cmd
2321cb0ef41Sopenharmony_ciif errorlevel 1 echo Could not find NASM, install it or build with openssl-no-asm. See BUILDING.md.
2331cb0ef41Sopenharmony_ci
2341cb0ef41Sopenharmony_cicall :getnodeversion || exit /b 1
2351cb0ef41Sopenharmony_ci
2361cb0ef41Sopenharmony_ciif defined TAG set configure_flags=%configure_flags% --tag=%TAG%
2371cb0ef41Sopenharmony_ci
2381cb0ef41Sopenharmony_ciif not "%target%"=="Clean" goto skip-clean
2391cb0ef41Sopenharmony_cirmdir /Q /S "%~dp0%config%\%TARGET_NAME%" > nul 2> nul
2401cb0ef41Sopenharmony_ci:skip-clean
2411cb0ef41Sopenharmony_ci
2421cb0ef41Sopenharmony_ciif defined noprojgen if defined nobuild goto :after-build
2431cb0ef41Sopenharmony_ci
2441cb0ef41Sopenharmony_ci@rem Set environment for msbuild
2451cb0ef41Sopenharmony_ci
2461cb0ef41Sopenharmony_ciset msvs_host_arch=x86
2471cb0ef41Sopenharmony_ciif _%PROCESSOR_ARCHITECTURE%_==_AMD64_ set msvs_host_arch=amd64
2481cb0ef41Sopenharmony_ciif _%PROCESSOR_ARCHITEW6432%_==_AMD64_ set msvs_host_arch=amd64
2491cb0ef41Sopenharmony_ciif _%PROCESSOR_ARCHITECTURE%_==_ARM64_ set msvs_host_arch=arm64
2501cb0ef41Sopenharmony_ci@rem usually vcvarsall takes an argument: host + '_' + target
2511cb0ef41Sopenharmony_ciset vcvarsall_arg=%msvs_host_arch%_%target_arch%
2521cb0ef41Sopenharmony_ci@rem unless both the host and the target are the same
2531cb0ef41Sopenharmony_ciif %target_arch%==x64 if %msvs_host_arch%==amd64 set vcvarsall_arg=amd64
2541cb0ef41Sopenharmony_ciif %target_arch%==%msvs_host_arch% set vcvarsall_arg=%target_arch%
2551cb0ef41Sopenharmony_ci
2561cb0ef41Sopenharmony_ci@rem Look for Visual Studio 2022
2571cb0ef41Sopenharmony_ci:vs-set-2022
2581cb0ef41Sopenharmony_ciif defined target_env if "%target_env%" NEQ "vs2022" goto vs-set-2019
2591cb0ef41Sopenharmony_ciecho Looking for Visual Studio 2022
2601cb0ef41Sopenharmony_ci@rem VCINSTALLDIR may be set if run from a VS Command Prompt and needs to be
2611cb0ef41Sopenharmony_ci@rem cleared first as vswhere_usability_wrapper.cmd doesn't when it fails to
2621cb0ef41Sopenharmony_ci@rem detect the version searched for
2631cb0ef41Sopenharmony_ciif not defined target_env set "VCINSTALLDIR="
2641cb0ef41Sopenharmony_cicall tools\msvs\vswhere_usability_wrapper.cmd "[17.0,18.0)" %target_arch% "prerelease"
2651cb0ef41Sopenharmony_ciif "_%VCINSTALLDIR%_" == "__" goto vs-set-2019
2661cb0ef41Sopenharmony_ciset "WIXSDKDIR=%WIX%\SDK\VS2017"
2671cb0ef41Sopenharmony_ciif defined msi (
2681cb0ef41Sopenharmony_ci  echo Looking for WiX installation for Visual Studio 2022...
2691cb0ef41Sopenharmony_ci  if not exist "%WIXSDKDIR%" (
2701cb0ef41Sopenharmony_ci    echo Failed to find WiX install for Visual Studio 2022
2711cb0ef41Sopenharmony_ci    echo VS2022 support for WiX is only present starting at version 3.XX
2721cb0ef41Sopenharmony_ci    goto vs-set-2019
2731cb0ef41Sopenharmony_ci  )
2741cb0ef41Sopenharmony_ci  if not exist "%VCINSTALLDIR%\..\MSBuild\Microsoft\WiX" (
2751cb0ef41Sopenharmony_ci    echo Failed to find the WiX Toolset Visual Studio 2022 Extension
2761cb0ef41Sopenharmony_ci    goto vs-set-2019
2771cb0ef41Sopenharmony_ci  )
2781cb0ef41Sopenharmony_ci)
2791cb0ef41Sopenharmony_ci@rem check if VS2022 is already setup, and for the requested arch
2801cb0ef41Sopenharmony_ciif "_%VisualStudioVersion%_" == "_17.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%target_arch%_" goto found_vs2022
2811cb0ef41Sopenharmony_ci@rem need to clear VSINSTALLDIR for vcvarsall to work as expected
2821cb0ef41Sopenharmony_ciset "VSINSTALLDIR="
2831cb0ef41Sopenharmony_ci@rem prevent VsDevCmd.bat from changing the current working directory
2841cb0ef41Sopenharmony_ciset "VSCMD_START_DIR=%CD%"
2851cb0ef41Sopenharmony_ciset vcvars_call="%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %vcvarsall_arg%
2861cb0ef41Sopenharmony_ciecho calling: %vcvars_call%
2871cb0ef41Sopenharmony_cicall %vcvars_call%
2881cb0ef41Sopenharmony_ciif errorlevel 1 goto vs-set-2019
2891cb0ef41Sopenharmony_ciif defined DEBUG_HELPER @ECHO ON
2901cb0ef41Sopenharmony_ci:found_vs2022
2911cb0ef41Sopenharmony_ciecho Found MSVS version %VisualStudioVersion%
2921cb0ef41Sopenharmony_ciset GYP_MSVS_VERSION=2022
2931cb0ef41Sopenharmony_ciset PLATFORM_TOOLSET=v143
2941cb0ef41Sopenharmony_cigoto msbuild-found
2951cb0ef41Sopenharmony_ci
2961cb0ef41Sopenharmony_ci@rem Look for Visual Studio 2019
2971cb0ef41Sopenharmony_ci:vs-set-2019
2981cb0ef41Sopenharmony_ciif defined target_env if "%target_env%" NEQ "vs2019" goto msbuild-not-found
2991cb0ef41Sopenharmony_ciecho Looking for Visual Studio 2019
3001cb0ef41Sopenharmony_ci@rem VCINSTALLDIR may be set if run from a VS Command Prompt and needs to be
3011cb0ef41Sopenharmony_ci@rem cleared first as vswhere_usability_wrapper.cmd doesn't when it fails to
3021cb0ef41Sopenharmony_ci@rem detect the version searched for
3031cb0ef41Sopenharmony_ciif not defined target_env set "VCINSTALLDIR="
3041cb0ef41Sopenharmony_cicall tools\msvs\vswhere_usability_wrapper.cmd "[16.0,17.0)" %target_arch% "prerelease"
3051cb0ef41Sopenharmony_ciif "_%VCINSTALLDIR%_" == "__" goto msbuild-not-found
3061cb0ef41Sopenharmony_ciset "WIXSDKDIR=%WIX%\SDK\VS2017"
3071cb0ef41Sopenharmony_ciif defined msi (
3081cb0ef41Sopenharmony_ci  echo Looking for WiX installation for Visual Studio 2019...
3091cb0ef41Sopenharmony_ci  if not exist "%WIXSDKDIR%" (
3101cb0ef41Sopenharmony_ci    echo Failed to find WiX install for Visual Studio 2019
3111cb0ef41Sopenharmony_ci    echo VS2019 support for WiX is only present starting at version 3.11
3121cb0ef41Sopenharmony_ci    goto msbuild-not-found
3131cb0ef41Sopenharmony_ci  )
3141cb0ef41Sopenharmony_ci  if not exist "%VCINSTALLDIR%\..\MSBuild\Microsoft\WiX" (
3151cb0ef41Sopenharmony_ci    echo Failed to find the WiX Toolset Visual Studio 2019 Extension
3161cb0ef41Sopenharmony_ci    goto msbuild-not-found
3171cb0ef41Sopenharmony_ci  )
3181cb0ef41Sopenharmony_ci)
3191cb0ef41Sopenharmony_ci@rem check if VS2019 is already setup, and for the requested arch
3201cb0ef41Sopenharmony_ciif "_%VisualStudioVersion%_" == "_16.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%target_arch%_" goto found_vs2019
3211cb0ef41Sopenharmony_ci@rem need to clear VSINSTALLDIR for vcvarsall to work as expected
3221cb0ef41Sopenharmony_ciset "VSINSTALLDIR="
3231cb0ef41Sopenharmony_ci@rem prevent VsDevCmd.bat from changing the current working directory
3241cb0ef41Sopenharmony_ciset "VSCMD_START_DIR=%CD%"
3251cb0ef41Sopenharmony_ciset vcvars_call="%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %vcvarsall_arg%
3261cb0ef41Sopenharmony_ciecho calling: %vcvars_call%
3271cb0ef41Sopenharmony_cicall %vcvars_call%
3281cb0ef41Sopenharmony_ciif errorlevel 1 goto msbuild-not-found
3291cb0ef41Sopenharmony_ciif defined DEBUG_HELPER @ECHO ON
3301cb0ef41Sopenharmony_ci:found_vs2019
3311cb0ef41Sopenharmony_ciecho Found MSVS version %VisualStudioVersion%
3321cb0ef41Sopenharmony_ciset GYP_MSVS_VERSION=2019
3331cb0ef41Sopenharmony_ciset PLATFORM_TOOLSET=v142
3341cb0ef41Sopenharmony_cigoto msbuild-found
3351cb0ef41Sopenharmony_ci
3361cb0ef41Sopenharmony_ci:msbuild-not-found
3371cb0ef41Sopenharmony_ciecho Failed to find a suitable Visual Studio installation.
3381cb0ef41Sopenharmony_ciecho Try to run in a "Developer Command Prompt" or consult
3391cb0ef41Sopenharmony_ciecho https://github.com/nodejs/node/blob/HEAD/BUILDING.md#windows
3401cb0ef41Sopenharmony_cigoto exit
3411cb0ef41Sopenharmony_ci
3421cb0ef41Sopenharmony_ci:msbuild-found
3431cb0ef41Sopenharmony_ci
3441cb0ef41Sopenharmony_ciset project_generated=
3451cb0ef41Sopenharmony_ci:project-gen
3461cb0ef41Sopenharmony_ci@rem Skip project generation if requested.
3471cb0ef41Sopenharmony_ciif defined noprojgen goto msbuild
3481cb0ef41Sopenharmony_ciif defined projgen goto run-configure
3491cb0ef41Sopenharmony_ciif not exist node.sln goto run-configure
3501cb0ef41Sopenharmony_ciif not exist .gyp_configure_stamp goto run-configure
3511cb0ef41Sopenharmony_ciecho %configure_flags% > .tmp_gyp_configure_stamp
3521cb0ef41Sopenharmony_ciwhere /R . /T *.gyp* >> .tmp_gyp_configure_stamp
3531cb0ef41Sopenharmony_cifc .gyp_configure_stamp .tmp_gyp_configure_stamp >NUL 2>&1
3541cb0ef41Sopenharmony_ciif errorlevel 1 goto run-configure
3551cb0ef41Sopenharmony_ci
3561cb0ef41Sopenharmony_ci:skip-configure
3571cb0ef41Sopenharmony_cidel .tmp_gyp_configure_stamp 2> NUL
3581cb0ef41Sopenharmony_ciecho Reusing solution generated with %configure_flags%
3591cb0ef41Sopenharmony_cigoto msbuild
3601cb0ef41Sopenharmony_ci
3611cb0ef41Sopenharmony_ci:run-configure
3621cb0ef41Sopenharmony_cidel .tmp_gyp_configure_stamp 2> NUL
3631cb0ef41Sopenharmony_cidel .gyp_configure_stamp 2> NUL
3641cb0ef41Sopenharmony_ci@rem Generate the VS project.
3651cb0ef41Sopenharmony_ciecho configure %configure_flags%
3661cb0ef41Sopenharmony_ciecho %configure_flags%> .used_configure_flags
3671cb0ef41Sopenharmony_cipython configure %configure_flags%
3681cb0ef41Sopenharmony_ciif errorlevel 1 goto create-msvs-files-failed
3691cb0ef41Sopenharmony_ciif not exist node.sln goto create-msvs-files-failed
3701cb0ef41Sopenharmony_ciset project_generated=1
3711cb0ef41Sopenharmony_ciecho Project files generated.
3721cb0ef41Sopenharmony_ciecho %configure_flags% > .gyp_configure_stamp
3731cb0ef41Sopenharmony_ciwhere /R . /T *.gyp* >> .gyp_configure_stamp
3741cb0ef41Sopenharmony_ci
3751cb0ef41Sopenharmony_ci:msbuild
3761cb0ef41Sopenharmony_ci@rem Skip build if requested.
3771cb0ef41Sopenharmony_ciif defined nobuild goto :after-build
3781cb0ef41Sopenharmony_ci
3791cb0ef41Sopenharmony_ci@rem Build the sln with msbuild.
3801cb0ef41Sopenharmony_ciset "msbcpu=/m:2"
3811cb0ef41Sopenharmony_ciif "%NUMBER_OF_PROCESSORS%"=="1" set "msbcpu=/m:1"
3821cb0ef41Sopenharmony_ciset "msbplatform=Win32"
3831cb0ef41Sopenharmony_ciif "%target_arch%"=="x64" set "msbplatform=x64"
3841cb0ef41Sopenharmony_ciif "%target_arch%"=="arm64" set "msbplatform=ARM64"
3851cb0ef41Sopenharmony_ciif "%target%"=="Build" (
3861cb0ef41Sopenharmony_ci  if defined no_cctest set target=node
3871cb0ef41Sopenharmony_ci  if "%test_args%"=="" set target=node
3881cb0ef41Sopenharmony_ci  if defined cctest set target="Build"
3891cb0ef41Sopenharmony_ci)
3901cb0ef41Sopenharmony_ciif "%target%"=="node" if exist "%config%\cctest.exe" del "%config%\cctest.exe"
3911cb0ef41Sopenharmony_ciif defined msbuild_args set "extra_msbuild_args=%extra_msbuild_args% %msbuild_args%"
3921cb0ef41Sopenharmony_ci@rem Setup env variables to use multiprocessor build
3931cb0ef41Sopenharmony_ciset UseMultiToolTask=True
3941cb0ef41Sopenharmony_ciset EnforceProcessCountAcrossBuilds=True
3951cb0ef41Sopenharmony_ciset MultiProcMaxCount=%NUMBER_OF_PROCESSORS%
3961cb0ef41Sopenharmony_cimsbuild node.sln %msbcpu% /t:%target% /p:Configuration=%config% /p:Platform=%msbplatform% /clp:NoItemAndPropertyList;Verbosity=minimal /nologo %extra_msbuild_args%
3971cb0ef41Sopenharmony_ciif errorlevel 1 (
3981cb0ef41Sopenharmony_ci  if not defined project_generated echo Building Node with reused solution failed. To regenerate project files use "vcbuild projgen"
3991cb0ef41Sopenharmony_ci  exit /B 1
4001cb0ef41Sopenharmony_ci)
4011cb0ef41Sopenharmony_ciif "%target%" == "Clean" goto exit
4021cb0ef41Sopenharmony_ci
4031cb0ef41Sopenharmony_ci:after-build
4041cb0ef41Sopenharmony_cird %config%
4051cb0ef41Sopenharmony_ciif errorlevel 1 echo "Old build output exists at 'out\%config%'. Please remove." & exit /B
4061cb0ef41Sopenharmony_ci:: Use /J because /D (symlink) requires special permissions.
4071cb0ef41Sopenharmony_ciif EXIST out\%config% mklink /J %config% out\%config%
4081cb0ef41Sopenharmony_ciif errorlevel 1 echo "Could not create junction to 'out\%config%'." & exit /B
4091cb0ef41Sopenharmony_ci
4101cb0ef41Sopenharmony_ci:sign
4111cb0ef41Sopenharmony_ci@rem Skip signing unless the `sign` option was specified.
4121cb0ef41Sopenharmony_ciif not defined sign goto licensertf
4131cb0ef41Sopenharmony_ci
4141cb0ef41Sopenharmony_cicall tools\sign.bat Release\node.exe
4151cb0ef41Sopenharmony_ciif errorlevel 1 echo Failed to sign exe, got error code %errorlevel%&goto exit
4161cb0ef41Sopenharmony_ci
4171cb0ef41Sopenharmony_ci:licensertf
4181cb0ef41Sopenharmony_ci@rem Skip license.rtf generation if not requested.
4191cb0ef41Sopenharmony_ciif not defined licensertf goto stage_package
4201cb0ef41Sopenharmony_ci
4211cb0ef41Sopenharmony_ciset "use_x64_node_exe=false"
4221cb0ef41Sopenharmony_ciif "%target_arch%"=="arm64" if "%PROCESSOR_ARCHITECTURE%"=="AMD64" set "use_x64_node_exe=true"
4231cb0ef41Sopenharmony_ciset "x64_node_exe=temp-vcbuild\node-x64-cross-compiling.exe"
4241cb0ef41Sopenharmony_ciif "%use_x64_node_exe%"=="true" (
4251cb0ef41Sopenharmony_ci  echo Cross-compilation to ARM64 detected. We'll use the x64 Node executable for license2rtf.
4261cb0ef41Sopenharmony_ci  if not exist "%x64_node_exe%" (
4271cb0ef41Sopenharmony_ci    echo Downloading x64 node.exe...
4281cb0ef41Sopenharmony_ci    if not exist "temp-vcbuild" mkdir temp-vcbuild
4291cb0ef41Sopenharmony_ci    powershell -c "Invoke-WebRequest -Uri 'https://nodejs.org/dist/latest/win-x64/node.exe' -OutFile '%x64_node_exe%'"
4301cb0ef41Sopenharmony_ci  )
4311cb0ef41Sopenharmony_ci  if not exist "%x64_node_exe%" (
4321cb0ef41Sopenharmony_ci    echo Could not find the Node executable at the given x64_node_exe path. Aborting.
4331cb0ef41Sopenharmony_ci    set exit_code=1
4341cb0ef41Sopenharmony_ci    goto exit
4351cb0ef41Sopenharmony_ci  )
4361cb0ef41Sopenharmony_ci  %x64_node_exe% tools\license2rtf.mjs < LICENSE > %config%\license.rtf
4371cb0ef41Sopenharmony_ci) else (
4381cb0ef41Sopenharmony_ci  %node_exe% tools\license2rtf.mjs < LICENSE > %config%\license.rtf
4391cb0ef41Sopenharmony_ci)
4401cb0ef41Sopenharmony_ci
4411cb0ef41Sopenharmony_ciif errorlevel 1 echo Failed to generate license.rtf, got error code %errorlevel%&goto exit
4421cb0ef41Sopenharmony_ci
4431cb0ef41Sopenharmony_ci:stage_package
4441cb0ef41Sopenharmony_ciif not defined stage_package goto install-doctools
4451cb0ef41Sopenharmony_ci
4461cb0ef41Sopenharmony_ciecho Creating package...
4471cb0ef41Sopenharmony_cicd Release
4481cb0ef41Sopenharmony_cirmdir /S /Q %TARGET_NAME% > nul 2> nul
4491cb0ef41Sopenharmony_cimkdir %TARGET_NAME% > nul 2> nul
4501cb0ef41Sopenharmony_cimkdir %TARGET_NAME%\node_modules > nul 2>nul
4511cb0ef41Sopenharmony_ci
4521cb0ef41Sopenharmony_cicopy /Y node.exe %TARGET_NAME%\ > nul
4531cb0ef41Sopenharmony_ciif errorlevel 1 echo Cannot copy node.exe && goto package_error
4541cb0ef41Sopenharmony_cicopy /Y ..\LICENSE %TARGET_NAME%\ > nul
4551cb0ef41Sopenharmony_ciif errorlevel 1 echo Cannot copy LICENSE && goto package_error
4561cb0ef41Sopenharmony_cicopy /Y ..\README.md %TARGET_NAME%\ > nul
4571cb0ef41Sopenharmony_ciif errorlevel 1 echo Cannot copy README.md && goto package_error
4581cb0ef41Sopenharmony_cicopy /Y ..\CHANGELOG.md %TARGET_NAME%\ > nul
4591cb0ef41Sopenharmony_ciif errorlevel 1 echo Cannot copy CHANGELOG.md && goto package_error
4601cb0ef41Sopenharmony_ci
4611cb0ef41Sopenharmony_ciif not defined nonpm (
4621cb0ef41Sopenharmony_ci  robocopy ..\deps\npm %TARGET_NAME%\node_modules\npm /e /xd test > nul
4631cb0ef41Sopenharmony_ci  if errorlevel 8 echo Cannot copy npm package && goto package_error
4641cb0ef41Sopenharmony_ci  copy /Y ..\deps\npm\bin\npm %TARGET_NAME%\ > nul
4651cb0ef41Sopenharmony_ci  if errorlevel 1 echo Cannot copy npm && goto package_error
4661cb0ef41Sopenharmony_ci  copy /Y ..\deps\npm\bin\npm.cmd %TARGET_NAME%\ > nul
4671cb0ef41Sopenharmony_ci  if errorlevel 1 echo Cannot copy npm.cmd && goto package_error
4681cb0ef41Sopenharmony_ci  copy /Y ..\deps\npm\bin\npx %TARGET_NAME%\ > nul
4691cb0ef41Sopenharmony_ci  if errorlevel 1 echo Cannot copy npx && goto package_error
4701cb0ef41Sopenharmony_ci  copy /Y ..\deps\npm\bin\npx.cmd %TARGET_NAME%\ > nul
4711cb0ef41Sopenharmony_ci  if errorlevel 1 echo Cannot copy npx.cmd && goto package_error
4721cb0ef41Sopenharmony_ci)
4731cb0ef41Sopenharmony_ci
4741cb0ef41Sopenharmony_ciif not defined nocorepack (
4751cb0ef41Sopenharmony_ci  robocopy ..\deps\corepack %TARGET_NAME%\node_modules\corepack /e /xd test > nul
4761cb0ef41Sopenharmony_ci  if errorlevel 8 echo Cannot copy corepack package && goto package_error
4771cb0ef41Sopenharmony_ci  copy /Y ..\deps\corepack\shims\nodewin\corepack %TARGET_NAME%\ > nul
4781cb0ef41Sopenharmony_ci  if errorlevel 1 echo Cannot copy corepack && goto package_error
4791cb0ef41Sopenharmony_ci  copy /Y ..\deps\corepack\shims\nodewin\corepack.cmd %TARGET_NAME%\ > nul
4801cb0ef41Sopenharmony_ci  if errorlevel 1 echo Cannot copy corepack.cmd && goto package_error
4811cb0ef41Sopenharmony_ci)
4821cb0ef41Sopenharmony_ci
4831cb0ef41Sopenharmony_cicopy /Y ..\tools\msvs\nodevars.bat %TARGET_NAME%\ > nul
4841cb0ef41Sopenharmony_ciif errorlevel 1 echo Cannot copy nodevars.bat && goto package_error
4851cb0ef41Sopenharmony_cicopy /Y ..\tools\msvs\install_tools\*.* %TARGET_NAME%\ > nul
4861cb0ef41Sopenharmony_ciif errorlevel 1 echo Cannot copy install_tools scripts && goto package_error
4871cb0ef41Sopenharmony_ciif not defined noetw (
4881cb0ef41Sopenharmony_ci    copy /Y ..\src\res\node_etw_provider.man %TARGET_NAME%\ > nul
4891cb0ef41Sopenharmony_ci    if errorlevel 1 echo Cannot copy node_etw_provider.man && goto package_error
4901cb0ef41Sopenharmony_ci)
4911cb0ef41Sopenharmony_ciif defined dll (
4921cb0ef41Sopenharmony_ci  copy /Y libnode.dll %TARGET_NAME%\ > nul
4931cb0ef41Sopenharmony_ci  if errorlevel 1 echo Cannot copy libnode.dll && goto package_error
4941cb0ef41Sopenharmony_ci
4951cb0ef41Sopenharmony_ci  mkdir %TARGET_NAME%\Release > nul
4961cb0ef41Sopenharmony_ci  copy /Y node.def %TARGET_NAME%\Release\ > nul
4971cb0ef41Sopenharmony_ci  if errorlevel 1 echo Cannot copy node.def && goto package_error
4981cb0ef41Sopenharmony_ci
4991cb0ef41Sopenharmony_ci  set HEADERS_ONLY=1
5001cb0ef41Sopenharmony_ci  python ..\tools\install.py install %CD%\%TARGET_NAME% \ > nul
5011cb0ef41Sopenharmony_ci  if errorlevel 1 echo Cannot install headers && goto package_error
5021cb0ef41Sopenharmony_ci  set HEADERS_ONLY=
5031cb0ef41Sopenharmony_ci)
5041cb0ef41Sopenharmony_cicd ..
5051cb0ef41Sopenharmony_ci
5061cb0ef41Sopenharmony_ci:package
5071cb0ef41Sopenharmony_ciif not defined package goto msi
5081cb0ef41Sopenharmony_cicd Release
5091cb0ef41Sopenharmony_ciecho Creating %TARGET_NAME%.7z
5101cb0ef41Sopenharmony_cidel %TARGET_NAME%.7z > nul 2> nul
5111cb0ef41Sopenharmony_ci7z a -r -mx9 -t7z %TARGET_NAME%.7z %TARGET_NAME% > nul
5121cb0ef41Sopenharmony_ciif errorlevel 1 echo Cannot create %TARGET_NAME%.7z && goto package_error
5131cb0ef41Sopenharmony_ci
5141cb0ef41Sopenharmony_ciecho Creating %TARGET_NAME%.zip
5151cb0ef41Sopenharmony_cidel %TARGET_NAME%.zip > nul 2> nul
5161cb0ef41Sopenharmony_ci7z a -r -mx9 -tzip %TARGET_NAME%.zip %TARGET_NAME% > nul
5171cb0ef41Sopenharmony_ciif errorlevel 1 echo Cannot create %TARGET_NAME%.zip && goto package_error
5181cb0ef41Sopenharmony_ci
5191cb0ef41Sopenharmony_ciecho Creating node_pdb.7z
5201cb0ef41Sopenharmony_cidel node_pdb.7z > nul 2> nul
5211cb0ef41Sopenharmony_ci7z a -mx9 -t7z node_pdb.7z node.pdb > nul
5221cb0ef41Sopenharmony_ci
5231cb0ef41Sopenharmony_ciecho Creating node_pdb.zip
5241cb0ef41Sopenharmony_cidel node_pdb.zip  > nul 2> nul
5251cb0ef41Sopenharmony_ci7z a -mx9 -tzip node_pdb.zip node.pdb > nul
5261cb0ef41Sopenharmony_ci
5271cb0ef41Sopenharmony_cicd ..
5281cb0ef41Sopenharmony_ciecho Package created!
5291cb0ef41Sopenharmony_cigoto package_done
5301cb0ef41Sopenharmony_ci:package_error
5311cb0ef41Sopenharmony_cicd ..
5321cb0ef41Sopenharmony_ciexit /b 1
5331cb0ef41Sopenharmony_ci:package_done
5341cb0ef41Sopenharmony_ci
5351cb0ef41Sopenharmony_ci:msi
5361cb0ef41Sopenharmony_ci@rem Skip msi generation if not requested
5371cb0ef41Sopenharmony_ciif not defined msi goto install-doctools
5381cb0ef41Sopenharmony_ci
5391cb0ef41Sopenharmony_ci:msibuild
5401cb0ef41Sopenharmony_ciecho Building node-v%FULLVERSION%-%target_arch%.msi
5411cb0ef41Sopenharmony_ciset "msbsdk="
5421cb0ef41Sopenharmony_ciif defined WindowsSDKVersion set "msbsdk=/p:WindowsTargetPlatformVersion=%WindowsSDKVersion:~0,-1%"
5431cb0ef41Sopenharmony_cimsbuild "%~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
5441cb0ef41Sopenharmony_ciif errorlevel 1 goto exit
5451cb0ef41Sopenharmony_ci
5461cb0ef41Sopenharmony_ciif not defined sign goto upload
5471cb0ef41Sopenharmony_cicall tools\sign.bat node-v%FULLVERSION%-%target_arch%.msi
5481cb0ef41Sopenharmony_ciif errorlevel 1 echo Failed to sign msi, got error code %errorlevel%&goto exit
5491cb0ef41Sopenharmony_ci
5501cb0ef41Sopenharmony_ci:upload
5511cb0ef41Sopenharmony_ci@rem Skip upload if not requested
5521cb0ef41Sopenharmony_ciif not defined upload goto install-doctools
5531cb0ef41Sopenharmony_ci
5541cb0ef41Sopenharmony_ciif not defined SSHCONFIG (
5551cb0ef41Sopenharmony_ci  echo SSHCONFIG is not set for upload
5561cb0ef41Sopenharmony_ci  exit /b 1
5571cb0ef41Sopenharmony_ci)
5581cb0ef41Sopenharmony_ci
5591cb0ef41Sopenharmony_ciif not defined STAGINGSERVER set STAGINGSERVER=node-www
5601cb0ef41Sopenharmony_cissh -F %SSHCONFIG% %STAGINGSERVER% "mkdir -p nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%"
5611cb0ef41Sopenharmony_ciif errorlevel 1 goto exit
5621cb0ef41Sopenharmony_ciscp -F %SSHCONFIG% Release\node.exe %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%/node.exe
5631cb0ef41Sopenharmony_ciif errorlevel 1 goto exit
5641cb0ef41Sopenharmony_ciscp -F %SSHCONFIG% Release\node.lib %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%/node.lib
5651cb0ef41Sopenharmony_ciif errorlevel 1 goto exit
5661cb0ef41Sopenharmony_ciscp -F %SSHCONFIG% Release\node_pdb.zip %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%/node_pdb.zip
5671cb0ef41Sopenharmony_ciif errorlevel 1 goto exit
5681cb0ef41Sopenharmony_ciscp -F %SSHCONFIG% Release\node_pdb.7z %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%/node_pdb.7z
5691cb0ef41Sopenharmony_ciif errorlevel 1 goto exit
5701cb0ef41Sopenharmony_ciscp -F %SSHCONFIG% Release\%TARGET_NAME%.7z %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/%TARGET_NAME%.7z
5711cb0ef41Sopenharmony_ciif errorlevel 1 goto exit
5721cb0ef41Sopenharmony_ciscp -F %SSHCONFIG% Release\%TARGET_NAME%.zip %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/%TARGET_NAME%.zip
5731cb0ef41Sopenharmony_ciif errorlevel 1 goto exit
5741cb0ef41Sopenharmony_ciscp -F %SSHCONFIG% node-v%FULLVERSION%-%target_arch%.msi %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/
5751cb0ef41Sopenharmony_ciif errorlevel 1 goto exit
5761cb0ef41Sopenharmony_cissh -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%*"
5771cb0ef41Sopenharmony_ciif errorlevel 1 goto exit
5781cb0ef41Sopenharmony_ci
5791cb0ef41Sopenharmony_ci
5801cb0ef41Sopenharmony_ci:install-doctools
5811cb0ef41Sopenharmony_ciREM only install if building doc OR testing doctool OR building addons
5821cb0ef41Sopenharmony_ciif not defined doc if not defined build_addons (
5831cb0ef41Sopenharmony_ci  echo.%test_args% | findstr doctool 1>nul
5841cb0ef41Sopenharmony_ci  if errorlevel 1 goto :skip-install-doctools
5851cb0ef41Sopenharmony_ci)
5861cb0ef41Sopenharmony_ciif exist "tools\doc\node_modules\unified\package.json" goto skip-install-doctools
5871cb0ef41Sopenharmony_ciSETLOCAL
5881cb0ef41Sopenharmony_cicd tools\doc
5891cb0ef41Sopenharmony_ci%npm_exe% ci
5901cb0ef41Sopenharmony_cicd ..\..
5911cb0ef41Sopenharmony_ciif errorlevel 1 goto exit
5921cb0ef41Sopenharmony_ciENDLOCAL
5931cb0ef41Sopenharmony_ci:skip-install-doctools
5941cb0ef41Sopenharmony_ci@rem Clear errorlevel from echo.%test_args% | findstr doctool 1>nul
5951cb0ef41Sopenharmony_cicd .
5961cb0ef41Sopenharmony_ci
5971cb0ef41Sopenharmony_ci:build-doc
5981cb0ef41Sopenharmony_ci@rem Build documentation if requested
5991cb0ef41Sopenharmony_ciif not defined doc goto run
6001cb0ef41Sopenharmony_ciif not exist %node_exe% (
6011cb0ef41Sopenharmony_ci  echo Failed to find node.exe
6021cb0ef41Sopenharmony_ci  goto run
6031cb0ef41Sopenharmony_ci)
6041cb0ef41Sopenharmony_cimkdir %config%\doc
6051cb0ef41Sopenharmony_cirobocopy /e doc\api %config%\doc\api
6061cb0ef41Sopenharmony_cirobocopy /e doc\api_assets %config%\doc\api\assets
6071cb0ef41Sopenharmony_ci
6081cb0ef41Sopenharmony_cifor %%F in (%config%\doc\api\*.md) do (
6091cb0ef41Sopenharmony_ci  %node_exe% tools\doc\generate.mjs --node-version=v%FULLVERSION% %%F --output-directory=%%~dF%%~pF
6101cb0ef41Sopenharmony_ci)
6111cb0ef41Sopenharmony_ci
6121cb0ef41Sopenharmony_ci:run
6131cb0ef41Sopenharmony_ci@rem Run tests if requested.
6141cb0ef41Sopenharmony_ci
6151cb0ef41Sopenharmony_ciif not defined build_addons goto build-js-native-api-tests
6161cb0ef41Sopenharmony_ciif not exist "%node_exe%" (
6171cb0ef41Sopenharmony_ci  echo Failed to find node.exe
6181cb0ef41Sopenharmony_ci  goto build-js-native-api-tests
6191cb0ef41Sopenharmony_ci)
6201cb0ef41Sopenharmony_ciecho Building addons
6211cb0ef41Sopenharmony_ci:: clear
6221cb0ef41Sopenharmony_cifor /d %%F in (test\addons\??_*) do (
6231cb0ef41Sopenharmony_ci  rd /s /q %%F
6241cb0ef41Sopenharmony_ci)
6251cb0ef41Sopenharmony_ci:: generate
6261cb0ef41Sopenharmony_ci"%node_exe%" tools\doc\addon-verify.mjs
6271cb0ef41Sopenharmony_ciif %errorlevel% neq 0 exit /b %errorlevel%
6281cb0ef41Sopenharmony_ci:: building addons
6291cb0ef41Sopenharmony_cisetlocal
6301cb0ef41Sopenharmony_ciset npm_config_nodedir=%~dp0
6311cb0ef41Sopenharmony_ci"%node_exe%" "%~dp0tools\build-addons.mjs" "%~dp0deps\npm\node_modules\node-gyp\bin\node-gyp.js" "%~dp0test\addons"
6321cb0ef41Sopenharmony_ciif errorlevel 1 exit /b 1
6331cb0ef41Sopenharmony_ciendlocal
6341cb0ef41Sopenharmony_ci
6351cb0ef41Sopenharmony_ci:build-js-native-api-tests
6361cb0ef41Sopenharmony_ciif not defined build_js_native_api_tests goto build-node-api-tests
6371cb0ef41Sopenharmony_ciif not exist "%node_exe%" (
6381cb0ef41Sopenharmony_ci  echo Failed to find node.exe
6391cb0ef41Sopenharmony_ci  goto build-node-api-tests
6401cb0ef41Sopenharmony_ci)
6411cb0ef41Sopenharmony_ciecho Building js-native-api
6421cb0ef41Sopenharmony_ci:: clear
6431cb0ef41Sopenharmony_cifor /d %%F in (test\js-native-api\??_*) do (
6441cb0ef41Sopenharmony_ci  rd /s /q %%F
6451cb0ef41Sopenharmony_ci)
6461cb0ef41Sopenharmony_ci:: building js-native-api
6471cb0ef41Sopenharmony_cisetlocal
6481cb0ef41Sopenharmony_ciset npm_config_nodedir=%~dp0
6491cb0ef41Sopenharmony_ci"%node_exe%" "%~dp0tools\build-addons.mjs" "%~dp0deps\npm\node_modules\node-gyp\bin\node-gyp.js" "%~dp0test\js-native-api"
6501cb0ef41Sopenharmony_ciif errorlevel 1 exit /b 1
6511cb0ef41Sopenharmony_ciendlocal
6521cb0ef41Sopenharmony_cigoto build-node-api-tests
6531cb0ef41Sopenharmony_ci
6541cb0ef41Sopenharmony_ci:build-node-api-tests
6551cb0ef41Sopenharmony_ciif not defined build_node_api_tests goto run-tests
6561cb0ef41Sopenharmony_ciif not exist "%node_exe%" (
6571cb0ef41Sopenharmony_ci  echo Failed to find node.exe
6581cb0ef41Sopenharmony_ci  goto run-tests
6591cb0ef41Sopenharmony_ci)
6601cb0ef41Sopenharmony_ciecho Building node-api
6611cb0ef41Sopenharmony_ci:: clear
6621cb0ef41Sopenharmony_cifor /d %%F in (test\node-api\??_*) do (
6631cb0ef41Sopenharmony_ci  rd /s /q %%F
6641cb0ef41Sopenharmony_ci)
6651cb0ef41Sopenharmony_ci:: building node-api
6661cb0ef41Sopenharmony_cisetlocal
6671cb0ef41Sopenharmony_ciset npm_config_nodedir=%~dp0
6681cb0ef41Sopenharmony_ci"%node_exe%" "%~dp0tools\build-addons.mjs" "%~dp0deps\npm\node_modules\node-gyp\bin\node-gyp.js" "%~dp0test\node-api"
6691cb0ef41Sopenharmony_ciif errorlevel 1 exit /b 1
6701cb0ef41Sopenharmony_ciendlocal
6711cb0ef41Sopenharmony_cigoto run-tests
6721cb0ef41Sopenharmony_ci
6731cb0ef41Sopenharmony_ci:run-tests
6741cb0ef41Sopenharmony_ciif defined test_check_deopts goto node-check-deopts
6751cb0ef41Sopenharmony_ciif defined test_node_inspect goto node-test-inspect
6761cb0ef41Sopenharmony_cigoto node-tests
6771cb0ef41Sopenharmony_ci
6781cb0ef41Sopenharmony_ci:node-check-deopts
6791cb0ef41Sopenharmony_cipython tools\test.py --mode=release --check-deopts parallel sequential
6801cb0ef41Sopenharmony_ciif defined test_node_inspect goto node-test-inspect
6811cb0ef41Sopenharmony_cigoto node-tests
6821cb0ef41Sopenharmony_ci
6831cb0ef41Sopenharmony_ci:node-test-inspect
6841cb0ef41Sopenharmony_ciset USE_EMBEDDED_NODE_INSPECT=1
6851cb0ef41Sopenharmony_ci%node_exe% tools\test-npm-package.js --install deps\node-inspect test
6861cb0ef41Sopenharmony_cigoto node-tests
6871cb0ef41Sopenharmony_ci
6881cb0ef41Sopenharmony_ci:node-tests
6891cb0ef41Sopenharmony_ciif not defined test_npm goto no-test-npm
6901cb0ef41Sopenharmony_ciset npm_test_cmd="%node_exe%" tools\test-npm-package.js --install --logfile=test-npm.tap deps\npm test-node
6911cb0ef41Sopenharmony_ciecho %npm_test_cmd%
6921cb0ef41Sopenharmony_ci%npm_test_cmd%
6931cb0ef41Sopenharmony_ciif errorlevel 1 goto exit
6941cb0ef41Sopenharmony_ci:no-test-npm
6951cb0ef41Sopenharmony_ci
6961cb0ef41Sopenharmony_ciif "%test_args%"=="" goto test-v8
6971cb0ef41Sopenharmony_ciif "%config%"=="Debug" set test_args=--mode=debug %test_args%
6981cb0ef41Sopenharmony_ciif "%config%"=="Release" set test_args=--mode=release %test_args%
6991cb0ef41Sopenharmony_ciif defined no_cctest echo Skipping cctest because no-cctest was specified && goto run-test-py
7001cb0ef41Sopenharmony_ciif not exist "%config%\cctest.exe" echo cctest.exe not found. Run "vcbuild test" or "vcbuild cctest" to build it. && goto run-test-py
7011cb0ef41Sopenharmony_ciecho running 'cctest %cctest_args%'
7021cb0ef41Sopenharmony_ci"%config%\cctest" %cctest_args%
7031cb0ef41Sopenharmony_ciif %errorlevel% neq 0 set exit_code=%errorlevel%
7041cb0ef41Sopenharmony_ci:run-test-py
7051cb0ef41Sopenharmony_ciecho running 'python tools\test.py %test_args%'
7061cb0ef41Sopenharmony_cipython tools\test.py %test_args%
7071cb0ef41Sopenharmony_ciif %errorlevel% neq 0 set exit_code=%errorlevel%
7081cb0ef41Sopenharmony_cigoto test-v8
7091cb0ef41Sopenharmony_ci
7101cb0ef41Sopenharmony_ci:test-v8
7111cb0ef41Sopenharmony_ciif not defined custom_v8_test goto lint-cpp
7121cb0ef41Sopenharmony_cicall tools/test-v8.bat
7131cb0ef41Sopenharmony_ciif errorlevel 1 goto exit
7141cb0ef41Sopenharmony_cigoto lint-cpp
7151cb0ef41Sopenharmony_ci
7161cb0ef41Sopenharmony_ci:lint-cpp
7171cb0ef41Sopenharmony_ciif not defined lint_cpp goto lint-js
7181cb0ef41Sopenharmony_ciif defined NODEJS_MAKE goto run-make-lint
7191cb0ef41Sopenharmony_ciwhere make > NUL 2>&1 && make -v | findstr /C:"GNU Make" 1> NUL
7201cb0ef41Sopenharmony_ciif "%ERRORLEVEL%"=="0" set "NODEJS_MAKE=make PYTHON=python" & goto run-make-lint
7211cb0ef41Sopenharmony_ciwhere wsl > NUL 2>&1
7221cb0ef41Sopenharmony_ciif "%ERRORLEVEL%"=="0" set "NODEJS_MAKE=wsl make" & goto run-make-lint
7231cb0ef41Sopenharmony_ciecho Could not find GNU Make, needed for linting C/C++
7241cb0ef41Sopenharmony_cigoto lint-js
7251cb0ef41Sopenharmony_ci
7261cb0ef41Sopenharmony_ci:run-make-lint
7271cb0ef41Sopenharmony_ci%NODEJS_MAKE% lint-cpp
7281cb0ef41Sopenharmony_cigoto lint-js
7291cb0ef41Sopenharmony_ci
7301cb0ef41Sopenharmony_ci:lint-js
7311cb0ef41Sopenharmony_ciif not defined lint_js goto lint-md-build
7321cb0ef41Sopenharmony_ciif not exist tools\node_modules\eslint goto no-lint
7331cb0ef41Sopenharmony_ciecho running lint-js
7341cb0ef41Sopenharmony_ci%node_exe% tools\node_modules\eslint\bin\eslint.js --cache --max-warnings=0 --report-unused-disable-directives --rule "linebreak-style: 0" .eslintrc.js benchmark doc lib test tools
7351cb0ef41Sopenharmony_cigoto lint-md-build
7361cb0ef41Sopenharmony_ci
7371cb0ef41Sopenharmony_ci:no-lint
7381cb0ef41Sopenharmony_ciecho Linting is not available through the source tarball.
7391cb0ef41Sopenharmony_ciecho Use the git repo instead: $ git clone https://github.com/nodejs/node.git
7401cb0ef41Sopenharmony_cigoto lint-md-build
7411cb0ef41Sopenharmony_ci
7421cb0ef41Sopenharmony_ci:lint-md-build
7431cb0ef41Sopenharmony_ciif not defined lint_md_build goto lint-md
7441cb0ef41Sopenharmony_ciecho "Deprecated no-op target 'lint_md_build'"
7451cb0ef41Sopenharmony_cigoto lint-md
7461cb0ef41Sopenharmony_ci
7471cb0ef41Sopenharmony_ci:lint-md
7481cb0ef41Sopenharmony_ciif not defined lint_md goto exit
7491cb0ef41Sopenharmony_ciecho Running Markdown linter on docs...
7501cb0ef41Sopenharmony_ciSETLOCAL ENABLEDELAYEDEXPANSION
7511cb0ef41Sopenharmony_ciset lint_md_files=
7521cb0ef41Sopenharmony_cifor /D %%D IN (doc\*) do (
7531cb0ef41Sopenharmony_ci  for %%F IN (%%D\*.md) do (
7541cb0ef41Sopenharmony_ci    set "lint_md_files="%%F" !lint_md_files!"
7551cb0ef41Sopenharmony_ci  )
7561cb0ef41Sopenharmony_ci)
7571cb0ef41Sopenharmony_ci%node_exe% tools\lint-md\lint-md.mjs %lint_md_files%
7581cb0ef41Sopenharmony_ciENDLOCAL
7591cb0ef41Sopenharmony_cigoto exit
7601cb0ef41Sopenharmony_ci
7611cb0ef41Sopenharmony_ci:format-md
7621cb0ef41Sopenharmony_ciif not defined lint_md goto exit
7631cb0ef41Sopenharmony_ciecho Running Markdown formatter on docs...
7641cb0ef41Sopenharmony_ciSETLOCAL ENABLEDELAYEDEXPANSION
7651cb0ef41Sopenharmony_ciset lint_md_files=
7661cb0ef41Sopenharmony_cifor /D %%D IN (doc\*) do (
7671cb0ef41Sopenharmony_ci  for %%F IN (%%D\*.md) do (
7681cb0ef41Sopenharmony_ci    set "lint_md_files="%%F" !lint_md_files!"
7691cb0ef41Sopenharmony_ci  )
7701cb0ef41Sopenharmony_ci)
7711cb0ef41Sopenharmony_ci%node_exe% tools\lint-md\lint-md.mjs --format %lint_md_files%
7721cb0ef41Sopenharmony_ciENDLOCAL
7731cb0ef41Sopenharmony_cigoto exit
7741cb0ef41Sopenharmony_ci
7751cb0ef41Sopenharmony_ci:create-msvs-files-failed
7761cb0ef41Sopenharmony_ciecho Failed to create vc project files.
7771cb0ef41Sopenharmony_cidel .used_configure_flags
7781cb0ef41Sopenharmony_ciset exit_code=1
7791cb0ef41Sopenharmony_cigoto exit
7801cb0ef41Sopenharmony_ci
7811cb0ef41Sopenharmony_ci:help
7821cb0ef41Sopenharmony_ciecho 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] [nonpm] [nocorepack] [noetw] [ltcg] [licensetf] [sign] [ia32/x86/x64/arm64] [vs2019/vs2022] [download-all] [enable-vtune] [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]
7831cb0ef41Sopenharmony_ciecho Examples:
7841cb0ef41Sopenharmony_ciecho   vcbuild.bat                          : builds release build
7851cb0ef41Sopenharmony_ciecho   vcbuild.bat debug                    : builds debug build
7861cb0ef41Sopenharmony_ciecho   vcbuild.bat release msi              : builds release build and MSI installer package
7871cb0ef41Sopenharmony_ciecho   vcbuild.bat test                     : builds debug build and runs tests
7881cb0ef41Sopenharmony_ciecho   vcbuild.bat build-release            : builds the release distribution as used by nodejs.org
7891cb0ef41Sopenharmony_ciecho   vcbuild.bat enable-vtune             : builds Node.js with Intel VTune profiling support to profile JavaScript
7901cb0ef41Sopenharmony_ciecho   vcbuild.bat link-module my_module.js : bundles my_module as built-in module
7911cb0ef41Sopenharmony_ciecho   vcbuild.bat lint                     : runs the C++, documentation and JavaScript linter
7921cb0ef41Sopenharmony_ciecho   vcbuild.bat no-cctest                : skip building cctest.exe
7931cb0ef41Sopenharmony_cigoto exit
7941cb0ef41Sopenharmony_ci
7951cb0ef41Sopenharmony_ci:exit
7961cb0ef41Sopenharmony_ciif %errorlevel% neq 0 exit /b %errorlevel%
7971cb0ef41Sopenharmony_ciexit /b %exit_code%
7981cb0ef41Sopenharmony_ci
7991cb0ef41Sopenharmony_ci
8001cb0ef41Sopenharmony_cirem ***************
8011cb0ef41Sopenharmony_cirem   Subroutines
8021cb0ef41Sopenharmony_cirem ***************
8031cb0ef41Sopenharmony_ci
8041cb0ef41Sopenharmony_ci:getnodeversion
8051cb0ef41Sopenharmony_ciset NODE_VERSION=
8061cb0ef41Sopenharmony_ciset TAG=
8071cb0ef41Sopenharmony_ciset FULLVERSION=
8081cb0ef41Sopenharmony_ci
8091cb0ef41Sopenharmony_cifor /F "usebackq tokens=*" %%i in (`python "%~dp0tools\getnodeversion.py"`) do set NODE_VERSION=%%i
8101cb0ef41Sopenharmony_ciif not defined NODE_VERSION (
8111cb0ef41Sopenharmony_ci  echo Cannot determine current version of Node.js
8121cb0ef41Sopenharmony_ci  exit /b 1
8131cb0ef41Sopenharmony_ci)
8141cb0ef41Sopenharmony_ci
8151cb0ef41Sopenharmony_ciif not defined DISTTYPE set DISTTYPE=release
8161cb0ef41Sopenharmony_ciif "%DISTTYPE%"=="release" (
8171cb0ef41Sopenharmony_ci  set FULLVERSION=%NODE_VERSION%
8181cb0ef41Sopenharmony_ci  goto distexit
8191cb0ef41Sopenharmony_ci)
8201cb0ef41Sopenharmony_ciif "%DISTTYPE%"=="custom" (
8211cb0ef41Sopenharmony_ci  if not defined CUSTOMTAG (
8221cb0ef41Sopenharmony_ci    echo "CUSTOMTAG is not set for DISTTYPE=custom"
8231cb0ef41Sopenharmony_ci    exit /b 1
8241cb0ef41Sopenharmony_ci  )
8251cb0ef41Sopenharmony_ci  set TAG=%CUSTOMTAG%
8261cb0ef41Sopenharmony_ci)
8271cb0ef41Sopenharmony_ciif not "%DISTTYPE%"=="custom" (
8281cb0ef41Sopenharmony_ci  if not defined DATESTRING (
8291cb0ef41Sopenharmony_ci    echo "DATESTRING is not set for nightly"
8301cb0ef41Sopenharmony_ci    exit /b 1
8311cb0ef41Sopenharmony_ci  )
8321cb0ef41Sopenharmony_ci  if not defined COMMIT (
8331cb0ef41Sopenharmony_ci    echo "COMMIT is not set for nightly"
8341cb0ef41Sopenharmony_ci    exit /b 1
8351cb0ef41Sopenharmony_ci  )
8361cb0ef41Sopenharmony_ci  if not "%DISTTYPE%"=="nightly" (
8371cb0ef41Sopenharmony_ci    if not "%DISTTYPE%"=="next-nightly" (
8381cb0ef41Sopenharmony_ci      echo "DISTTYPE is not release, custom, nightly or next-nightly"
8391cb0ef41Sopenharmony_ci      exit /b 1
8401cb0ef41Sopenharmony_ci    )
8411cb0ef41Sopenharmony_ci  )
8421cb0ef41Sopenharmony_ci  set TAG=%DISTTYPE%%DATESTRING%%COMMIT%
8431cb0ef41Sopenharmony_ci)
8441cb0ef41Sopenharmony_ciset FULLVERSION=%NODE_VERSION%-%TAG%
8451cb0ef41Sopenharmony_ci
8461cb0ef41Sopenharmony_ci:distexit
8471cb0ef41Sopenharmony_ciif not defined DISTTYPEDIR set DISTTYPEDIR=%DISTTYPE%
8481cb0ef41Sopenharmony_ciset TARGET_NAME=node-v%FULLVERSION%-win-%target_arch%
8491cb0ef41Sopenharmony_cigoto :EOF
850