Skip to content

Commit f189290

Browse files
committed
Support for automated build bot scripts, add PandaSystem::get_git_commit()
1 parent cd8c6ee commit f189290

File tree

5 files changed

+57
-15
lines changed

5 files changed

+57
-15
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ compiler:
44
- clang
55
before_script:
66
- sudo apt-get install python-dev libpng-dev zlib1g-dev libssl-dev libx11-dev libgl1-mesa-dev libxrandr-dev libxxf86dga-dev libxcursor-dev bison flex libfreetype6-dev libvorbis-dev libjpeg-dev libopenal-dev libode-dev nvidia-cg-toolkit
7-
script: python makepanda/makepanda.py --everything
7+
script: python makepanda/makepanda.py --everything --git-commit $TRAVIS_COMMIT
88
notifications:
99
irc:
1010
channels:

dtool/src/dtoolutil/pandaSystem.cxx

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ is_official_version() {
226226
return false;
227227
#endif
228228
}
229-
229+
230230
////////////////////////////////////////////////////////////////////
231231
// Function: PandaSystem::get_distributor
232232
// Access: Published, Static
@@ -239,7 +239,7 @@ string PandaSystem::
239239
get_distributor() {
240240
return PANDA_DISTRIBUTOR;
241241
}
242-
242+
243243
////////////////////////////////////////////////////////////////////
244244
// Function: PandaSystem::get_compiler
245245
// Access: Published, Static
@@ -279,7 +279,7 @@ get_compiler() {
279279
return "unknown";
280280
#endif
281281
}
282-
282+
283283
////////////////////////////////////////////////////////////////////
284284
// Function: PandaSystem::get_build_date
285285
// Access: Published, Static
@@ -291,7 +291,23 @@ string PandaSystem::
291291
get_build_date() {
292292
return __DATE__ " " __TIME__;
293293
}
294-
294+
295+
////////////////////////////////////////////////////////////////////
296+
// Function: PandaSystem::get_git_commit
297+
// Access: Published, Static
298+
// Description: Returns a string representing the git commit hash
299+
// that this source tree is based on, or the empty
300+
// string if it has not been specified at build time.
301+
////////////////////////////////////////////////////////////////////
302+
string PandaSystem::
303+
get_git_commit() {
304+
#ifdef PANDA_GIT_COMMIT_STR
305+
return PANDA_GIT_COMMIT_STR;
306+
#else
307+
return string();
308+
#endif
309+
}
310+
295311
////////////////////////////////////////////////////////////////////
296312
// Function: PandaSystem::get_platform
297313
// Access: Published, Static
@@ -440,7 +456,7 @@ heap_trim(size_t pad) {
440456
////////////////////////////////////////////////////////////////////
441457
// Function: PandaSystem::output
442458
// Access: Published
443-
// Description:
459+
// Description:
444460
////////////////////////////////////////////////////////////////////
445461
void PandaSystem::
446462
output(ostream &out) const {
@@ -450,7 +466,7 @@ output(ostream &out) const {
450466
////////////////////////////////////////////////////////////////////
451467
// Function: PandaSystem::write
452468
// Access: Published
453-
// Description:
469+
// Description:
454470
////////////////////////////////////////////////////////////////////
455471
void PandaSystem::
456472
write(ostream &out) const {
@@ -472,7 +488,7 @@ write(ostream &out) const {
472488
}
473489
}
474490

475-
491+
476492
////////////////////////////////////////////////////////////////////
477493
// Function: PandaSystem::get_global_ptr
478494
// Access: Published, Static
@@ -498,12 +514,12 @@ void PandaSystem::
498514
reset_system_names() {
499515
_system_names.clear();
500516
_system_names.reserve(_systems.size());
501-
517+
502518
Systems::const_iterator si;
503519
for (si = _systems.begin(); si != _systems.end(); ++si) {
504520
_system_names.push_back((*si).first);
505521
}
506-
522+
507523
_system_names_dirty = false;
508524
}
509525

dtool/src/dtoolutil/pandaSystem.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ class EXPCL_DTOOL PandaSystem {
4141
static int get_minor_version();
4242
static int get_sequence_version();
4343
static bool is_official_version();
44-
44+
4545
static string get_distributor();
4646
static string get_compiler();
4747
static string get_build_date();
48+
static string get_git_commit();
4849

4950
static string get_platform();
5051

@@ -106,4 +107,4 @@ inline ostream &operator << (ostream &out, const PandaSystem &ps) {
106107

107108
#endif
108109

109-
110+

makepanda/getversion.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env python
2+
3+
# This script parses the version number in dtool/PandaVersion.pp
4+
# and returns it on the command-line. This is useful for the
5+
# automated scripts that build the Panda3D releases.
6+
7+
from makepandacore import ParsePandaVersion, ParsePluginVersion
8+
import sys
9+
10+
if '--runtime' in sys.argv:
11+
version = ParsePluginVersion("dtool/PandaVersion.pp")
12+
else:
13+
version = ParsePandaVersion("dtool/PandaVersion.pp")
14+
15+
version = version.strip()
16+
sys.stdout.write(version)
17+
sys.stdout.flush()

makepanda/makepanda.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
VERSION=None
6262
DEBVERSION=None
6363
RPMRELEASE="1"
64+
GIT_COMMIT=None
6465
P3DSUFFIX=None
6566
MAJOR_VERSION=None
6667
COREAPI_VERSION=None
@@ -121,7 +122,7 @@ def keyboardInterruptHandler(x,y):
121122
def usage(problem):
122123
if (problem):
123124
print("")
124-
print("Error parsing commandline input", problem)
125+
print("Error parsing command-line input: %s" % (problem))
125126

126127
print("")
127128
print("Makepanda generates a 'built' subdirectory containing a")
@@ -164,15 +165,15 @@ def usage(problem):
164165
def parseopts(args):
165166
global INSTALLER,RTDIST,RUNTIME,GENMAN,DISTRIBUTOR,VERSION
166167
global COMPRESSOR,THREADCOUNT,OSXTARGET,UNIVERSAL,HOST_URL
167-
global DEBVERSION,RPMRELEASE,P3DSUFFIX
168+
global DEBVERSION,RPMRELEASE,GIT_COMMIT,P3DSUFFIX
168169
global STRDXSDKVERSION, STRMSPLATFORMVERSION, BOOUSEINTELCOMPILER
169170
longopts = [
170171
"help","distributor=","verbose","runtime","osxtarget=",
171172
"optimize=","everything","nothing","installer","rtdist","nocolor",
172173
"version=","lzma","no-python","threads=","outputdir=","override=",
173174
"static","host=","debversion=","rpmrelease=","p3dsuffix=",
174175
"directx-sdk=", "platform-sdk=", "use-icl",
175-
"universal", "target=", "arch="]
176+
"universal", "target=", "arch=", "git-commit="]
176177
anything = 0
177178
optimize = ""
178179
target = None
@@ -208,6 +209,7 @@ def parseopts(args):
208209
elif (option=="--host"): HOST_URL=value
209210
elif (option=="--debversion"): DEBVERSION=value
210211
elif (option=="--rpmrelease"): RPMRELEASE=value
212+
elif (option=="--git-commit"): GIT_COMMIT=value
211213
elif (option=="--p3dsuffix"): P3DSUFFIX=value
212214
# Backward compatibility, OPENGL was renamed to GL
213215
elif (option=="--use-opengl"): PkgEnable("GL")
@@ -259,6 +261,9 @@ def parseopts(args):
259261
except:
260262
usage("Invalid setting for OPTIMIZE")
261263

264+
if GIT_COMMIT is not None and not re.match("^[a-f0-9]{40}$", GIT_COMMIT):
265+
usage("Invalid SHA-1 hash given for --git-commit option!")
266+
262267
if target is not None or target_arch is not None:
263268
SetTarget(target, target_arch)
264269

@@ -2399,6 +2404,9 @@ def CreatePandaVersionFiles():
23992404
else:
24002405
pandaversion_h += "\n#undef PANDA_OFFICIAL_VERSION\n"
24012406

2407+
if GIT_COMMIT:
2408+
pandaversion_h += "\n#define PANDA_GIT_COMMIT_STR \"%s\"\n" % (GIT_COMMIT)
2409+
24022410
if not RUNTIME:
24032411
checkpandaversion_cxx = CHECKPANDAVERSION_CXX.replace("$VERSION1",str(version1))
24042412
checkpandaversion_cxx = checkpandaversion_cxx.replace("$VERSION2",str(version2))

0 commit comments

Comments
 (0)