0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
nodejs/deps/uv/vcbuild.bat

185 lines
6.0 KiB
Batchfile
Raw Normal View History

2011-08-22 23:51:29 +02:00
@echo off
cd %~dp0
if /i "%1"=="help" goto help
if /i "%1"=="--help" goto help
if /i "%1"=="-help" goto help
if /i "%1"=="/help" goto help
if /i "%1"=="?" goto help
if /i "%1"=="-?" goto help
if /i "%1"=="--?" goto help
if /i "%1"=="/?" goto help
@rem Process arguments.
2011-08-26 18:10:35 +02:00
set config=
2011-08-22 23:51:29 +02:00
set target=Build
set target_arch=ia32
set target_env=
2011-08-22 23:51:29 +02:00
set noprojgen=
2011-08-26 18:10:35 +02:00
set nobuild=
2011-08-22 23:51:29 +02:00
set run=
2012-10-06 23:04:30 +02:00
set vs_toolset=x86
set msbuild_platform=WIN32
2012-10-06 23:04:30 +02:00
set library=static_library
2011-08-22 23:51:29 +02:00
:next-arg
if "%1"=="" goto args-done
if /i "%1"=="debug" set config=Debug&goto arg-ok
if /i "%1"=="release" set config=Release&goto arg-ok
if /i "%1"=="test" set run=run-tests.exe&goto arg-ok
if /i "%1"=="bench" set run=run-benchmarks.exe&goto arg-ok
if /i "%1"=="clean" set target=Clean&goto arg-ok
if /i "%1"=="vs2017" set target_env=vs2017&goto arg-ok
2011-08-22 23:51:29 +02:00
if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok
2011-08-26 18:10:35 +02:00
if /i "%1"=="nobuild" set nobuild=1&goto arg-ok
if /i "%1"=="x86" set target_arch=ia32&set msbuild_platform=WIN32&set vs_toolset=x86&goto arg-ok
if /i "%1"=="ia32" set target_arch=ia32&set msbuild_platform=WIN32&set vs_toolset=x86&goto arg-ok
if /i "%1"=="x64" set target_arch=x64&set msbuild_platform=x64&set vs_toolset=x64&goto arg-ok
2012-10-06 23:04:30 +02:00
if /i "%1"=="shared" set library=shared_library&goto arg-ok
if /i "%1"=="static" set library=static_library&goto arg-ok
2011-08-22 23:51:29 +02:00
:arg-ok
shift
goto next-arg
:args-done
if defined WindowsSDKDir goto select-target
if defined VCINSTALLDIR goto select-target
@rem Look for Visual Studio 2017 only if explicitly requested.
if "%target_env%" NEQ "vs2017" goto vs-set-2015
echo Looking for Visual Studio 2017
@rem Check if VS2017 is already setup, and for the requested arch.
if "_%VisualStudioVersion%_" == "_15.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%vs_toolset%_" goto found_vs2017
set "VSINSTALLDIR="
call tools\vswhere_usability_wrapper.cmd
if "_%VCINSTALLDIR%_" == "__" goto vs-set-2015
@rem Need to clear VSINSTALLDIR for vcvarsall to work as expected.
@rem Keep current working directory after call to vcvarsall
set "VSCMD_START_DIR=%CD%"
set vcvars_call="%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %vs_toolset%
echo calling: %vcvars_call%
call %vcvars_call%
:found_vs2017
echo Found MSVS version %VisualStudioVersion%
if %VSCMD_ARG_TGT_ARCH%==x64 set target_arch=x64&set msbuild_platform=x64&set vs_toolset=x64
set GYP_MSVS_VERSION=2017
goto select-target
2014-02-27 03:08:30 +01:00
@rem Look for Visual Studio 2015
:vs-set-2015
if not defined VS140COMNTOOLS goto vc-set-2013
if not exist "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2013
call "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
set GYP_MSVS_VERSION=2015
echo Using Visual Studio 2015
goto select-target
:vc-set-2013
2013-12-31 19:33:54 +01:00
@rem Look for Visual Studio 2013
if not defined VS120COMNTOOLS goto vc-set-2012
if not exist "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2012
call "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
set GYP_MSVS_VERSION=2013
echo Using Visual Studio 2013
2013-12-31 19:33:54 +01:00
goto select-target
:vc-set-2012
2014-06-27 02:44:36 +02:00
@rem Look for Visual Studio 2012
2013-04-12 17:43:05 +02:00
if not defined VS110COMNTOOLS goto vc-set-2010
if not exist "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2010
call "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
set GYP_MSVS_VERSION=2012
echo Using Visual Studio 2012
2013-04-12 17:43:05 +02:00
goto select-target
:vc-set-2010
2012-10-06 23:04:30 +02:00
@rem Look for Visual Studio 2010
if not defined VS100COMNTOOLS goto vc-set-2008
if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2008
call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
set GYP_MSVS_VERSION=2010
echo Using Visual Studio 2010
2012-10-06 23:04:30 +02:00
goto select-target
:vc-set-2008
@rem Look for Visual Studio 2008
if not defined VS90COMNTOOLS goto vc-set-notfound
if not exist "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-notfound
call "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
set GYP_MSVS_VERSION=2008
echo Using Visual Studio 2008
2012-10-06 23:04:30 +02:00
goto select-target
:vc-set-notfound
echo Warning: Visual Studio not found
:select-target
2011-08-26 18:10:35 +02:00
if not "%config%"=="" goto project-gen
if "%run%"=="run-tests.exe" set config=Debug& goto project-gen
if "%run%"=="run-benchmarks.exe" set config=Release& goto project-gen
set config=Debug
2011-08-22 23:51:29 +02:00
2011-08-26 18:10:35 +02:00
:project-gen
2011-08-22 23:51:29 +02:00
@rem Skip project generation if requested.
if defined noprojgen goto msbuild
@rem Generate the VS project.
2011-08-26 18:10:35 +02:00
if exist build\gyp goto have_gyp
echo git clone https://chromium.googlesource.com/external/gyp build/gyp
git clone https://chromium.googlesource.com/external/gyp build/gyp
2011-08-26 18:10:35 +02:00
if errorlevel 1 goto gyp_install_failed
goto have_gyp
:gyp_install_failed
2013-02-26 20:30:12 +01:00
echo Failed to download gyp. Make sure you have git installed, or
2011-08-26 18:10:35 +02:00
echo manually install gyp into %~dp0build\gyp.
2013-03-01 02:04:29 +01:00
exit /b 1
2011-08-26 18:10:35 +02:00
:have_gyp
2014-06-27 02:44:36 +02:00
if not defined PYTHON set PYTHON=python
"%PYTHON%" gyp_uv.py -Dtarget_arch=%target_arch% -Duv_library=%library%
2011-08-22 23:51:29 +02:00
if errorlevel 1 goto create-msvs-files-failed
if not exist uv.sln goto create-msvs-files-failed
2011-08-26 18:10:35 +02:00
echo Project files generated.
2011-08-22 23:51:29 +02:00
:msbuild
2011-08-26 18:10:35 +02:00
@rem Skip project generation if requested.
if defined nobuild goto run
2012-10-06 23:04:30 +02:00
@rem Check if VS build env is available
2014-02-27 03:08:30 +01:00
if defined VCINSTALLDIR goto msbuild-found
if defined WindowsSDKDir goto msbuild-found
2012-01-31 17:41:46 +01:00
echo Build skipped. To build, this file needs to run from VS cmd prompt.
goto run
2011-08-26 18:10:35 +02:00
2011-08-22 23:51:29 +02:00
@rem Build the sln with msbuild.
2012-01-31 17:41:46 +01:00
:msbuild-found
msbuild uv.sln /t:%target% /p:Configuration=%config% /p:Platform="%msbuild_platform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
2013-03-01 02:04:29 +01:00
if errorlevel 1 exit /b 1
msbuild test\test.sln /t:%target% /p:Configuration=%config% /p:Platform="%msbuild_platform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
if errorlevel 1 exit /b 1
2011-08-22 23:51:29 +02:00
:run
@rem Run tests if requested.
if "%run%"=="" goto exit
echo running 'test\%config%\%run%'
test\%config%\%run%
2011-08-22 23:51:29 +02:00
goto exit
:create-msvs-files-failed
2012-10-06 23:04:30 +02:00
echo Failed to create vc project files.
2013-03-01 02:04:29 +01:00
exit /b 1
2011-08-22 23:51:29 +02:00
:help
echo vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [vs2017] [x86/x64] [static/shared]
2011-08-22 23:51:29 +02:00
echo Examples:
echo vcbuild.bat : builds debug build
echo vcbuild.bat test : builds debug build and runs tests
echo vcbuild.bat release bench: builds release build and runs benchmarks
goto exit
:exit