summaryrefslogtreecommitdiffstats
path: root/Nightbuild2008.cmd
blob: 11e2b3683bd87638e289891813bc3bc932335206 (plain) (blame)
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
@echo off
:: Nightbbuild2008.cmd
:: This script is run every night to produce a new version of MCServer, backup its PDB files and upload the packages to web.
:: These sub-scripts are used:
::  - UploadVersion.ftp FTP command template for uploading the version to the web
:: When run without parameters, this script pauses at the end and waits for a keypress.
:: To run in an automated scheduler, add any parameter to disable waiting for a keystroke
::
:: This script expects a few tools on specific paths, you can pass the correct paths for your system as env vars "zip" and "vc"
:: This script assumes that "git", "symstore" and "touch" are available on PATH.
:: git comes from msysgit
:: symstore comes from Microsoft's Debugging Tools for Windows
:: touch comes from unxtools
:: This script is locale-dependent


:: 7-zip executable (by default it should be on PATH):
if %zip%a == a set zip=7z

:: Visual C++ compiler executable name:
if %vc%a == a set vc="vcbuild.exe"




:: Get the date and time into vars:
For /f "tokens=2-4 delims=/. " %%a in ('date /t') do (
	set MYYEAR=%%c
	set MYMONTH=%%b
	set MYDAY=%%a
)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set MYTIME=%%a_%%b)

echo MYYEAR = %MYYEAR%
echo MYMONTH = %MYMONTH%
echo MYDAY = %MYDAY%
echo MYTIME = %MYTIME%

echo Performing nightbuild of MC-Server





set DONOTPAUSE=y

:: Update the sources to the latest revision:
del source\Bindings.cpp
del source\Bindings.h
git checkout -- source\Bindings.*
git pull
if errorlevel 1 goto haderror



:: Get the Git commit ID into an environment var
For /f "tokens=1 delims=/. " %%a in ('git log -1 --oneline --no-abbrev-commit') do (set COMMITID=%%a)
if errorlevel 1 goto haderror



:: Test if the version is already present, using a "tagfile" that we create upon successful build
set TAGFILE=Install\built_%COMMITID%.tag
if exist %TAGFILE% (
	echo Latest version already present, bailing out
	goto end
)



:: Update the Bindings:
del source\Bindings.cpp
del source\Bindings.h
echo Updating Lua bindings
set ALLTOLUA_WAIT=N
cd source
call AllToLua.bat
cd ..




:: Compile using VC2008 Express. Do a full rebuild.
echo Setting up VS environment...
call "%VS90COMNTOOLS%\vsvars32.bat"
echo Compiling MCServer...
title MCS Nightbuild
start "vc" /b /wait /low /min %vc% /r vc2008\MCServer.sln "Release|Win32"
if errorlevel 1 goto haderror





:: Copy all the example ini files into the Install folder for zipping:
copy MCServer\*.example.ini Install\*.example.ini

:: Use 7-zip to compress the resulting files into a single file:
set FILESUFFIX=%MYYEAR%_%MYMONTH%_%MYDAY%_%MYTIME%_%COMMITID%
echo FILESUFFIX=%FILESUFFIX%
copy MCServer\MCServer.exe Install\MCServer.exe
cd Install
%zip% a -mx9 -y MCServer_Win_%FILESUFFIX%.7z -scsWIN @Zip2008.list
if errorlevel 1 goto haderror
cd ..

:: Also pack PDBs into a separate archive:
%zip% a -mx9 -y Install\PDBs_%FILESUFFIX%.7z -scsWIN @Install\Zip2008_PDBs.list
if errorlevel 1 goto haderror





:: upload to the FTP:
:upload
if "a%ftppass%" == "a" (
	echo You need to set FTP password in the ftppass environment variable to upload the files
	goto end
)
if "a%ftpuser%" == "a" (
	echo You need to set FTP username in the ftpuser environment variable to upload the files
	goto end
)
if "a%ftpsite%" == "a" (
	echo You need to set FTP server in the ftpsite environment variable to upload the files
	goto end
)
ncftpput -p %ftppass% -u %ftpuser% -T temp_ %ftpsite% / Install\MCServer_Win_%FILESUFFIX%.7z
if errorlevel 1 goto haderror
ncftpput -p %ftppass% -u %ftpuser% -T temp_ %ftpsite% /PDBs Install\PDBs_%FILESUFFIX%.7z
if errorlevel 1 goto haderror
echo Upload finished.




:: Create the tagfile so that we know that this CommitID has been built already
touch %TAGFILE%





:: Add the symbols to a global symbol cache
:: We want per-month symbol caches, so that the old ones can be easily deleted
set SYMBOLS=Symbols\%MYYEAR%_%MYMONTH%\
echo Storing symbols in %SYMBOLS%

symstore add /f MCServer\MCServer.* /s %SYMBOLS% /t MCServer
if errorlevel 1 goto haderror



goto end




:haderror
echo an error was encountered, check command output above
pause
goto finished





:end
if "a%1" == "a" pause



:finished