Set up the ndk in $PATH before each build

This commit is contained in:
Daniel Martí 2015-01-06 19:41:55 +01:00
parent 9b200f47d8
commit 6819e3c30e
2 changed files with 21 additions and 1 deletions

View file

@ -468,6 +468,10 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
for n in ['ANDROID_NDK', 'NDK']: for n in ['ANDROID_NDK', 'NDK']:
common.env[n] = thisbuild['ndk_path'] common.env[n] = thisbuild['ndk_path']
common.reset_env_path()
# Set up the current NDK to the PATH
common.add_to_env_path(thisbuild['ndk_path'])
# Prepare the source code... # Prepare the source code...
root_dir, srclibpaths = common.prepare_source(vcs, app, thisbuild, root_dir, srclibpaths = common.prepare_source(vcs, app, thisbuild,
build_dir, srclib_dir, build_dir, srclib_dir,

View file

@ -37,6 +37,7 @@ import metadata
config = None config = None
options = None options = None
env = None env = None
orig_path = None
default_config = { default_config = {
@ -118,7 +119,7 @@ def read_config(opts, config_file='config.py'):
The config is read from config_file, which is in the current directory when The config is read from config_file, which is in the current directory when
any of the repo management commands are used. any of the repo management commands are used.
""" """
global config, options, env global config, options, env, orig_path
if config is not None: if config is not None:
return config return config
@ -153,6 +154,7 @@ def read_config(opts, config_file='config.py'):
# There is no standard, so just set up the most common environment # There is no standard, so just set up the most common environment
# variables # variables
env = os.environ env = os.environ
orig_path = env['PATH']
for n in ['ANDROID_HOME', 'ANDROID_SDK']: for n in ['ANDROID_HOME', 'ANDROID_SDK']:
env[n] = config['sdk_path'] env[n] = config['sdk_path']
@ -1816,6 +1818,20 @@ def remove_signing_keys(build_dir):
logging.info("Cleaned %s of keysigning configs at %s" % (propfile, path)) logging.info("Cleaned %s of keysigning configs at %s" % (propfile, path))
def reset_env_path():
global env, orig_path
env['PATH'] = orig_path
def add_to_env_path(path):
global env
paths = env['PATH'].split(os.pathsep)
if path in paths:
return
paths += path
env['PATH'] = os.pathsep.join(paths)
def replace_config_vars(cmd): def replace_config_vars(cmd):
global env global env
cmd = cmd.replace('$$SDK$$', config['sdk_path']) cmd = cmd.replace('$$SDK$$', config['sdk_path'])