Browse Source

Support for automated build bot scripts, add PandaSystem::get_git_commit()

rdb 11 years ago
parent
commit
f189290dfe

+ 1 - 1
.travis.yml

@@ -4,7 +4,7 @@ compiler:
   - clang
   - clang
 before_script:
 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
   - 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:
 notifications:
   irc:
   irc:
     channels:
     channels:

+ 25 - 9
dtool/src/dtoolutil/pandaSystem.cxx

@@ -226,7 +226,7 @@ is_official_version() {
   return false;
   return false;
 #endif
 #endif
 }
 }
-  
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: PandaSystem::get_distributor
 //     Function: PandaSystem::get_distributor
 //       Access: Published, Static
 //       Access: Published, Static
@@ -239,7 +239,7 @@ string PandaSystem::
 get_distributor() {
 get_distributor() {
   return PANDA_DISTRIBUTOR;
   return PANDA_DISTRIBUTOR;
 }
 }
-  
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: PandaSystem::get_compiler
 //     Function: PandaSystem::get_compiler
 //       Access: Published, Static
 //       Access: Published, Static
@@ -279,7 +279,7 @@ get_compiler() {
   return "unknown";
   return "unknown";
 #endif
 #endif
 }
 }
-  
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: PandaSystem::get_build_date
 //     Function: PandaSystem::get_build_date
 //       Access: Published, Static
 //       Access: Published, Static
