This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
/
vcbuild.bat
211 lines (181 loc) · 6.46 KB
/
vcbuild.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
@echo off
@rem Attribution Notice
@rem ------------------
@rem This file uses parts of Node.js `vcbuild.bat`.
@rem Please refer to https://github.com/joyent/node.
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.
set config=Release
set target=Build
set target_arch=ia32
set noprojgen=
set nobuild=
set test=
set work_dir=%~dp0
: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"=="clean" set target=Clean&goto arg-ok
if /i "%1"=="ia32" set target_arch=ia32&goto arg-ok
if /i "%1"=="x86" set target_arch=ia32&goto arg-ok
if /i "%1"=="x64" set target_arch=x64&goto arg-ok
if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok
if /i "%1"=="nobuild" set nobuild=1&goto arg-ok
if /i "%1"=="test" set test=test&goto arg-ok
if /i "%1"=="inttest" set inttest=1&goto arg-ok
if /i "%1"=="MSVC2015" set GYP_MSVS_VERSION=2015&goto arg-ok
if /i "%1"=="MSVC2013" set GYP_MSVS_VERSION=2013&goto arg-ok
if /i "%1"=="MSVC2012" set GYP_MSVS_VERSION=2012&goto arg-ok
if /i "%1"=="MSVC2010" set GYP_MSVS_VERSION=2010&goto arg-ok
if /i "%1"=="MSVC2008" set GYP_MSVS_VERSION=2008&goto arg-ok
echo Warning: ignoring invalid command line option `%1`.
:arg-ok
shift
goto next-arg
:args-done
if "%config%"=="Debug" set debug_arg=--debug
:project-gen
@rem Skip project generation if requested.
if defined noprojgen goto msbuild
if "%GYP_MSVS_VERSION%"=="" set GYP_MSVS_VERSION=2015
@rem Generate the VS project.
SETLOCAL
if defined VS120COMNTOOLS call "%VS120COMNTOOLS%\VCVarsQueryRegistry.bat"
if defined inttest python configure %debug_arg% --dest-cpu=%target_arch% --include-integration-tests
if not defined inttest python configure %debug_arg% --dest-cpu=%target_arch%
if errorlevel 1 goto create-msvs-files-failed
if not exist build/drafter.sln goto create-msvs-files-failed
echo Project files generated.
ENDLOCAL
:msbuild
@rem Skip project generation if requested.
if defined nobuild goto success
if "%GYP_MSVS_VERSION%"=="2015" goto vc-set-2015
if "%GYP_MSVS_VERSION%"=="2013" goto vc-set-2013
if "%GYP_MSVS_VERSION%"=="2012" goto vc-set-2012
if "%GYP_MSVS_VERSION%"=="2010" goto vc-set-2010
if "%GYP_MSVS_VERSION%"=="2008" goto vc-set-2008
@rem MSVS 2015 is VS14
:vc-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"
if not defined VCINSTALLDIR goto msbuild-not-found
goto msbuild-found
:vc-set-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"
if not defined VCINSTALLDIR goto msbuild-not-found
goto msbuild-found
:vc-set-2012
if not defined VS110COMNTOOLS goto vc-set-2010
if not exist "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2010
call "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat"
if not defined VCINSTALLDIR goto msbuild-not-found
goto msbuild-found
:vc-set-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"
if not defined VCINSTALLDIR goto msbuild-not-found
goto msbuild-found
:vc-set-2008
if not defined VS90COMNTOOLS goto msbuild-not-found
if not exist "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" goto msbuild-not-found
call "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat"
if not defined VCINSTALLDIR goto msbuild-not-found
goto msbuild-found
:msbuild-not-found
echo Build skipped. To build, this file needs to run from VS cmd prompt.
goto fail
:msbuild-found
@rem Build the sln with msbuild.
@rem Refer to http://msdn.microsoft.com/en-us/library/ms164311.aspx
echo Building Snow Crash...
msbuild build/drafter.sln /m /clp:NoSummary;NoItemAndPropertyList;Verbosity=normal /nologo /property:Configuration=%config%
if errorlevel 1 goto fail
:run
@rem Run tests if requested.
if "%test%"=="" goto intigration-test
echo Running tests...
.\build\%config%\test-libmarkdownparser.exe || goto fail
.\build\%config%\test-libsnowcrash.exe || goto fail
.\build\%config%\test-libdrafter.exe || goto fail
.\build\%config%\test-capi.exe || goto fail
:intigration-test
if defined inttest goto run-integration-test
@rem All Done
goto success
:run-integration-test
copy %work_dir%\build\%config%\drafter.exe .
if "%config%"=="Debug" (
SET "Replacement= ENV['PATH'] = "../../build/Debug""
goto :run-cucumber
)
SET "Replacement= ENV['PATH'] = "../../build/Release""
goto :run-cucumber
:run-cucumber
SET "file=features\support\env-win.rb"
if exist "%file%" goto env-exist
SETLOCAL ENABLEDELAYEDEXPANSION
SET "line=require 'aruba/cucumber'"
ECHO !line! >"%file%"
SET "line=require 'rbconfig'"
ECHO !line! >>"%file%"
SET "line=Before do"
ECHO !line! >>"%file%"
SET "line= @dirs << "../../features/fixtures""
ECHO !line! >>"%file%"
SET "line= case RbConfig::CONFIG['host_os']"
ECHO !line! >>"%file%"
SET "line= when /mswin|msys|mingw|cygwin|bccwin|wince|emc/"
ECHO !line! >>"%file%"
ECHO !Replacement! >>"%file%"
SET "line=end"
ECHO !line! >>"%file%"
SET "line=end"
ECHO !line! >>"%file%"
ENDLOCAL
bundle exec cucumber
goto success
:env-exist
SET /a Line#ToSearch=7
(FOR /f "tokens=1*delims=:" %%a IN ('findstr /n "^" "%file%"') DO (
SET "Line=%%b"
IF %%a equ %Line#ToSearch% SET "Line=%Replacement%"
SETLOCAL ENABLEDELAYEDEXPANSION
ECHO(!Line!)
ENDLOCAL
)>"%file%.new"
MOVE "%file%.new" "%file%" >nul
bundle exec cucumber
goto success
:create-msvs-files-failed
echo Failed to create vc project files.
goto fail
:help
echo vcbuild.bat [debug/release] [test] [clean] [noprojgen] [nobuild] [x86/x64] [inttest] [MSVC2012/MSVC2013]
echo Examples:
echo vcbuild.bat : builds release build
echo vcbuild.bat nobuild : generate MSVS project files only
echo vcbuild.bat debug : builds debug build
echo vcbuild.bat test : builds debug build and runs tests
echo vcbuild.bat inttest : include integration tests
echo vcbuild.bat MSVC2013 : indicate target solution's version, could also define as MSVC2012, MSVC2013
goto success
:fail
REM print log if found
if exist "drafter.log" tail.exe -n 100 "drafter.log"
EXIT /B 1
:success
EXIT /B 0