# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+from __future__ import print_function
import os
import sys
import shutil
def get(self, k):
for o in self.options:
if o.key == k:
+ if o.value is None:
+ raise Error('Required setting %s not found' % k)
return o.value
- raise Error('Required setting %s not found' % k)
-
def set(self, k, v):
for o in self.options:
o.offer(k, v)
def log(m):
if not globals.quiet:
- print '\x1b[33m* %s\x1b[0m' % m
+ print('\x1b[33m* %s\x1b[0m' % m)
def scp_escape(n):
s = n.split(':')
s = l.split()
if len(s) == 3 and s[0] == "VERSION":
- print "Writing %s" % version
- print >>o,"VERSION = '%s'" % version
+ print("Writing %s" % version)
+ print("VERSION = '%s'" % version, file=o)
else:
- print >>o,l,
+ print(l, file=o, end="")
f.close()
o.close()
tree.build(tree)
return tree.call('package', tree.version), tree.git_commit
- def test(self, tree):
+ def test(self, tree, test):
+ """test is the test case to run, or None"""
tree.build_dependencies()
tree.build()
- return tree.call('test')
+ return tree.call('test', test)
def set(self, a, b):
self.variables[a] = b
def variables_string(self, escaped_quotes=False):
e = ''
- for k, v in self.variables.iteritems():
+ for k, v in self.variables.items():
if escaped_quotes:
v = v.replace('"', '\\"')
e += '%s=%s ' % (k, v)
#
class WindowsTarget(Target):
- def __init__(self, bits, directory=None):
+ def __init__(self, version, bits, directory=None):
super(WindowsTarget, self).__init__('windows', directory)
+ self.version = version
self.bits = bits
self.windows_prefix = '%s/%d' % (config.get('windows_environment_prefix'), self.bits)
self.set('CXXFLAGS', '-I%s/include' % self.directory)
self.set('CPPFLAGS', '')
self.set('LINKFLAGS', '-L%s/lib' % self.directory)
- self.set('PKG_CONFIG_PATH', '%s/lib/pkgconfig:/usr/local/lib/pkgconfig' % self.directory)
+ self.set('PKG_CONFIG_PATH',
+ '%s/lib/pkgconfig:%s/lib64/pkgconfig:/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig' % (self.directory, self.directory))
self.set('PATH', '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin')
class ChrootTarget(LinuxTarget):
def target_factory(s, debug, work):
target = None
if s.startswith('windows-'):
- target = WindowsTarget(int(s.split('-')[1]), work)
+ x = s.split('-')
+ if len(x) == 2:
+ target = WindowsTarget(None, int(x[1]), work)
+ elif len(x) == 3:
+ target = WindowsTarget(x[1], int(x[2]), work)
+ else:
+ raise Error("Bad Windows target name `%s'")
elif s.startswith('ubuntu-') or s.startswith('debian-') or s.startswith('centos-'):
p = s.split('-')
if len(p) != 3:
raise Error("Bad Linux target name `%s'; must be something like ubuntu-12.04-32 (i.e. distro-version-bits)" % s)
target = ChrootTarget(p[0], p[1], int(p[2]), work)
+ elif s.startswith('arch-'):
+ p = s.split('-')
+ if len(p) != 2:
+ raise Error("Bad Arch target name `%s'; must be arch-32 or arch-64")
+ target = ChrootTarget(p[0], None, p[1], work)
elif s == 'raspbian':
target = ChrootTarget(s, None, None, work)
elif s == 'host':
+ if command_and_read('uname -m').read().strip() == 'x86_64':
+ bits = 64
+ else:
+ bits = 32
try:
f = open('/etc/fedora-release', 'r')
l = f.readline().strip().split()
- if command_and_read('uname -m').read().strip() == 'x86_64':
- bits = 64
- else:
- bits = 32
target = HostTarget("fedora", l[2], bits, work)
except Exception as e:
- raise Error("could not identify distribution for `host' target (%s)" % e)
+ if os.path.exists('/etc/arch-release'):
+ target = HostTarget("arch", None, bits, work)
+ else:
+ raise Error("could not identify distribution for `host' target (%s)" % e)
elif s.startswith('osx-'):
target = OSXSingleTarget(int(s.split('-')[1]), work)
elif s == 'osx':
proj = '%s/src/%s' % (target.directory, self.name)
self.cscript = {}
- execfile('%s/cscript' % proj, self.cscript)
+ exec(open('%s/cscript' % proj).read(), self.cscript)
if os.path.exists('%s/wscript' % proj):
v = read_wscript_variable(proj, "VERSION");
if 'option_defaults' in dep.cscript:
options = dep.cscript['option_defaults']()
if len(d) > 2:
- for k, v in d[2].iteritems():
+ for k, v in d[2].items():
options[k] = v
dep.build(options)
one_of = "Command is one of:\n"
summary = ""
- for k, v in commands.iteritems():
+ for k, v in commands.items():
one_of += "\t%s\t%s\n" % (k, v)
summary += k + " "
parser.add_argument('--debug', help='build with debugging symbols where possible', action='store_true')
parser.add_argument('-w', '--work', help='override default work directory')
parser.add_argument('-g', '--git-prefix', help='override configured git prefix')
+ parser.add_argument('--test', help='name of test to run (with `test''), defaults to all')
args = parser.parse_args()
# Override configured stuff
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>"
+ print("<h2>Changes between version %s and %s</h2>" % (s[2], last), file=html)
+ print("<ul>", file=html)
for c in changes:
- print >>html,"<li>%s" % c
- print >>html,"</ul>"
+ print("<li>%s" % c, file=html)
+ print("</ul>", file=html)
last = s[2]
changes = []
versions -= 1
if args.major is None or v.major == args.major:
latest = v
- print latest
+ print(latest)
target.cleanup()
elif globals.command == 'test':
target = target_factory(args.target, args.debug, args.work)
tree = globals.trees.get(args.project, args.checkout, target)
with TreeDirectory(tree):
- target.test(tree)
+ target.test(tree, args.test)
except Error as e:
if target is not None:
target.cleanup()
target = SourceTarget()
tree = globals.trees.get(args.project, args.checkout, target)
with TreeDirectory(tree):
- print command_and_read('git rev-parse HEAD').readline().strip()[:7]
+ print(command_and_read('git rev-parse HEAD').readline().strip()[:7])
target.cleanup()
elif globals.command == 'checkout':
try:
main()
except Error as e:
- print >>sys.stderr,'cdist: %s' % str(e)
+ print('cdist: %s' % str(e), file=sys.stderr)
sys.exit(1)