Add NDK r10d, this time alongside r9b

Specified per-build with ndk=<version> defaulting to the oldest, r9b.
This commit is contained in:
Daniel Martí 2015-01-03 00:02:54 +01:00
parent 43092407a3
commit f60f1bc59e
9 changed files with 130 additions and 64 deletions

View file

@ -452,13 +452,22 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
"""Do a build locally."""
if thisbuild['buildjni'] and thisbuild['buildjni'] != ['no']:
if not config['ndk_path']:
logging.critical("$ANDROID_NDK is not set!")
if not thisbuild['ndk_path']:
logging.critical("Android NDK version '%s' could not be found!" % thisbuild['ndk'])
logging.critical("Configured versions:")
for k, v in config['ndk_paths'].iteritems():
if k.endswith("_orig"):
continue
logging.critical(" %s: %s" % (k, v))
sys.exit(3)
elif not os.path.isdir(config['sdk_path']):
logging.critical("$ANDROID_NDK points to a non-existing directory!")
elif not os.path.isdir(thisbuild['ndk_path']):
logging.critical("Android NDK '%s' is not a directory!" % thisbuild['ndk_path'])
sys.exit(3)
# Set up environment vars that depend on each build
for n in ['ANDROID_NDK', 'NDK']:
common.env[n] = thisbuild['ndk_path']
# Prepare the source code...
root_dir, srclibpaths = common.prepare_source(vcs, app, thisbuild,
build_dir, srclib_dir,
@ -551,7 +560,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
# Run a build command if one is required...
if thisbuild['build']:
logging.info("Running 'build' commands in %s" % root_dir)
cmd = common.replace_config_vars(thisbuild['build'])
cmd = common.replace_config_vars(thisbuild['build'], thisbuild)
# Substitute source library paths into commands...
for name, number, libpath in srclibpaths:
@ -571,7 +580,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
if jni_components == ['yes']:
jni_components = ['']
cmd = [os.path.join(config['ndk_path'], "ndk-build"), "-j1"]
cmd = [os.path.join(thisbuild['ndk_path'], "ndk-build"), "-j1"]
for d in jni_components:
if d:
logging.info("Building native code in '%s'" % d)
@ -644,8 +653,8 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
modules = bconfig.get('app', 'requirements').split(',')
cmd = 'ANDROIDSDK=' + config['sdk_path']
cmd += ' ANDROIDNDK=' + config['ndk_path']
cmd += ' ANDROIDNDKVER=r9'
cmd += ' ANDROIDNDK=' + thisbuild['ndk_path']
cmd += ' ANDROIDNDKVER=' + thisbuild['ndk']
cmd += ' ANDROIDAPI=' + str(bconfig.get('app', 'android.api'))
cmd += ' VIRTUALENV=virtualenv'
cmd += ' ./distribute.sh'
@ -1042,7 +1051,7 @@ def main():
# Set up vcs interface and make sure we have the latest code...
logging.debug("Getting {0} vcs interface for {1}"
.format(app['Repo Type'], app['Repo']))
vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir)
vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir, build)
first = False

View file

