Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: better error message on python fail #17298

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions tools/msvs/find_python.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
@IF NOT DEFINED DEBUG_HELPER @ECHO OFF
IF NOT "%VCBUILD_PYTHON_LOCATION%"=="" EXIT /B
SETLOCAL
:: If python.exe is in %Path%, just validate
FOR /F "delims=" %%a IN ('where python 2^> NUL') DO (
FOR /F "delims=" %%a IN ('where python') DO (
SET need_path=0
SET p=%%~dpa
IF NOT ERRORLEVEL 1 GOTO :validate
Expand All @@ -19,7 +20,7 @@ EXIT /B 1
:: Helper subroutine to handle quotes in %1
:find-main-branch
SET main_key="%~1\Python\PythonCore"
REG QUERY %main_key% /s | findstr "2." | findstr InstallPath > NUL 2> NUL
REG QUERY %main_key% /s | findstr "2." | findstr InstallPath
IF NOT ERRORLEVEL 1 CALL :find-key %main_key%
EXIT /B

Expand All @@ -41,7 +42,7 @@ EXIT /B 1
:validate
IF NOT EXIST "%p%python.exe" EXIT /B 1
:: Check if %p% is python2
"%p%python.exe" -V 2>&1 | findstr /R "^Python.2.*" > NUL
"%p%python.exe" -V 2>&1 | findstr /R "^Python.2.*"
IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL%
:: We can wrap it up
ENDLOCAL & SET pt=%p%& SET need_path_ext=%need_path%
Expand Down
31 changes: 22 additions & 9 deletions vcbuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ set nghttp2_debug=
set link_module=

:next-arg
if "%1"=="" goto args-done
if "%1"=="" goto environment-validate
if /i "%1"=="debug" set config=Debug&goto arg-ok
if /i "%1"=="release" set config=Release&goto arg-ok
if /i "%1"=="clean" set target=Clean&goto arg-ok
Expand Down Expand Up @@ -125,8 +125,17 @@ shift
shift
goto next-arg

:args-done
:environment-validate
REM Make sure we can find python
call :run-python --version > NUL 2>&1
if errorlevel 1 (
echo Could not find python2. More information can be found at
echo https://github.com/nodejs/node/blob/master/BUILDING.md#windows-1
exit /b 1
)


REM Shortcut for just linting (does not need python)
if "%*"=="lint" (
goto lint-cpp
)
Expand Down Expand Up @@ -167,14 +176,14 @@ if "%i18n_arg%"=="without-intl" set configure_flags=%configure_flags% --without-

if defined config_flags set configure_flags=%configure_flags% %config_flags%

if not "%target%"=="Clean" goto no-clean
if not exist "%~dp0deps\icu" goto no-depsicu
if "%target%"=="Clean" echo deleting %~dp0deps\icu
if "%target%"=="Clean" rmdir /S /Q %~dp0deps\icu
:no-depsicu

call :getnodeversion || exit /b 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The next line uses FULLVERSION which is populated in getnodeversion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by making the rmdir line more generic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%TAG% is used in project-gen too.


if "%target%"=="Clean" rmdir /Q /S "%~dp0%config%\node-v%FULLVERSION%-win-%target_arch%" > nul 2> nul
for /d %%I IN ("%~dp0%config%\node-v*") do rmdir /Q /S "%%I"
:no-clean

if defined noprojgen if defined nobuild if not defined sign if not defined msi goto licensertf

Expand Down Expand Up @@ -354,6 +363,7 @@ if not defined msi goto run

:msibuild
echo Building node-v%FULLVERSION%-%target_arch%.msi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't %FULLVERSION% set by getnodeversion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also in :package

call :getnodeversion || exit /b 1
msbuild "%~dp0tools\msvs\msi\nodemsi.sln" /m /t:Clean,Build /p:PlatformToolset=%PLATFORM_TOOLSET% /p:GypMsvsVersion=%GYP_MSVS_VERSION% /p:Configuration=%config% /p:Platform=%target_arch% /p:NodeVersion=%NODE_VERSION% /p:FullVersion=%FULLVERSION% /p:DistTypeDir=%DISTTYPEDIR% %noetw_msi_arg% %noperfctr_msi_arg% /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
if errorlevel 1 goto exit

Expand Down Expand Up @@ -556,8 +566,13 @@ echo vcbuild.bat lint : runs the C++ and JavaScript linter
goto exit

:run-python
call tools\msvs\find_python.cmd
if errorlevel 1 echo Could not find python2 & goto :exit
IF NOT DEFINED DEBUG_HELPER (
call tools\msvs\find_python.cmd 1>NUL 2>&1
) ELSE (
call tools\msvs\find_python.cmd
)
if errorlevel 1 exit /b 1

set cmd1="%VCBUILD_PYTHON_LOCATION%" %*
echo %cmd1%
%cmd1%
Expand All @@ -575,8 +590,6 @@ rem ***************
set NODE_VERSION=
set TAG=
set FULLVERSION=
:: Call as subroutine for validation of python
call :run-python tools\getnodeversion.py > nul
for /F "tokens=*" %%i in ('"%VCBUILD_PYTHON_LOCATION%" tools\getnodeversion.py') do set NODE_VERSION=%%i
if not defined NODE_VERSION (
echo Cannot determine current version of Node.js
Expand Down