Skip to content

Commit cfad441

Browse files
seishunbzoz
authored andcommitted
build,win: replace run-python subroutine with single find_python call
A subroutine does not work as a replacement for the `python` command since one cannot use a subroutine call in a `for /F` loop. PR-URL: #18621 Reviewed-By: Bartosz Sosnowski <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent 28dc56d commit cfad441

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

vcbuild.bat

+12-16
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ if "%target%"=="Clean" echo deleting %~dp0deps\icu
165165
if "%target%"=="Clean" rmdir /S /Q %~dp0deps\icu
166166
:no-depsicu
167167

168+
call tools\msvs\find_python.cmd
169+
if errorlevel 1 echo Could not find python2 & goto :exit
170+
168171
call :getnodeversion || exit /b 1
169172

170173
if defined TAG set configure_flags=%configure_flags% --tag=%TAG%
@@ -234,7 +237,8 @@ goto run
234237
if defined noprojgen goto msbuild
235238

236239
@rem Generate the VS project.
237-
call :run-python configure %configure_flags%
240+
echo configure %configure_flags%
241+
python configure %configure_flags%
238242
if errorlevel 1 goto create-msvs-files-failed
239243
if not exist node.sln goto create-msvs-files-failed
240244
echo Project files generated.
@@ -426,7 +430,7 @@ if defined test_node_inspect goto node-test-inspect
426430
goto node-tests
427431

428432
:node-check-deopts
429-
call :run-python tools\test.py --mode=release --check-deopts parallel sequential -J
433+
python tools\test.py --mode=release --check-deopts parallel sequential -J
430434
if defined test_node_inspect goto node-test-inspect
431435
goto node-tests
432436

@@ -450,7 +454,8 @@ if defined no_cctest echo Skipping cctest because no-cctest was specified && got
450454
echo running 'cctest %cctest_args%'
451455
"%config%\cctest" %cctest_args%
452456
:run-test-py
453-
call :run-python tools\test.py %test_args%
457+
echo running 'python tools\test.py %test_args%'
458+
python tools\test.py %test_args%
454459
goto test-v8
455460

456461
:test-v8
@@ -462,7 +467,7 @@ goto lint-cpp
462467
:lint-cpp
463468
if not defined lint_cpp goto lint-js
464469
call :run-lint-cpp src\*.c src\*.cc src\*.h test\addons\*.cc test\addons\*.h test\addons-napi\*.cc test\addons-napi\*.h test\cctest\*.cc test\cctest\*.h test\gc\binding.cc tools\icu\*.cc tools\icu\*.h
465-
call :run-python tools/check-imports.py
470+
python tools/check-imports.py
466471
goto lint-js
467472

468473
:run-lint-cpp
@@ -478,7 +483,7 @@ for /f "tokens=*" %%G in ('dir /b /s /a %*') do (
478483
( endlocal
479484
set cppfilelist=%localcppfilelist%
480485
)
481-
call :run-python tools/cpplint.py %cppfilelist% > nul
486+
python tools/cpplint.py %cppfilelist% > nul
482487
goto exit
483488

484489
:add-to-list
@@ -540,14 +545,6 @@ echo vcbuild.bat lint : runs the C++ and JavaScript linter
540545
echo vcbuild.bat no-cctest : skip building cctest.exe
541546
goto exit
542547

543-
:run-python
544-
call tools\msvs\find_python.cmd
545-
if errorlevel 1 echo Could not find python2 & goto :exit
546-
set cmd1="%VCBUILD_PYTHON_LOCATION%" %*
547-
echo %cmd1%
548-
%cmd1%
549-
exit /b %ERRORLEVEL%
550-
551548
:exit
552549
goto :EOF
553550

@@ -560,9 +557,8 @@ rem ***************
560557
set NODE_VERSION=
561558
set TAG=
562559
set FULLVERSION=
563-
:: Call as subroutine for validation of python
564-
call :run-python tools\getnodeversion.py > nul
565-
for /F "tokens=*" %%i in ('"%VCBUILD_PYTHON_LOCATION%" tools\getnodeversion.py') do set NODE_VERSION=%%i
560+
561+
for /F "usebackq tokens=*" %%i in (`python "%~dp0tools\getnodeversion.py"`) do set NODE_VERSION=%%i
566562
if not defined NODE_VERSION (
567563
echo Cannot determine current version of Node.js
568564
exit /b 1

0 commit comments

Comments
 (0)