@@ -291,7 +291,23 @@ string PandaSystem::
 get_build_date() {
 get_build_date() {
   return __DATE__ " " __TIME__;
   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
 //     Function: PandaSystem::get_platform
 //       Access: Published, Static
 //       Access: Published, Static
@@ -440,7 +456,7 @@ heap_trim(size_t pad) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: PandaSystem::output
 //     Function: PandaSystem::output
 //       Access: Published
 //       Access: Published
-//  Description: 
+//  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void PandaSystem::
 void PandaSystem::
 output(ostream &out) const {
 output(ostream &out) const {
@@ -450,7 +466,7 @@ output(ostream &out) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: PandaSystem::write
 //     Function: PandaSystem::write
 //       Access: Published
 //       Access: Published
-//  Description: 
+//  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void PandaSystem::
 void PandaSystem::
 write(ostream &out) const {
 write(ostream &out) const {
@@ -472,7 +488,7 @@ write(ostream &out) const {
   }
   }
 }
 }
 
 
-  
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: PandaSystem::get_global_ptr
 //     Function: PandaSystem::get_global_ptr
 //       Access: Published, Static
 //       Access: Published, Static
@@ -498,12 +514,12 @@ void PandaSystem::
 reset_system_names() {
 reset_system_names() {
   _system_names.clear();
   _system_names.clear();
   _system_names.reserve(_systems.size());
   _system_names.reserve(_systems.size());
-  
+
   Systems::const_iterator si;
   Systems::const_iterator si;
   for (si = _systems.begin(); si != _systems.end(); ++si) {
   for (si = _systems.begin(); si != _systems.end(); ++si) {
     _system_names.push_back((*si).first);
     _system_names.push_back((*si).first);
   }
   }
-  
+
   _system_names_dirty = false;
   _system_names_dirty = false;
 }
 }
 
 

+ 3 - 2
dtool/src/dtoolutil/pandaSystem.h

@@ -41,10 +41,11 @@ PUBLISHED:
   static int get_minor_version();
   static int get_minor_version();
   static int get_sequence_version();
   static int get_sequence_version();
   static bool is_official_version();
   static bool is_official_version();
-  
+
   static string get_distributor();
   static string get_distributor();
   static string get_compiler();
   static string get_compiler();
   static string get_build_date();
   static string get_build_date();
+  static string get_git_commit();
 
 
   static string get_platform();
   static string get_platform();
 
 
@@ -106,4 +107,4 @@ inline ostream &operator << (ostream &out, const PandaSystem &ps) {
 
 
 #endif
 #endif
 
 
-  
+

+ 17 - 0
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()

+ 11 - 3
makepanda/makepanda.py

@@ -61,6 +61,7 @@ DISTRIBUTOR=""
 VERSION=None
 VERSION=None
 DEBVERSION=None
 DEBVERSION=None
 RPMRELEASE="1"
 RPMRELEASE="1"
+GIT_COMMIT=None
 P3DSUFFIX=None
 P3DSUFFIX=None
 MAJOR_VERSION=None
 MAJOR_VERSION=None
 COREAPI_VERSION=None
 COREAPI_VERSION=None
@@ -121,7 +122,7 @@ signal.signal(signal.SIGINT, keyboardInterruptHandler)
 def usage(problem):
 def usage(problem):
     if (problem):
     if (problem):
         print("")
         print("")
-        print("Error parsing commandline input", problem)
+        print("Error parsing command-line input: %s" % (problem))
 
 
     print("")
     print("")
     print("Makepanda generates a 'built' subdirectory containing a")
     print("Makepanda generates a 'built' subdirectory containing a")
@@ -164,7 +165,7 @@ def usage(problem):
 def parseopts(args):
 def parseopts(args):
     global INSTALLER,RTDIST,RUNTIME,GENMAN,DISTRIBUTOR,VERSION
     global INSTALLER,RTDIST,RUNTIME,GENMAN,DISTRIBUTOR,VERSION
     global COMPRESSOR,THREADCOUNT,OSXTARGET,UNIVERSAL,HOST_URL
     global COMPRESSOR,THREADCOUNT,OSXTARGET,UNIVERSAL,HOST_URL
-    global DEBVERSION,RPMRELEASE,P3DSUFFIX
+    global DEBVERSION,RPMRELEASE,GIT_COMMIT,P3DSUFFIX
     global STRDXSDKVERSION, STRMSPLATFORMVERSION, BOOUSEINTELCOMPILER
     global STRDXSDKVERSION, STRMSPLATFORMVERSION, BOOUSEINTELCOMPILER
     longopts = [
     longopts = [
         "help","distributor=","verbose","runtime","osxtarget=",
         "help","distributor=","verbose","runtime","osxtarget=",
@@ -172,7 +173,7 @@ def parseopts(args):
         "version=","lzma","no-python","threads=","outputdir=","override=",
         "version=","lzma","no-python","threads=","outputdir=","override=",
         "static","host=","debversion=","rpmrelease=","p3dsuffix=",
         "static","host=","debversion=","rpmrelease=","p3dsuffix=",
         "directx-sdk=", "platform-sdk=", "use-icl",
         "directx-sdk=", "platform-sdk=", "use-icl",
-        "universal", "target=", "arch="]
+        "universal", "target=", "arch=", "git-commit="]
     anything = 0
     anything = 0
     optimize = ""
     optimize = ""
     target = None
     target = None
@@ -208,6 +209,7 @@ def parseopts(args):
             elif (option=="--host"): HOST_URL=value
             elif (option=="--host"): HOST_URL=value
             elif (option=="--debversion"): DEBVERSION=value
             elif (option=="--debversion"): DEBVERSION=value
             elif (option=="--rpmrelease"): RPMRELEASE=value
             elif (option=="--rpmrelease"): RPMRELEASE=value
+            elif (option=="--git-commit"): GIT_COMMIT=value
             elif (option=="--p3dsuffix"): P3DSUFFIX=value
             elif (option=="--p3dsuffix"): P3DSUFFIX=value
             # Backward compatibility, OPENGL was renamed to GL
             # Backward compatibility, OPENGL was renamed to GL
             elif (option=="--use-opengl"): PkgEnable("GL")
             elif (option=="--use-opengl"): PkgEnable("GL")
@@ -259,6 +261,9 @@ def parseopts(args):
     except:
     except:
         usage("Invalid setting for OPTIMIZE")
         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:
     if target is not None or target_arch is not None:
         SetTarget(target, target_arch)
         SetTarget(target, target_arch)
 
 
@@ -2399,6 +2404,9 @@ def CreatePandaVersionFiles():
     else:
     else:
         pandaversion_h += "\n#undef  PANDA_OFFICIAL_VERSION\n"
         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:
     if not RUNTIME:
         checkpandaversion_cxx = CHECKPANDAVERSION_CXX.replace("$VERSION1",str(version1))
         checkpandaversion_cxx = CHECKPANDAVERSION_CXX.replace("$VERSION1",str(version1))
         checkpandaversion_cxx = checkpandaversion_cxx.replace("$VERSION2",str(version2))
         checkpandaversion_cxx = checkpandaversion_cxx.replace("$VERSION2",str(version2))