#!/usr/bin/python
-# Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+# Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
import datetime
import subprocess
import re
+import copy
+import inspect
class Error(Exception):
def __init__(self, value):
class Version:
def __init__(self, s):
- self.pre = False
+ self.devel = False
if s.startswith("'"):
s = s[1:]
if s.endswith("'"):
s = s[0:-1]
+ if s.endswith('devel'):
+ s = s[0:-5]
+ self.devel = True
+
if s.endswith('pre'):
s = s[0:-3]
- self.pre = True
p = s.split('.')
self.major = int(p[0])
def bump_minor(self):
self.minor += 1
self.micro = 0
- self.pre = False
def bump_micro(self):
self.micro += 1
- self.pre = False
- def to_pre(self):
- self.pre = True
+ def to_devel(self):
+ self.devel = True
def to_release(self):
- self.pre = False
+ self.devel = False
def __str__(self):
s = '%d.%02d.%d' % (self.major, self.minor, self.micro)
- if self.pre:
- s += 'pre'
+ if self.devel:
+ s += 'devel'
return s
os.chdir(cwd)
- def build(self, project, options):
- project.cscript['build'](self, options)
+ def build(self, project, options=None):
+ variables = copy.copy(self.variables)
+ print 'Target %s builds %s with %s' % (self.platform, project.name, self.variables)
+ if len(inspect.getargspec(project.cscript['build']).args) == 2:
+ project.cscript['build'](self, options)
+ else:
+ project.cscript['build'](self)
+ self.variables = variables
def package(self, project):
project.checkout(self)
self.build_dependencies(project)
- project.cscript['build'](self)
+ self.build(project)
return project.cscript['package'](self, project.version)
def test(self, project):
project.checkout(self)
self.build_dependencies(project)
- project.cscript['build'](self)
+ self.build(project)
project.cscript['test'](self)
def set(self, a, b):
+ print "Target set %s=%s" % (a, b)
self.variables[a] = b
def unset(self, a):
self.set('CXXFLAGS', '-I%s/include' % self.work_dir_cscript())
self.set('LINKFLAGS', '-L%s/lib' % self.work_dir_cscript())
- self.set('PKG_CONFIG_PATH', '%s/lib/pkgconfig' % self.work_dir_cscript())
+ self.set('PKG_CONFIG_PATH', '%s/lib/pkgconfig:/usr/local/lib/pkgconfig' % self.work_dir_cscript())
self.set('PATH', '%s:/usr/local/bin' % (os.environ['PATH']))
def work_dir_cdist(self):
# windows-{32,64}
# or ubuntu-version-{32,64}
# or debian-version-{32,64}
+# or centos-version-{32,64}
# or osx-{32,64}
# or source
# @param debug True to build with debugging symbols (where possible)
target = None
if s.startswith('windows-'):
target = WindowsTarget(int(s.split('-')[1]), work)
- elif s.startswith('ubuntu-') or s.startswith('debian-'):
+ elif s.startswith('ubuntu-') or s.startswith('debian-') or s.startswith('centos-'):
p = s.split('-')
if len(p) != 3:
print >>sys.stderr,"Bad Linux target name `%s'; must be something like ubuntu-12.04-32 (i.e. distro-version-bits)" % s
packages = [packages]
if target.platform == 'linux':
- out = '%s/%s-%d' % (args.output, target.version, target.bits)
+ out = '%s/%s-%s-%d' % (args.output, target.distro, target.version, target.bits)
try:
os.makedirs(out)
except:
for p in packages:
copyfile(p, '%s/%s' % (args.output, os.path.basename(p)))
- target.cleanup()
+ if not args.keep:
+ target.cleanup()
elif args.command == 'release':
if args.minor is False and args.micro is False:
version = project.version
version.to_release()
+ if args.minor:
+ version.bump_minor()
+ else:
+ version.bump_micro()
set_version_in_wscript(version)
append_version_to_changelog(version)
command('git commit -a -m "Bump version"')
command('git tag -m "v%s" v%s' % (version, version))
- if args.minor:
- version.bump_minor()
- else:
- version.bump_micro()
- version.to_pre()
-
+ version.to_devel()
set_version_in_wscript(version)
command('git commit -a -m "Bump version"')
command('git push')
if m:
tags = m.group(1).split(', ')
for t in tags:
+ s = t.split()
+ if len(s) > 1:
+ t = s[1]
if len(t) > 0 and t[0] == 'v':
latest = t[1:]