build: vcbuild fix "The input line is too long."
[platform/upstream/nodejs.git] / 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=Release
16 set msiplatform=x86
17 set target=Build
18 set target_arch=ia32
19 set debug_arg=
20 set nosnapshot_arg=
21 set noprojgen=
22 set nobuild=
23 set nosign=
24 set nosnapshot=
25 set test=
26 set test_args=
27 set msi=
28 set licensertf=
29 set upload=
30 set jslint=
31 set buildnodeweak=
32 set noetw=
33 set noetw_arg=
34 set noetw_msi_arg=
35 set noperfctr=
36 set noperfctr_arg=
37 set noperfctr_msi_arg=
38 set i18n_arg=
39
40 :next-arg
41 if "%1"=="" goto args-done
42 if /i "%1"=="debug"         set config=Debug&goto arg-ok
43 if /i "%1"=="release"       set config=Release&goto arg-ok
44 if /i "%1"=="clean"         set target=Clean&goto arg-ok
45 if /i "%1"=="ia32"          set target_arch=ia32&goto arg-ok
46 if /i "%1"=="x86"           set target_arch=ia32&goto arg-ok
47 if /i "%1"=="x64"           set target_arch=x64&goto arg-ok
48 if /i "%1"=="noprojgen"     set noprojgen=1&goto arg-ok
49 if /i "%1"=="nobuild"       set nobuild=1&goto arg-ok
50 if /i "%1"=="nosign"        set nosign=1&goto arg-ok
51 if /i "%1"=="nosnapshot"    set nosnapshot=1&goto arg-ok
52 if /i "%1"=="noetw"         set noetw=1&goto arg-ok
53 if /i "%1"=="noperfctr"     set noperfctr=1&goto arg-ok
54 if /i "%1"=="licensertf"    set licensertf=1&goto arg-ok
55 if /i "%1"=="test-uv"       set test=test-uv&goto arg-ok
56 if /i "%1"=="test-internet" set test=test-internet&goto arg-ok
57 if /i "%1"=="test-pummel"   set test=test-pummel&goto arg-ok
58 if /i "%1"=="test-simple"   set test=test-simple&goto arg-ok
59 if /i "%1"=="test-message"  set test=test-message&goto arg-ok
60 if /i "%1"=="test-gc"       set test=test-gc&set buildnodeweak=1&goto arg-ok
61 if /i "%1"=="test-all"      set test=test-all&set buildnodeweak=1&goto arg-ok
62 if /i "%1"=="test"          set test=test&goto arg-ok
63 if /i "%1"=="msi"           set msi=1&set licensertf=1&goto arg-ok
64 if /i "%1"=="upload"        set upload=1&goto arg-ok
65 if /i "%1"=="jslint"        set jslint=1&goto arg-ok
66 if /i "%1"=="small-icu"     set i18n_arg=%1&goto arg-ok
67 if /i "%1"=="full-icu"      set i18n_arg=%1&goto arg-ok
68
69 echo Warning: ignoring invalid command line option `%1`.
70
71 :arg-ok
72 :arg-ok
73 shift
74 goto next-arg
75
76 :args-done
77 if defined upload goto upload
78 if defined jslint goto jslint
79
80 if "%config%"=="Debug" set debug_arg=--debug
81 if "%target_arch%"=="x64" set msiplatform=x64
82 if defined nosnapshot set nosnapshot_arg=--without-snapshot
83 if defined noetw set noetw_arg=--without-etw& set noetw_msi_arg=/p:NoETW=1
84 if defined noperfctr set noperfctr_arg=--without-perfctr& set noperfctr_msi_arg=/p:NoPerfCtr=1
85
86 if "%i18n_arg%"=="full-icu" set i18n_arg=--with-intl=full-icu
87 if "%i18n_arg%"=="small-icu" set i18n_arg=--with-intl=small-icu
88
89 :project-gen
90 @rem Skip project generation if requested.
91 if defined noprojgen goto msbuild
92
93 if defined NIGHTLY set TAG=nightly-%NIGHTLY%
94
95 @rem Generate the VS project.
96 SETLOCAL
97   if defined VS100COMNTOOLS call "%VS100COMNTOOLS%\VCVarsQueryRegistry.bat"
98   python configure %i18n_arg% %debug_arg% %nosnapshot_arg% %noetw_arg% %noperfctr_arg% --dest-cpu=%target_arch% --tag=%TAG%
99   if errorlevel 1 goto create-msvs-files-failed
100   if not exist node.sln goto create-msvs-files-failed
101   echo Project files generated.
102 ENDLOCAL
103
104 :msbuild
105 @rem Skip project generation if requested.
106 if defined nobuild goto sign
107
108 @rem Look for Visual Studio 2013
109 if not defined VS120COMNTOOLS goto vc-set-2012
110 if not exist "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2012
111 if "%VCVARS_VER%" NEQ "120" (
112   call "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat"
113   SET VCVARS_VER=120
114 )
115 if not defined VCINSTALLDIR goto msbuild-not-found
116 set GYP_MSVS_VERSION=2013
117 goto msbuild-found
118
119 :vc-set-2012
120 @rem Look for Visual Studio 2012
121 if not defined VS110COMNTOOLS goto vc-set-2010
122 if not exist "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2010
123 if "%VCVARS_VER%" NEQ "110" (
124   call "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat"
125   SET VCVARS_VER=110
126 )
127 if not defined VCINSTALLDIR goto msbuild-not-found
128 set GYP_MSVS_VERSION=2012
129 goto msbuild-found
130
131 :vc-set-2010
132 if not defined VS100COMNTOOLS goto msbuild-not-found
133 if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto msbuild-not-found
134 if "%VCVARS_VER%" NEQ "100" (
135   call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat"
136   SET VCVARS_VER=100
137 )
138 if not defined VCINSTALLDIR goto msbuild-not-found
139 goto msbuild-found
140
141 :msbuild-not-found
142 echo Build skipped. To build, this file needs to run from VS cmd prompt.
143 goto run
144
145 :msbuild-found
146 @rem Build the sln with msbuild.
147 msbuild node.sln /m /t:%target% /p:Configuration=%config% /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
148 if errorlevel 1 goto exit
149
150 :sign
151 @rem Skip signing if the `nosign` option was specified.
152 if defined nosign goto licensertf
153
154 signtool sign /a /d "Node.js" /t http://timestamp.globalsign.com/scripts/timestamp.dll Release\node.exe
155 if errorlevel 1 echo Failed to sign exe&goto exit
156
157 :licensertf
158 @rem Skip license.rtf generation if not requested.
159 if not defined licensertf goto msi
160
161 %config%\node tools\license2rtf.js < LICENSE > %config%\license.rtf
162 if errorlevel 1 echo Failed to generate license.rtf&goto exit
163
164 :msi
165 @rem Skip msi generation if not requested
166 if not defined msi goto run
167 call :getnodeversion
168
169 if not defined NIGHTLY goto msibuild
170 set NODE_VERSION=%NODE_VERSION%.%NIGHTLY%
171
172 :msibuild
173 echo Building node-%NODE_VERSION%
174 msbuild "%~dp0tools\msvs\msi\nodemsi.sln" /m /t:Clean,Build /p:Configuration=%config% /p:Platform=%msiplatform% /p:NodeVersion=%NODE_VERSION% %noetw_msi_arg% %noperfctr_msi_arg% /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
175 if errorlevel 1 goto exit
176
177 if defined nosign goto run
178 signtool sign /a /d "Node.js" /t http://timestamp.globalsign.com/scripts/timestamp.dll Release\node-v%NODE_VERSION%-%msiplatform%.msi
179 if errorlevel 1 echo Failed to sign msi&goto exit
180
181 :run
182 @rem Run tests if requested.
183 if "%test%"=="" goto exit
184
185 if "%config%"=="Debug" set test_args=--mode=debug
186 if "%config%"=="Release" set test_args=--mode=release
187
188 if "%test%"=="test" set test_args=%test_args% simple message
189 if "%test%"=="test-internet" set test_args=%test_args% internet
190 if "%test%"=="test-pummel" set test_args=%test_args% pummel
191 if "%test%"=="test-simple" set test_args=%test_args% simple
192 if "%test%"=="test-message" set test_args=%test_args% message
193 if "%test%"=="test-gc" set test_args=%test_args% gc
194 if "%test%"=="test-all" set test_args=%test_args%
195
196 :build-node-weak
197 @rem Build node-weak if required
198 if "%buildnodeweak%"=="" goto run-tests
199 "%config%\node" deps\npm\node_modules\node-gyp\bin\node-gyp rebuild --directory="%~dp0test\gc\node_modules\weak" --nodedir="%~dp0."
200 if errorlevel 1 goto build-node-weak-failed
201 goto run-tests
202
203 :build-node-weak-failed
204 echo Failed to build node-weak.
205 goto exit
206
207 :run-tests
208 echo running 'python tools/test.py %test_args%'
209 python tools/test.py %test_args%
210 if "%test%"=="test" goto jslint
211 goto exit
212
213 :create-msvs-files-failed
214 echo Failed to create vc project files. 
215 goto exit
216
217 :upload
218 echo uploading .exe .msi .pdb to nodejs.org
219 call :getnodeversion
220 @echo on
221 ssh node@nodejs.org mkdir -p web/nodejs.org/dist/v%NODE_VERSION%
222 scp Release\node.msi node@nodejs.org:~/web/nodejs.org/dist/v%NODE_VERSION%/node-v%NODE_VERSION%.msi
223 scp Release\node.exe node@nodejs.org:~/web/nodejs.org/dist/v%NODE_VERSION%/node.exe
224 scp Release\node.pdb node@nodejs.org:~/web/nodejs.org/dist/v%NODE_VERSION%/node.pdb
225 @echo off
226 goto exit
227
228 :jslint
229 echo running jslint
230 set PYTHONPATH=tools/closure_linter/
231 python tools/closure_linter/closure_linter/gjslint.py --unix_mode --strict --nojsdoc -r lib/ -r src/ --exclude_files lib/punycode.js
232 goto exit
233
234 :help
235 echo vcbuild.bat [debug/release] [msi] [test-all/test-uv/test-internet/test-pummel/test-simple/test-message] [clean] [noprojgen] [nobuild] [nosign] [x86/x64]
236 echo Examples:
237 echo   vcbuild.bat                : builds release build
238 echo   vcbuild.bat debug          : builds debug build
239 echo   vcbuild.bat release msi    : builds release build and MSI installer package
240 echo   vcbuild.bat test           : builds debug build and runs tests
241 goto exit
242
243 :exit
244 goto :EOF
245
246 rem ***************
247 rem   Subroutines
248 rem ***************
249
250 :getnodeversion
251 set NODE_VERSION=
252 for /F "usebackq tokens=*" %%i in (`python "%~dp0tools\getnodeversion.py"`) do set NODE_VERSION=%%i
253 if not defined NODE_VERSION echo Cannot determine current version of node.js & exit /b 1
254 goto :EOF