0b7ea481117d215b6e594cd5dff1620d4d5b0721
[platform/upstream/nodejs.git] / deps / uv / vcbuild.bat
1 @echo off
2
3 cd %~dp0
4
5 if /i "%1"=="help" goto help
6 if /i "%1"=="--help" goto help
7 if /i "%1"=="-help" goto help
8 if /i "%1"=="/help" goto help
9 if /i "%1"=="?" goto help
10 if /i "%1"=="-?" goto help
11 if /i "%1"=="--?" goto help
12 if /i "%1"=="/?" goto help
13
14 @rem Process arguments.
15 set config=
16 set target=Build
17 set noprojgen=
18 set nobuild=
19 set run=
20 set target_arch=ia32
21 set vs_toolset=x86
22 set platform=WIN32
23 set library=static_library
24
25 :next-arg
26 if "%1"=="" goto args-done
27 if /i "%1"=="debug"        set config=Debug&goto arg-ok
28 if /i "%1"=="release"      set config=Release&goto arg-ok
29 if /i "%1"=="test"         set run=run-tests.exe&goto arg-ok
30 if /i "%1"=="bench"        set run=run-benchmarks.exe&goto arg-ok
31 if /i "%1"=="clean"        set target=Clean&goto arg-ok
32 if /i "%1"=="noprojgen"    set noprojgen=1&goto arg-ok
33 if /i "%1"=="nobuild"      set nobuild=1&goto arg-ok
34 if /i "%1"=="x86"          set target_arch=ia32&set platform=WIN32&set vs_toolset=x86&goto arg-ok
35 if /i "%1"=="ia32"         set target_arch=ia32&set platform=WIN32&set vs_toolset=x86&goto arg-ok
36 if /i "%1"=="x64"          set target_arch=x64&set platform=amd64&set vs_toolset=x64&goto arg-ok
37 if /i "%1"=="shared"       set library=shared_library&goto arg-ok
38 if /i "%1"=="static"       set library=static_library&goto arg-ok
39 :arg-ok
40 shift
41 goto next-arg
42 :args-done
43
44 @rem Look for Visual Studio 2012
45 if not defined VS110COMNTOOLS goto vc-set-2010
46 if not exist "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2010
47 call "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
48 set GYP_MSVS_VERSION=2012
49 goto select-target
50
51 :vc-set-2010
52 @rem Look for Visual Studio 2010
53 if not defined VS100COMNTOOLS goto vc-set-2008
54 if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2008
55 call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
56 set GYP_MSVS_VERSION=2010
57 goto select-target
58
59 :vc-set-2008
60 @rem Look for Visual Studio 2008
61 if not defined VS90COMNTOOLS goto vc-set-notfound
62 if not exist "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-notfound
63 call "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
64 set GYP_MSVS_VERSION=2008
65 goto select-target
66
67 :vc-set-notfound
68 echo Warning: Visual Studio not found
69
70 :select-target
71 if not "%config%"=="" goto project-gen
72 if "%run%"=="run-tests.exe" set config=Debug& goto project-gen
73 if "%run%"=="run-benchmarks.exe" set config=Release& goto project-gen
74 set config=Debug
75
76 :project-gen
77 @rem Skip project generation if requested.
78 if defined noprojgen goto msbuild
79
80 @rem Generate the VS project.
81 if exist build\gyp goto have_gyp
82 echo git clone https://git.chromium.org/external/gyp.git build/gyp
83 git clone https://git.chromium.org/external/gyp.git build/gyp
84 if errorlevel 1 goto gyp_install_failed
85 goto have_gyp
86
87 :gyp_install_failed
88 echo Failed to download gyp. Make sure you have git installed, or
89 echo manually install gyp into %~dp0build\gyp.
90 exit /b 1
91
92 :have_gyp
93 if not defined PYTHON set PYTHON="python"
94 %PYTHON% gyp_uv.py -Dtarget_arch=%target_arch% -Dlibrary=%library%
95 if errorlevel 1 goto create-msvs-files-failed
96 if not exist uv.sln goto create-msvs-files-failed
97 echo Project files generated.
98
99 :msbuild
100 @rem Skip project generation if requested.
101 if defined nobuild goto run
102
103 @rem Check if VS build env is available
104 if not defined VCINSTALLDIR goto msbuild-not-found
105 goto msbuild-found
106
107 :msbuild-not-found
108 echo Build skipped. To build, this file needs to run from VS cmd prompt.
109 goto run
110
111 @rem Build the sln with msbuild.
112 :msbuild-found
113 msbuild uv.sln /t:%target% /p:Configuration=%config% /p:Platform="%platform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
114 if errorlevel 1 exit /b 1
115
116 :run
117 @rem Run tests if requested.
118 if "%run%"=="" goto exit
119 if not exist %config%\%run% goto exit
120 echo running '%config%\%run%'
121 %config%\%run%
122 goto exit
123
124 :create-msvs-files-failed
125 echo Failed to create vc project files.
126 exit /b 1
127
128 :help
129 echo vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [x86/x64] [static/shared]
130 echo Examples:
131 echo   vcbuild.bat              : builds debug build
132 echo   vcbuild.bat test         : builds debug build and runs tests
133 echo   vcbuild.bat release bench: builds release build and runs benchmarks
134 goto exit
135
136 :exit