# Note that 'force' here also implies test mode.
-def build_server(app, thisbuild, vcs, build_dir, output_dir, sdk_path, force):
+def build_server(app, thisbuild, vcs, build_dir, output_dir, force):
"""Do a build on the build server."""
import ssh
name, _ = lib.split('@')
if options.verbose:
print "Processing srclib '" + name + "'"
- srclibpaths.append((name, common.getsrclib(lib, 'build/srclib', sdk_path, basepath=True, prepare=False)))
+ srclibpaths.append((name, common.getsrclib(lib, 'build/srclib', basepath=True, prepare=False)))
# If one was used for the main source, add that too.
basesrclib = vcs.getsrclib()
if basesrclib:
# Prepare the source code...
root_dir, srclibpaths = common.prepare_source(vcs, app, thisbuild,
- build_dir, srclib_dir, extlib_dir, config['sdk_path'], config['ndk_path'],
- config['javacc_path'], config['mvn3'], onserver)
+ build_dir, srclib_dir, extlib_dir, onserver)
# We need to clean via the build tool in case the binary dirs are
# different from the default ones
# Run a build command if one is required...
if 'build' in thisbuild:
- cmd = thisbuild['build']
+ cmd = common.replace_config_vars(thisbuild['build'])
# Substitute source library paths into commands...
for name, libpath in srclibpaths:
libpath = os.path.relpath(libpath, root_dir)
cmd = cmd.replace('$$' + name + '$$', libpath)
- cmd = cmd.replace('$$SDK$$', config['sdk_path'])
- cmd = cmd.replace('$$NDK$$', config['ndk_path'])
- cmd = cmd.replace('$$MVN3$$', config['mvn3'])
if options.verbose:
print "Running 'build' commands in %s" % root_dir
- p = FDroidPopen(['bash', '-x', '-c', cmd],
- cwd=root_dir)
+ p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=root_dir)
if p.returncode != 0:
raise BuildException("Error running build command for %s:%s" %
# grabbing the source now.
vcs.gotorevision(thisbuild['commit'])
- build_server(app, thisbuild, vcs, build_dir, output_dir, config['sdk_path'], force)
+ build_server(app, thisbuild, vcs, build_dir, output_dir, force)
else:
build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_dir, tmp_dir, install, force, onserver)
return True
if options.verbose:
print "Getting {0} vcs interface for {1}".format(
app['Repo Type'], app['Repo'])
- vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir, config['sdk_path'])
+ vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir)
first = False
# caution, because it's inappropriate for many projects.
# Returns (None, "a message") if this didn't work, or (version, vercode) for
# the details of the current version.
-def check_tags(app, sdk_path):
+def check_tags(app):
try:
return (None, 'Tags update mode only works for git, hg, bzr and git-svn repositories currently', None)
# Set up vcs interface and make sure we have the latest code...
- vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir, sdk_path)
+ vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir)
vcs.gotorevision(None)
# caution, because it's inappropriate for many projects.
# Returns (None, "a message") if this didn't work, or (version, vercode) for
# the details of the current version.
-def check_repomanifest(app, sdk_path, branch=None):
+def check_repomanifest(app, branch=None):
try:
repotype = app['Repo Type']
# Set up vcs interface and make sure we have the latest code...
- vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir, sdk_path)
+ vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir)
if repotype == 'git':
if branch:
msg = "Could not scan app %s due to unknown error: %s" % (app['id'], traceback.format_exc())
return (None, msg)
-def check_repotrunk(app, sdk_path, branch=None):
+def check_repotrunk(app, branch=None):
try:
if app['Repo Type'] == 'srclib':
return (None, 'RepoTrunk update mode only makes sense in svn and git-svn repositories')
# Set up vcs interface and make sure we have the latest code...
- vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir, sdk_path)
+ vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir)
vcs.gotorevision(None)
vercode = None
mode = app['Update Check Mode']
if mode == 'Tags':
- (version, vercode, tag) = check_tags(app, config['sdk_path'])
+ (version, vercode, tag) = check_tags(app)
elif mode == 'RepoManifest':
- (version, vercode) = check_repomanifest(app, config['sdk_path'])
+ (version, vercode) = check_repomanifest(app)
elif mode.startswith('RepoManifest/'):
- (version, vercode) = check_repomanifest(app, config['sdk_path'], mode[13:])
+ (version, vercode) = check_repomanifest(app, mode[13:])
elif mode == 'RepoTrunk':
- (version, vercode) = check_repotrunk(app, config['sdk_path'])
+ (version, vercode) = check_repotrunk(app)
elif mode == 'HTTP':
(version, vercode) = check_http(app)
elif mode == 'Static':
else:
app_dir = os.path.join('build/', app['id'])
- vcs = common.getvcs(app["Repo Type"], app["Repo"], app_dir,
- config['sdk_path'])
+ vcs = common.getvcs(app["Repo Type"], app["Repo"], app_dir)
vcs.gotorevision(tag)
flavour = None
return config
-def getvcs(vcstype, remote, local, sdk_path):
+def getvcs(vcstype, remote, local):
if vcstype == 'git':
- return vcs_git(remote, local, sdk_path)
+ return vcs_git(remote, local)
if vcstype == 'svn':
- return vcs_svn(remote, local, sdk_path)
+ return vcs_svn(remote, local)
if vcstype == 'git-svn':
- return vcs_gitsvn(remote, local, sdk_path)
+ return vcs_gitsvn(remote, local)
if vcstype == 'hg':
- return vcs_hg(remote, local, sdk_path)
+ return vcs_hg(remote, local)
if vcstype == 'bzr':
- return vcs_bzr(remote, local, sdk_path)
+ return vcs_bzr(remote, local)
if vcstype == 'srclib':
if local != 'build/srclib/' + remote:
raise VCSException("Error: srclib paths are hard-coded!")
- return getsrclib(remote, 'build/srclib', sdk_path, raw=True)
+ return getsrclib(remote, 'build/srclib', raw=True)
raise VCSException("Invalid vcs type " + vcstype)
def getsrclibvcs(name):
return parse_srclib(srclib_path)['Repo Type']
class vcs:
- def __init__(self, remote, local, sdk_path):
-
- self.sdk_path = sdk_path
+ def __init__(self, remote, local):
# svn, git-svn and bzr may require auth
self.username = None
# Returns the path to it. Normally this is the path to be used when referencing
# it, which may be a subdirectory of the actual project. If you want the base
# directory of the project, pass 'basepath=True'.
-def getsrclib(spec, srclib_dir, sdk_path, ndk_path="", mvn3="", basepath=False, raw=False, prepare=True, preponly=False):
+def getsrclib(spec, srclib_dir, basepath=False, raw=False, prepare=True, preponly=False):
if raw:
name = spec
sdir = os.path.join(srclib_dir, name)
if not preponly:
- vcs = getvcs(srclib["Repo Type"], srclib["Repo"], sdir, sdk_path)
+ vcs = getvcs(srclib["Repo Type"], srclib["Repo"], sdir)
vcs.srclib = (name, sdir)
if ref:
vcs.gotorevision(ref)
if prepare:
if srclib["Prepare"] is not None:
- cmd = srclib["Prepare"].replace('$$SDK$$', sdk_path)
- cmd = cmd.replace('$$NDK$$', ndk_path).replace('$$MVN$$', mvn3)
+ cmd = replace_config_vars(srclib["Prepare"])
p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=libdir)
if p.returncode != 0:
if srclib["Update Project"] == "Yes":
print "Updating srclib %s at path %s" % (name, libdir)
- if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
+ if subprocess.call([os.path.join(config['sdk_path'], 'tools', 'android'),
'update', 'project', '-p', libdir]) != 0:
raise BuildException( 'Error updating ' + name + ' project')
# 'build/srclib'
# 'extlib_dir' - the path to the external libraries directory, usually
# 'build/extlib'
-# 'sdk_path' - the path to the Android SDK
-# 'ndk_path' - the path to the Android NDK
-# 'javacc_path' - the path to javacc
-# 'mvn3' - the path to the maven 3 executable
# Returns the (root, srclibpaths) where:
# 'root' is the root directory, which may be the same as 'build_dir' or may
# be a subdirectory of it.
# 'srclibpaths' is information on the srclibs being used
-def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, sdk_path, ndk_path, javacc_path, mvn3, onserver=False):
+def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=False):
# Optionally, the actual app source can be in a subdirectory...
if 'subdir' in build:
# Run an init command if one is required...
if 'init' in build:
- cmd = build['init']
- cmd = cmd.replace('$$SDK$$', sdk_path)
- cmd = cmd.replace('$$NDK$$', ndk_path)
- cmd = cmd.replace('$$MVN$$', mvn3)
+ cmd = replace_config_vars(build['init'])
if options.verbose:
print "Running 'init' commands in %s" % root_dir
if (updatemode != 'no'
and build.get('maven', 'no') == 'no'
and build.get('gradle', 'no') == 'no'):
- parms = [os.path.join(sdk_path, 'tools', 'android'),
+ parms = [os.path.join(config['sdk_path'], 'tools', 'android'),
'update', 'project']
if 'target' in build and build['target']:
parms += ['-t', build['target']]
re.S|re.M).group(1)
props += "sdk-location=%s\n" % sdkloc
else:
- props += "sdk.dir=%s\n" % sdk_path
- props += "sdk-location=%s\n" % sdk_path
+ props += "sdk.dir=%s\n" % config['sdk_path']
+ props += "sdk-location=%s\n" % ['sdk_path']
# Add ndk location...
- props += "ndk.dir=%s\n" % ndk_path
- props += "ndk-location=%s\n" % ndk_path
+ props += "ndk.dir=%s\n" % config['ndk_path']
+ props += "ndk-location=%s\n" % config['ndk_path']
# Add java.encoding if necessary...
if 'encoding' in build:
props += "java.encoding=%s\n" % build['encoding']
for lib in build['srclibs'].split(';'):
lib = lib.strip()
name, _ = lib.split('@')
- srclibpaths.append((name, getsrclib(lib, srclib_dir, sdk_path, ndk_path, mvn3, preponly=onserver)))
+ srclibpaths.append((name, getsrclib(lib, srclib_dir, preponly=onserver)))
basesrclib = vcs.getsrclib()
# If one was used for the main source, add that too.
if basesrclib:
# Run a pre-build command if one is required...
if 'prebuild' in build:
- cmd = build['prebuild']
+ cmd = replace_config_vars(build['prebuild'])
# Substitute source library paths into prebuild commands...
for name, libpath in srclibpaths:
libpath = os.path.relpath(libpath, root_dir)
cmd = cmd.replace('$$' + name + '$$', libpath)
- cmd = cmd.replace('$$SDK$$', sdk_path)
- cmd = cmd.replace('$$NDK$$', ndk_path)
- cmd = cmd.replace('$$MVN3$$', mvn3)
+
if options.verbose:
print "Running 'prebuild' commands in %s" % root_dir
elif not any(s in line for s in (' signingConfig ',)):
o.write(line)
+def replace_config_vars(cmd):
+ cmd = cmd.replace('$$SDK$$', config['sdk_path'])
+ cmd = cmd.replace('$$NDK$$', config['ndk_path'])
+ cmd = cmd.replace('$$MVN3$$', config['mvn3'])
+ return cmd
+
build_dir = 'build/' + app['id']
# Set up vcs interface and make sure we have the latest code...
- vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir,
- config['sdk_path'])
+ vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir)
for thisbuild in app['builds']:
# Prepare the source code...
root_dir, _ = common.prepare_source(vcs, app, thisbuild,
- build_dir, srclib_dir, extlib_dir,
- config['sdk_path'], config['ndk_path'],
- config['javacc_path'], config['mvn3'],
- False)
+ build_dir, srclib_dir, extlib_dir, False)
# Do the scan...
buildprobs = common.scan_source(build_dir, root_dir, thisbuild)