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'),
self.set('CCACHE_BASEDIR', os.path.realpath(self.directory))
self.set('CCACHE_NOHASHDIR', '')
else:
- self.directory = directory
+ self.directory = os.path.realpath(directory)
self.rmdir = False
return ''
return '-u %s' % getpass.getuser()
+ def _mount_option(self, d):
+ return '-v %s:%s ' % (os.path.realpath(d), os.path.realpath(d))
+
def setup(self):
- opts = '-v %s:%s ' % (self.directory, self.directory)
+ opts = self._mount_option(self.directory)
for m in self.mounts:
- opts += '-v %s:%s ' % (m, m)
+ opts += self._mount_option(m)
+ if config.has('git_reference'):
+ opts += self._mount_option(config.get('git_reference'))
if self.privileged:
opts += '--privileged=true '
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'):
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");