Bug 1557855 - Define MOZBUILD_STATE_PATH as an option. r=nalexander

Rather than taking it from the environment every time it's necessary.

Differential Revision: https://phabricator.services.mozilla.com/D34249

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mike Hommey 2019-06-07 23:25:01 +00:00
parent 671c425d6f
commit 4b49193e14
3 changed files with 22 additions and 12 deletions

View File

@ -7,11 +7,9 @@
# Ensure Android SDK and build-tools versions depending on mobile target.
@depends(host, '--help')
@depends(host, mozbuild_state_path, '--help')
@imports('os')
def default_android_sdk_root(host, _):
mozbuild_state_dir = os.environ.get('MOZBUILD_STATE_PATH',
os.path.expanduser(os.path.join('~', '.mozbuild')))
def default_android_sdk_root(host, mozbuild_state_path, _):
sdk_basename = {
'Darwin': 'android-sdk-macosx',
'Linux': 'android-sdk-linux',
@ -20,7 +18,7 @@ def default_android_sdk_root(host, _):
if sdk_basename is None:
log.warning("%s is unsupported host" % host.kernel)
return None
return os.path.join(mozbuild_state_dir, sdk_basename)
return os.path.join(mozbuild_state_path, sdk_basename)
option('--with-android-sdk', nargs=1,

View File

@ -1266,6 +1266,19 @@ set_define('MOZ_UPDATE_CHANNEL', update_channel)
add_old_configure_assignment('MOZ_UPDATE_CHANNEL', update_channel)
js_option(env='MOZBUILD_STATE_PATH', nargs=1,
help='Path to a persistent state directory for the build system '
'and related tools')
@depends('MOZBUILD_STATE_PATH', '--help')
@imports('os')
def mozbuild_state_path(path, _):
if path:
return path[0]
return os.path.expanduser(os.path.join('~', '.mozbuild'))
# A template providing a shorthand for setting a variable. The created
# option will only be settable with imply_option.
# It is expected that a project-specific moz.configure will call imply_option

View File

@ -700,10 +700,11 @@ def toolchain_search_path_for(host_or_target):
target: vc_compiler_path,
}[host_or_target]
@depends(vc_path, original_path, developer_options)
@depends(vc_path, original_path, developer_options, mozbuild_state_path)
@imports('os')
@imports(_from='os', _import='environ')
def toolchain_search_path(vc_compiler_path, original_path, developer_options):
def toolchain_search_path(vc_compiler_path, original_path, developer_options,
mozbuild_state_path):
result = list(original_path)
if vc_compiler_path:
@ -717,17 +718,15 @@ def toolchain_search_path_for(host_or_target):
# Also add in the location to which `mach bootstrap` or
# `mach artifact toolchain` installs clang.
mozbuild_state_dir = environ.get('MOZBUILD_STATE_PATH',
os.path.expanduser(os.path.join('~', '.mozbuild')))
bootstrapped = []
bootstrap_clang_path = os.path.join(mozbuild_state_dir, 'clang', 'bin')
bootstrap_clang_path = os.path.join(mozbuild_state_path, 'clang', 'bin')
bootstrapped.append(bootstrap_clang_path)
bootstrap_cbindgen_path = os.path.join(mozbuild_state_dir, 'cbindgen')
bootstrap_cbindgen_path = os.path.join(mozbuild_state_path, 'cbindgen')
bootstrapped.append(bootstrap_cbindgen_path)
bootstrap_nasm_path = os.path.join(mozbuild_state_dir, 'nasm')
bootstrap_nasm_path = os.path.join(mozbuild_state_path, 'nasm')
bootstrapped.append(bootstrap_nasm_path)
# Also add the rustup install directory for cargo/rustc.