@ -41,7 +41,10 @@ env = None
default_config = {
'sdk_path': "$ANDROID_HOME",
'ndk_path': "$ANDROID_NDK",
'ndk_paths': {
'r9b': None,
'r10d': "$ANDROID_NDK"
},
'build_tools': "21.1.2",
'ant': "ant",
'mvn3': "mvn",
@ -82,14 +85,31 @@ def fill_config_defaults(thisconfig):
thisconfig[k] = v
# Expand paths (~users and $vars)
for k in ['sdk_path', 'ndk_path', 'ant', 'mvn3', 'gradle', 'keystore', 'repo_icon']:
def expand_path(path):
if path is None:
return None
orig = path
path = os.path.expanduser(path)
path = os.path.expandvars(path)
if orig == path:
return None
return path
for k in ['sdk_path', 'ant', 'mvn3', 'gradle', 'keystore', 'repo_icon']:
v = thisconfig[k]
orig = v
v = os.path.expanduser(v)
v = os.path.expandvars(v)
if orig != v:
thisconfig[k] = v
thisconfig[k + '_orig'] = orig
exp = expand_path(v)
if exp is not None:
thisconfig[k] = exp
thisconfig[k + '_orig'] = v
for k in ['ndk_paths']:
d = thisconfig[k]
for k2 in d.copy():
v = d[k2]
exp = expand_path(v)
if exp is not None:
thisconfig[k][k2] = exp
thisconfig[k][k2 + '_orig'] = v
def read_config(opts, config_file='config.py'):
@ -135,8 +155,6 @@ def read_config(opts, config_file='config.py'):
env = os.environ
for n in ['ANDROID_HOME', 'ANDROID_SDK']:
env[n] = config['sdk_path']
for n in ['ANDROID_NDK', 'NDK']:
env[n] = config['ndk_path']
for k in ["keystorepass", "keypass"]:
if k in config:
@ -165,6 +183,15 @@ def read_config(opts, config_file='config.py'):
return config
def get_ndk_path(version):
if version is None:
version = 'r10d' # latest
paths = config['ndk_paths']
if version not in paths:
return None
return paths[version]
def find_sdk_tools_cmd(cmd):
'''find a working path to a tool from the Android SDK'''
@ -366,7 +393,7 @@ def getcvname(app):
return '%s (%s)' % (app['Current Version'], app['Current Version Code'])
def getvcs(vcstype, remote, local):
def getvcs(vcstype, remote, local, build):
if vcstype == 'git':
return vcs_git(remote, local)
if vcstype == 'git-svn':
@ -378,7 +405,7 @@ def getvcs(vcstype, remote, local):
if vcstype == 'srclib':
if local != os.path.join('build', 'srclib', remote):
raise VCSException("Error: srclib paths are hard-coded!")
return getsrclib(remote, os.path.join('build', 'srclib'), raw=True)
return getsrclib(remote, os.path.join('build', 'srclib'), build, raw=True)
if vcstype == 'svn':
raise VCSException("Deprecated vcs type 'svn' - please use 'git-svn' instead")
raise VCSException("Invalid vcs type " + vcstype)
@ -1040,7 +1067,7 @@ class BuildException(FDroidException):
# 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, srclibpaths=[], subdir=None,
def getsrclib(spec, srclib_dir, build, srclibpaths=[], subdir=None,
basepath=False, raw=False, prepare=True, preponly=False):
number = None
@ -1063,7 +1090,7 @@ def getsrclib(spec, srclib_dir, srclibpaths=[], subdir=None,
sdir = os.path.join(srclib_dir, name)
if not preponly:
vcs = getvcs(srclib["Repo Type"], srclib["Repo"], sdir)
vcs = getvcs(srclib["Repo Type"], srclib["Repo"], sdir, build)
vcs.srclib = (name, number, sdir)
if ref:
vcs.gotorevision(ref)
@ -1104,7 +1131,7 @@ def getsrclib(spec, srclib_dir, srclibpaths=[], subdir=None,
if prepare:
if srclib["Prepare"]:
cmd = replace_config_vars(srclib["Prepare"])
cmd = replace_config_vars(srclib["Prepare"], build)
p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=libdir)
if p.returncode != 0:
@ -1155,7 +1182,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
# Run an init command if one is required
if build['init']:
cmd = replace_config_vars(build['init'])
cmd = replace_config_vars(build['init'], build)
logging.info("Running 'init' commands in %s" % root_dir)
p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=root_dir)
@ -1179,7 +1206,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
if build['srclibs']:
logging.info("Collecting source libraries")
for lib in build['srclibs']:
srclibpaths.append(getsrclib(lib, srclib_dir, srclibpaths,
srclibpaths.append(getsrclib(lib, srclib_dir, build, srclibpaths,
preponly=onserver))
for name, number, libpath in srclibpaths:
@ -1213,10 +1240,10 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
else:
props += "sdk.dir=%s\n" % config['sdk_path']
props += "sdk-location=%s\n" % config['sdk_path']
if config['ndk_path']:
if build['ndk_path']:
# Add ndk location
props += "ndk.dir=%s\n" % config['ndk_path']
props += "ndk-location=%s\n" % config['ndk_path']
props += "ndk.dir=%s\n" % build['ndk_path']
props += "ndk-location=%s\n" % build['ndk_path']
# Add java.encoding if necessary
if build['encoding']:
props += "java.encoding=%s\n" % build['encoding']
@ -1336,7 +1363,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
if build['prebuild']:
logging.info("Running 'prebuild' commands in %s" % root_dir)
cmd = replace_config_vars(build['prebuild'])
cmd = replace_config_vars(build['prebuild'], build)
# Substitute source library paths into prebuild commands
for name, number, libpath in srclibpaths:
@ -1764,9 +1791,9 @@ def remove_signing_keys(build_dir):
logging.info("Cleaned %s of keysigning configs at %s" % (propfile, path))
def replace_config_vars(cmd):
def replace_config_vars(cmd, build):
cmd = cmd.replace('$$SDK$$', config['sdk_path'])
cmd = cmd.replace('$$NDK$$', config['ndk_path'])
cmd = cmd.replace('$$NDK$$', build['ndk_path'])
cmd = cmd.replace('$$MVN3$$', config['mvn3'])
return cmd

View file

@ -203,16 +203,8 @@ def main():
# now that we have a local config.py, read configuration...
config = common.read_config(options)
# track down where the Android NDK is
ndk_path = '/opt/android-ndk'
if os.path.isdir(config['ndk_path']):
ndk_path = config['ndk_path']
elif 'ANDROID_NDK' in os.environ.keys():
logging.info('using ANDROID_NDK')
ndk_path = os.environ['ANDROID_NDK']
if os.path.isdir(ndk_path):
write_to_config(test_config, 'ndk_path')
# the NDK is optional so we don't prompt the user for it if its not found
# the NDK is optional and there may be multiple versions of it, so it's
# left for the user to configure
# find or generate the keystore for the repo signing key. First try the
# path written in the default config.py. Then check if the user has
@ -286,7 +278,7 @@ def main():
logging.info(' Android SDK:\t\t\t' + config['sdk_path'])
if aapt:
logging.info(' Android SDK Build Tools:\t' + os.path.dirname(aapt))
logging.info(' Android NDK (optional):\t' + ndk_path)
logging.info(' Android NDK r10d (optional):\t$ANDROID_NDK')
logging.info(' Keystore for signing key:\t' + keystore)
if repo_keyalias is not None:
logging.info(' Alias for key in store:\t' + repo_keyalias)

View file

@ -25,6 +25,8 @@ import logging
from collections import OrderedDict
import common
srclibs = None
@ -100,6 +102,7 @@ flag_defaults = OrderedDict([
('scandelete', []),
('build', ''),
('buildjni', []),
('ndk', 'r9b'), # defaults to oldest
('preassemble', []),
('antcommands', None),
('novcheck', False),
@ -560,6 +563,7 @@ def fill_build_defaults(build):
continue
build[flag] = value
build['type'] = get_build_type()
build['ndk_path'] = common.get_ndk_path(build['ndk'])
# Parse metadata for a single application.