Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

first stab at a global build script for hudson-based configurations. …

…right now this builds, packages, versions, and copies the binary into a place where hudson can SCP or copy into a more "global" location for build results
  • Loading branch information...
commit 0631685fa461cf33dbe67b277d2fe88aa636a40a 1 parent d468d98
@marshall authored
View
1  .gitignore
@@ -5,3 +5,4 @@ build/win32
Debug
.vimdir
*.pyc
+distribution
View
77 build/hudson/build.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+
+import os, sys, re
+import getopt, subprocess
+import shutil, distutils.dir_util as dir_util
+import hudson, version
+
+hudson_config = hudson.HudsonConfig()
+
+workspace_dir = os.environ["WORKSPACE"]
+kroll_dir = os.path.join(workspace_dir, "kroll")
+hudson_dir = os.getcwd()
+build_dir = os.path.join(workspace_dir, 'build', hudson_config.platform.shortname())
+package_dir = os.path.join(workspace_dir, 'distribution', hudson_config.get_platform_id())
+
+try:
+ os.makedirs(package_dir)
+except:
+ pass
+
+def usage():
+ print "--help: print this usage"
+ print "--release: build in release mode (without debugging symbols)"
+ print "--version=X set the version number for a release build"
+ sys.exit(1)
+
+try:
+ opts, args = getopt.getopt(sys.argv[1:], "hrv:", ["help", "release", "version="])
+except getopt.GetoptError, err:
+ print str(err)
+ usage()
+
+release = False
+version = str(version.MAJOR) + "." + str(version.MINOR) + "." + str(version.MICRO) + "."
+version += str(hudson_config.get_git_revision())
+
+for option, value in opts:
+ if option in ("-h", "--help"):
+ usage()
+ elif option in ("-r", "--release"):
+ release = True
+ elif option in ("-v", "--version"):
+ version = value
+
+
+dir_util.remove_tree(build_dir)
+
+build_command = "scons -D"
+if not release:
+ build_command += " debug=1"
+
+package_command = build_command + " package=1"
+build_testsuite_command = build_command + " testsuite=1"
+
+os.system(build_command)
+os.system(package_command)
+
+titanium_runtime = None
+if hudson_config.platform.is_linux():
+ titanium_runtime = "titanium_runtime.bin"
+elif hudson_config.platform.is_win32():
+ titanium_runtime = "titanium_runtime.exe"
+elif hudson_config.platform.is_osx():
+ titanium_runtime = "titanium_runtime.dmg"
+
+runtime_target = titanium_runtime.replace("titanium_runtime.", "titanium_runtime_%s." % version)
+shutil.copy(os.path.join(build_dir, titanium_runtime), os.path.join(package_dir, runtime_target))
+
+# TODO: enable testsuite
+#os.system(build_testsuite_command)
+#
+#if hudson_config.platform.is_linux():
+# os.system(os.path.join(build_dir, "titanium_testsuite", "titanium_testsuite"))
+#elif hudson_config.platform.is_win32():
+# os.system(os.path.join(build_dir, "titanium_testsuite", "titanium_testsuite.exe"))
+#elif hudson_config.platform.is_osx():
+# os.system(os.path.join(build_dir, "titanium_testsuite", "Contents", "MacOS", "titanium_testsuite"))
View
61 build/hudson/hudson.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env py
+##
+## Hudson build script -- mostly os / platform configuration
+##
+
+import os, re, platform
+import subprocess
+
+class Platform:
+ def __init__(self):
+ if 'Darwin' in platform.platform():
+ mac_ver = platform.mac_ver()
+ version = mac_ver[0][0:-2]
+ self.id = 'MacOSX-%s-Universal' % version
+ elif 'Windows' in platform.platform():
+ self.id = 'Windows'
+ elif 'Linux' in platform.platform():
+ if os.path.exists('/etc/lsb-release'):
+ self.parse_lsb_release()
+ dist = platform.dist()
+ if dist[0] is 'fedora':
+ self.id = 'Fedora-%s-%s' % (dist[1], self.unix_arch())
+
+ def unix_arch(self):
+ arch = os.uname()[4]
+ if arch is 'x86_64':
+ return '64bit'
+ return '32bit'
+
+ def parse_lsb_release(self):
+ lsb_release = open('/etc/lsb-release', 'r')
+ lines = lsb_release.readlines()
+ distro_id = None
+ distro_release = None
+ for line in lines:
+ if 'DISTRIBUTION_ID' in line:
+ m = re.match('DISTRIBUTION_ID=(.+)', line)
+ distro_id = m.group(1)
+ elif 'DISTRIBUTION_RELEASE' in line:
+ m = re.match('DISTRIBUTION_RELEASE=(.+)', line)
+ distro_release = m.group(1)
+ self.id = '%s-%s-%s' % (distro_id, distro_release, self.unix_arch())
+
+ def is_linux(self): return 'Linux' in platform.platform()
+ def is_osx(self): return 'Darwin' in platform.platform()
+ def is_win32(self): return 'Windows' in platform.platform()
+ def shortname(self):
+ if self.is_linux(): return "linux"
+ elif self.is_osx(): return "osx"
+ elif self.is_win32(): return "win32"
+
+class HudsonConfig:
+ def __init__(self):
+ self.platform = Platform()
+
+ def get_platform_id(self):
+ return self.platform.id
+
+ def get_git_revision(self):
+ log_lines = subprocess.Popen(['git', 'log', '--pretty=oneline'], stdout=subprocess.PIPE).communicate()[0]
+ return len(log_lines.splitlines())
View
3  build/hudson/version.py
@@ -0,0 +1,3 @@
+MAJOR = 0
+MINOR = 3
+MICRO = 0
Please sign in to comment.
Something went wrong with that request. Please try again.