From 6a10eb582cd553bc949ad3cd7a01385e2e4d8ba0 Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Sat, 25 Nov 2017 14:15:03 -0500 Subject: [PATCH 1/3] build: better error message on python fail --- tools/msvs/find_python.cmd | 7 ++++--- vcbuild.bat | 23 +++++++++++++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/tools/msvs/find_python.cmd b/tools/msvs/find_python.cmd index f2a779290e8104..e542912760b648 100644 --- a/tools/msvs/find_python.cmd +++ b/tools/msvs/find_python.cmd @@ -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 @@ -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 @@ -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% diff --git a/vcbuild.bat b/vcbuild.bat index d2683f99887cc0..3b1b711b1de88d 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -127,10 +127,19 @@ goto next-arg :args-done +REM Shortcut for just linting (does not need python) if "%*"=="lint" ( goto lint-cpp ) +REM Make sure we can find python +call :run-python --version > NUL +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 +) + if defined build_release ( set config=Release set package=1 @@ -172,8 +181,6 @@ if "%target%"=="Clean" echo deleting %~dp0deps\icu if "%target%"=="Clean" rmdir /S /Q %~dp0deps\icu :no-depsicu -call :getnodeversion || exit /b 1 - if "%target%"=="Clean" rmdir /Q /S "%~dp0%config%\node-v%FULLVERSION%-win-%target_arch%" > nul 2> nul if defined noprojgen if defined nobuild if not defined sign if not defined msi goto licensertf @@ -354,6 +361,7 @@ if not defined msi goto run :msibuild echo Building node-v%FULLVERSION%-%target_arch%.msi +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 @@ -556,8 +564,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% @@ -575,8 +588,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 From eb496c44169da393a552a16d26e63e0bf44e1321 Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Sat, 25 Nov 2017 15:10:55 -0500 Subject: [PATCH 2/3] [fixup] explicit validation section --- vcbuild.bat | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/vcbuild.bat b/vcbuild.bat index 3b1b711b1de88d..bad0ed58472716 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -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 @@ -125,13 +125,7 @@ shift shift goto next-arg -:args-done - -REM Shortcut for just linting (does not need python) -if "%*"=="lint" ( - goto lint-cpp -) - +:environment-validate REM Make sure we can find python call :run-python --version > NUL if errorlevel 1 ( @@ -140,6 +134,12 @@ if errorlevel 1 ( exit /b 1 ) + +REM Shortcut for just linting (does not need python) +if "%*"=="lint" ( + goto lint-cpp +) + if defined build_release ( set config=Release set package=1 From aa15c27625501438a2291ff99ba58107eb9e7efd Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Sat, 25 Nov 2017 15:38:05 -0500 Subject: [PATCH 3/3] [fixup] improve cleaning of Release artifacts --- vcbuild.bat | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vcbuild.bat b/vcbuild.bat index bad0ed58472716..a09559867716e0 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -127,7 +127,7 @@ goto next-arg :environment-validate REM Make sure we can find python -call :run-python --version > NUL +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 @@ -176,12 +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 -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