/
vcbuild.bat
117 lines (90 loc) · 2.93 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
@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.
set config=Debug
set target=Build
set noprojgen=
set nobuild=
set test=
set test_args=
set msi=
: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"=="noprojgen" set noprojgen=1&goto arg-ok
if /i "%1"=="nobuild" set nobuild=1&goto arg-ok
if /i "%1"=="test-simple" set test=test-simple&goto arg-ok
if /i "%1"=="test" set test=test&goto arg-ok
if /i "%1"=="msi" set msi=1&goto arg-ok
:arg-ok
shift
goto next-arg
:gyp_install_failed
echo Failed to download gyp. Make sure you have subversion installed, or
echo manually install gyp into %~dp0tools\gyp.
goto exit
:args-done
if exist tools\gyp goto project-gen
echo svn co http://gyp.googlecode.com/svn/trunk tools/gyp
svn co http://gyp.googlecode.com/svn/trunk tools/gyp
if errorlevel 1 goto gyp_install_failed
goto project-gen
:project-gen
@rem Skip project generation if requested.
if defined noprojgen goto msbuild
@rem Generate the VS project.
cmd /c "python tools\gyp.py -f msvs -G msvs_version=2010"
if errorlevel 1 goto create-msvs-files-failed
if not exist meijing.sln goto create-msvs-files-failed
echo Project files generated.
:msbuild
@rem Skip project generation if requested.
if defined nobuild goto msi
@rem Bail out early if not running in VS build env.
if defined VCINSTALLDIR goto msbuild-found
if not defined VS100COMNTOOLS goto msbuild-not-found
if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto msbuild-not-found
call "%VS100COMNTOOLS%\..\..\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 run
:msbuild-found
@rem Build the sln with msbuild.
msbuild libMU.sln
if errorlevel 1 goto exit
:msi
@rem Skip msi generation if not requested
if not defined msi goto run
for /F "tokens=*" %%i in (version.txt) do set SNMP_VERSION=%%i
@rem add create installer code at here
if errorlevel 1 goto exit
:run
@rem Run tests if requested.
if "%test%"=="" goto exit
if "%config%"=="Debug" set test_args=--mode=debug
if "%config%"=="Release" set test_args=--mode=release
if "%test%"=="test" set test_args=%test_args%
if "%test%"=="test-simple" set test_args=%test_args% simple
goto exit
:create-msvs-files-failed
echo Failed to create vc project files.
goto exit
:help
echo vcbuild.bat [debug/release] [msi] [test/test-simple] [clean] [noprojgen] [nobuild]
echo Examples:
echo vcbuild.bat : builds debug build
echo vcbuild.bat test : builds debug build and runs tests
goto exit
:exit