#!/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.beta = None
+ 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
-
- b = s.find("beta")
- if b != -1:
- self.beta = int(s[b+4:])
- s = s[0:b]
p = s.split('.')
self.major = int(p[0])
self.minor = int(p[1])
+ if len(p) == 3:
+ self.micro = int(p[2])
+ else:
+ self.micro = 0
- def bump(self):
+ def bump_minor(self):
self.minor += 1
- self.pre = False
- self.beta = None
+ self.micro = 0
- def to_pre(self):
- self.pre = True
- self.beta = None
+ def bump_micro(self):
+ self.micro += 1
- def bump_and_to_pre(self):
- self.bump()
- self.pre = True
- self.beta = None
+ def to_devel(self):
+ self.devel = True
def to_release(self):
- self.pre = False
- self.beta = None
-
- def bump_beta(self):
- if self.pre:
- self.pre = False
- self.beta = 1
- elif self.beta is not None:
- self.beta += 1
- elif self.beta is None:
- self.beta = 1
+ self.devel = False
def __str__(self):
- s = '%d.%02d' % (self.major, self.minor)
- if self.beta is not None:
- s += 'beta%d' % self.beta
- elif self.pre:
- s += 'pre'
+ s = '%d.%02d.%d' % (self.major, self.minor, self.micro)
+ if self.devel:
+ s += 'devel'
return s
# Make the options to pass in from the option_defaults of the thing
# we are building and any options specified by the parent.
- # The presence of option_defaults() is taken to mean that this
- # cscript understands and expects options
options = {}
if 'option_defaults' in dep.cscript:
options = dep.cscript['option_defaults']()
for k, v in d[2].iteritems():
options[k] = v
- self.build(dep, options)
- else:
- # Backwards compatibility
- self.build(dep)
+ self.build(dep, options)
os.chdir(cwd)
def build(self, project, options=None):
- if options is not 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
parser.add_argument('command')
parser.add_argument('-p', '--project', help='project name')
parser.add_argument('-d', '--directory', help='directory within project repo', default='.')
-parser.add_argument('--beta', help='beta release', action='store_true')
-parser.add_argument('--full', help='full release', action='store_true')
+parser.add_argument('--minor', help='minor version number bump', action='store_true')
+parser.add_argument('--micro', help='micro version number bump', action='store_true')
parser.add_argument('-c', '--checkout', help='string to pass to git for checkout')
parser.add_argument('-o', '--output', help='output directory', default='.')
parser.add_argument('-q', '--quiet', help='be quiet', action='store_true')
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.full is False and args.beta is False:
- raise Error('you must specify --full or --beta')
+ if args.minor is False and args.micro is False:
+ raise Error('you must specify --minor or --micro')
target = SourceTarget()
project.checkout(target)
version = project.version
- if args.full:
- version.to_release()
+ version.to_release()
+ if args.minor:
+ version.bump_minor()
else:
- version.bump_beta()
+ 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.full:
- version.bump_and_to_pre()
- set_version_in_wscript(version)
- command('git commit -a -m "Bump version"')
-
+ version.to_devel()
+ set_version_in_wscript(version)
+ command('git commit -a -m "Bump version"')
command('git push')
command('git push --tags')
if len(l) > 0 and l[0] == "\t":
s = l.split()
if len(s) == 4 and s[1] == "Version" and s[3] == "released.":
- if not "beta" in s[2]:
+ v = Version(s[2])
+ if v.micro == 0:
if last is not None and len(changes) > 0:
print >>html,"<h2>Changes between version %s and %s</h2>" % (s[2], last)
print >>html,"<ul>"
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:]