-#!/usr/bin/python
+#!/usr/bin/python3
# Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
#
def __init__(self):
self.options = [ Option('mxe_prefix'),
Option('git_prefix'),
+ Option('git_reference'),
Option('osx_environment_prefix'),
Option('osx_sdk_prefix'),
Option('osx_sdk'),
log_normal("Deprecated cscript package() method with no options parameter")
packages = tree.call('package', tree.version)
- if isinstance(packages, (str, unicode)):
- copyfile(packages, os.path.join(output_dir, os.path.basename(devel_to_git(tree.git_commit, packages))))
- else:
+ if isinstance(packages, list):
for p in packages:
copyfile(p, os.path.join(output_dir, os.path.basename(devel_to_git(tree.git_commit, p))))
+ else:
+ copyfile(packages, os.path.join(output_dir, os.path.basename(devel_to_git(tree.git_commit, packages))))
def build(self, project, checkout, options):
tree = globals.trees.get(project, checkout, self)
opts += '-v %s:%s ' % (m, m)
if self.privileged:
opts += '--privileged=true '
+ if config.has('git_reference'):
+ opts += '-v %s:%s ' % (config.get('git_reference'), config.get('git_reference'))
if self.ccache:
- opts += "-e CCACHE_DIR=/ccache --volumes-from ccache-%s" % self.image
+ opts += "-e CCACHE_DIR=/ccache/%s --mount source=ccache,target=/ccache" % self.image
tag = self.image
if config.has('docker_hub_repository'):
tree = globals.trees.get(project, checkout, self)
with TreeDirectory(tree):
- if len(inspect.getargspec(tree.cscript['package']).args) == 3:
+ if len(inspect.getfullargspec(tree.cscript['package']).args) == 3:
packages = tree.call('package', tree.version, options)
else:
log_normal("Deprecated cscript package() method with no options parameter")
if globals.quiet:
flags = '-q'
redirect = '>/dev/null'
- command('git clone %s %s/%s.git %s/src/%s' % (flags, config.get('git_prefix'), self.name, target.directory, self.name))
+ if config.has('git_reference'):
+ ref = '--reference-if-able %s/%s.git' % (config.get('git_reference'), self.name)
+ else:
+ ref = ''
+ command('git clone %s %s %s/%s.git %s/src/%s' % (flags, ref, config.get('git_prefix'), self.name, target.directory, self.name))
os.chdir('%s/src/%s' % (target.directory, self.name))
spec = self.specifier
exec(open('%s/cscript' % proj).read(), self.cscript)
# cscript can include submodules = False to stop submodules being fetched
- if not 'submodules' in self.cscript or self.cscript['submodules'] == True:
- command('git submodule init --quiet')
- command('git submodule update --quiet')
+ if (not 'submodules' in self.cscript or self.cscript['submodules'] == True) and os.path.exists('.gitmodules'):
+ command('git submodule --quiet init')
+ paths = command_and_read('git config --file .gitmodules --get-regexp path')
+ urls = command_and_read('git config --file .gitmodules --get-regexp url')
+ for path, url in zip(paths, urls):
+ path = path.split(' ')[1]
+ url = url.split(' ')[1]
+ ref = ''
+ if config.has('git_reference'):
+ ref_path = os.path.join(config.get('git_reference'), os.path.basename(url))
+ if os.path.exists(ref_path):
+ ref = '--reference %s' % ref_path
+ command('git submodule --quiet update %s %s' % (ref, path))
if os.path.exists('%s/wscript' % proj):
v = read_wscript_variable(proj, "VERSION");
if not 'dependencies' in self.cscript:
return
- if len(inspect.getargspec(self.cscript['dependencies']).args) == 2:
+ if len(inspect.getfullargspec(self.cscript['dependencies']).args) == 2:
self_options = copy.copy(options)
self.add_defaults(self_options)
deps = self.call('dependencies', self_options)