diff --git a/.travis.yml b/.travis.yml index 8675a25c0e..26088946eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ compiler: - clang before_script: - 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 -script: python makepanda/makepanda.py --everything +script: python makepanda/makepanda.py --everything --git-commit $TRAVIS_COMMIT notifications: irc: channels: diff --git a/dtool/src/dtoolutil/pandaSystem.cxx b/dtool/src/dtoolutil/pandaSystem.cxx index ac71aa0729..d54029ecf2 100644 --- a/dtool/src/dtoolutil/pandaSystem.cxx +++ b/dtool/src/dtoolutil/pandaSystem.cxx @@ -226,7 +226,7 @@ is_official_version() { return false; #endif } - + //////////////////////////////////////////////////////////////////// // Function: PandaSystem::get_distributor // Access: Published, Static @@ -239,7 +239,7 @@ string PandaSystem:: get_distributor() { return PANDA_DISTRIBUTOR; } - + //////////////////////////////////////////////////////////////////// // Function: PandaSystem::get_compiler // Access: Published, Static @@ -279,7 +279,7 @@ get_compiler() { return "unknown"; #endif } - + //////////////////////////////////////////////////////////////////// // Function: PandaSystem::get_build_date // Access: Published, Static @@ -291,7 +291,23 @@ string PandaSystem:: get_build_date() { return __DATE__ " " __TIME__; } - + +//////////////////////////////////////////////////////////////////// +// Function: PandaSystem::get_git_commit +// Access: Published, Static +// Description: Returns a string representing the git commit hash +// that this source tree is based on, or the empty +// string if it has not been specified at build time. +//////////////////////////////////////////////////////////////////// +string PandaSystem:: +get_git_commit() { +#ifdef PANDA_GIT_COMMIT_STR + return PANDA_GIT_COMMIT_STR; +#else + return string(); +#endif +} + //////////////////////////////////////////////////////////////////// // Function: PandaSystem::get_platform // Access: Published, Static @@ -440,7 +456,7 @@ heap_trim(size_t pad) { //////////////////////////////////////////////////////////////////// // Function: PandaSystem::output // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// void PandaSystem:: output(ostream &out) const { @@ -450,7 +466,7 @@ output(ostream &out) const { //////////////////////////////////////////////////////////////////// // Function: PandaSystem::write // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// void PandaSystem:: write(ostream &out) const { @@ -472,7 +488,7 @@ write(ostream &out) const { } } - + //////////////////////////////////////////////////////////////////// // Function: PandaSystem::get_global_ptr // Access: Published, Static @@ -498,12 +514,12 @@ void PandaSystem:: reset_system_names() { _system_names.clear(); _system_names.reserve(_systems.size()); - + Systems::const_iterator si; for (si = _systems.begin(); si != _systems.end(); ++si) { _system_names.push_back((*si).first); } - + _system_names_dirty = false; } diff --git a/dtool/src/dtoolutil/pandaSystem.h b/dtool/src/dtoolutil/pandaSystem.h index d0a7835e01..f69b8adde1 100644 --- a/dtool/src/dtoolutil/pandaSystem.h +++ b/dtool/src/dtoolutil/pandaSystem.h @@ -41,10 +41,11 @@ PUBLISHED: static int get_minor_version(); static int get_sequence_version(); static bool is_official_version(); - + static string get_distributor(); static string get_compiler(); static string get_build_date(); + static string get_git_commit(); static string get_platform(); @@ -106,4 +107,4 @@ inline ostream &operator << (ostream &out, const PandaSystem &ps) { #endif - + diff --git a/makepanda/getversion.py b/makepanda/getversion.py new file mode 100755 index 0000000000..5d74316aec --- /dev/null +++ b/makepanda/getversion.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +# This script parses the version number in dtool/PandaVersion.pp +# and returns it on the command-line. This is useful for the +# automated scripts that build the Panda3D releases. + +from makepandacore import ParsePandaVersion, ParsePluginVersion +import sys + +if '--runtime' in sys.argv: + version = ParsePluginVersion("dtool/PandaVersion.pp") +else: + version = ParsePandaVersion("dtool/PandaVersion.pp") + +version = version.strip() +sys.stdout.write(version) +sys.stdout.flush() diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index e29085f428..c6135e8124 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -61,6 +61,7 @@ DISTRIBUTOR="" VERSION=None DEBVERSION=None RPMRELEASE="1" +GIT_COMMIT=None P3DSUFFIX=None MAJOR_VERSION=None COREAPI_VERSION=None @@ -121,7 +122,7 @@ signal.signal(signal.SIGINT, keyboardInterruptHandler) def usage(problem): if (problem): print("") - print("Error parsing commandline input", problem) + print("Error parsing command-line input: %s" % (problem)) print("") print("Makepanda generates a 'built' subdirectory containing a") @@ -164,7 +165,7 @@ def usage(problem): def parseopts(args): global INSTALLER,RTDIST,RUNTIME,GENMAN,DISTRIBUTOR,VERSION global COMPRESSOR,THREADCOUNT,OSXTARGET,UNIVERSAL,HOST_URL - global DEBVERSION,RPMRELEASE,P3DSUFFIX + global DEBVERSION,RPMRELEASE,GIT_COMMIT,P3DSUFFIX global STRDXSDKVERSION, STRMSPLATFORMVERSION, BOOUSEINTELCOMPILER longopts = [ "help","distributor=","verbose","runtime","osxtarget=", @@ -172,7 +173,7 @@ def parseopts(args): "version=","lzma","no-python","threads=","outputdir=","override=", "static","host=","debversion=","rpmrelease=","p3dsuffix=", "directx-sdk=", "platform-sdk=", "use-icl", - "universal", "target=", "arch="] + "universal", "target=", "arch=", "git-commit="] anything = 0 optimize = "" target = None @@ -208,6 +209,7 @@ def parseopts(args): elif (option=="--host"): HOST_URL=value elif (option=="--debversion"): DEBVERSION=value elif (option=="--rpmrelease"): RPMRELEASE=value + elif (option=="--git-commit"): GIT_COMMIT=value elif (option=="--p3dsuffix"): P3DSUFFIX=value # Backward compatibility, OPENGL was renamed to GL elif (option=="--use-opengl"): PkgEnable("GL") @@ -259,6 +261,9 @@ def parseopts(args): except: usage("Invalid setting for OPTIMIZE") + if GIT_COMMIT is not None and not re.match("^[a-f0-9]{40}$", GIT_COMMIT): + usage("Invalid SHA-1 hash given for --git-commit option!") + if target is not None or target_arch is not None: SetTarget(target, target_arch) @@ -2399,6 +2404,9 @@ def CreatePandaVersionFiles(): else: pandaversion_h += "\n#undef PANDA_OFFICIAL_VERSION\n" + if GIT_COMMIT: + pandaversion_h += "\n#define PANDA_GIT_COMMIT_STR \"%s\"\n" % (GIT_COMMIT) + if not RUNTIME: checkpandaversion_cxx = CHECKPANDAVERSION_CXX.replace("$VERSION1",str(version1)) checkpandaversion_cxx = checkpandaversion_cxx.replace("$VERSION2",str(version2))