зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1648552 - `mach bootstrap` checks if Android NDK version is the correct version r=nalexander
Differential Revision: https://phabricator.services.mozilla.com/D82084
This commit is contained in:
Родитель
78b3e5d01b
Коммит
37490b6c6e
|
@ -82,43 +82,26 @@ add_old_configure_assignment('android_ndk', ndk)
|
|||
@checking('for android ndk version')
|
||||
@imports(_from='__builtin__', _import='open')
|
||||
@imports(_from='mozboot.android', _import='NDK_VERSION')
|
||||
@imports(_from='mozboot.android', _import='get_ndk_version')
|
||||
@imports(_from='mozboot.android', _import='GetNdkVersionError')
|
||||
def ndk_version(ndk):
|
||||
if not ndk:
|
||||
# Building 'js/src' for non-Android.
|
||||
return
|
||||
with open(os.path.join(ndk, 'source.properties'), 'r') as f:
|
||||
revision = [line for line in f if line.startswith('Pkg.Revision')]
|
||||
if not revision:
|
||||
die('Cannot determine NDK version from source.properties')
|
||||
if len(revision) != 1:
|
||||
die('Too many Pkg.Revision lines in source.properties')
|
||||
|
||||
(_, version) = revision[0].split('=')
|
||||
if not version:
|
||||
die('Unexpected Pkg.Revision line in source.properties')
|
||||
try:
|
||||
major, minor, human = get_ndk_version(ndk)
|
||||
except GetNdkVersionError as e:
|
||||
die(str(e))
|
||||
|
||||
(major, minor, revision) = version.strip().split('.')
|
||||
if not major or not minor:
|
||||
die('Unexpected NDK version string: ' + version)
|
||||
|
||||
# source.properties contains a $MAJOR.$MINOR.$PATCH revision number,
|
||||
# but the more common nomenclature that Google uses is alphanumeric
|
||||
# version strings like "r20" or "r19c". Convert the source.properties
|
||||
# notation into an alphanumeric string.
|
||||
int_minor = int(minor)
|
||||
alphas = "abcdefghijklmnop"
|
||||
ascii_minor = alphas[int_minor] if int_minor > 0 else ''
|
||||
human = "r%s%s" % (major, ascii_minor)
|
||||
|
||||
if NDK_VERSION != human:
|
||||
die('The only supported version of the NDK is %s (have %s)\n'
|
||||
'Please run |mach bootstrap| '
|
||||
'to install the correct NDK.' % (NDK_VERSION, human))
|
||||
|
||||
return namespace(
|
||||
major=major,
|
||||
minor=minor,
|
||||
)
|
||||
if NDK_VERSION != human:
|
||||
die('The only supported version of the NDK is %s (have %s)\n'
|
||||
'Please run |mach bootstrap| '
|
||||
'to install the correct NDK.' % (NDK_VERSION, human))
|
||||
return namespace(
|
||||
major=major,
|
||||
minor=minor,
|
||||
)
|
||||
|
||||
|
||||
set_config('ANDROID_NDK_MAJOR_VERSION', ndk_version.major)
|
||||
|
|
|
@ -18,7 +18,7 @@ from mozboot.bootstrap import MOZCONFIG_SUGGESTION_TEMPLATE
|
|||
NDK_VERSION = 'r20'
|
||||
|
||||
ANDROID_NDK_EXISTS = '''
|
||||
Looks like you have the Android NDK installed at:
|
||||
Looks like you have the correct version of the Android NDK installed at:
|
||||
%s
|
||||
'''
|
||||
|
||||
|
@ -71,6 +71,10 @@ mk_add_options MOZ_OBJDIR=./objdir-frontend
|
|||
'''
|
||||
|
||||
|
||||
class GetNdkVersionError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def install_mobile_android_sdk_or_ndk(url, path):
|
||||
'''
|
||||
Fetch an Android SDK or NDK from |url| and unpack it into
|
||||
|
@ -136,6 +140,40 @@ def install_mobile_android_sdk_or_ndk(url, path):
|
|||
os.rmdir(download_path)
|
||||
|
||||
|
||||
def get_ndk_version(ndk_path):
|
||||
"""Given the path to the NDK, return the version as a 3-tuple of (major,
|
||||
minor, human).
|
||||
"""
|
||||
with open(os.path.join(ndk_path, 'source.properties'), 'r') as f:
|
||||
revision = [line for line in f if line.startswith('Pkg.Revision')]
|
||||
if not revision:
|
||||
raise GetNdkVersionError(
|
||||
'Cannot determine NDK version from source.properties')
|
||||
if len(revision) != 1:
|
||||
raise GetNdkVersionError(
|
||||
'Too many Pkg.Revision lines in source.properties')
|
||||
|
||||
(_, version) = revision[0].split('=')
|
||||
if not version:
|
||||
raise GetNdkVersionError(
|
||||
'Unexpected Pkg.Revision line in source.properties')
|
||||
|
||||
(major, minor, revision) = version.strip().split('.')
|
||||
if not major or not minor:
|
||||
raise GetNdkVersionError(
|
||||
'Unexpected NDK version string: ' + version)
|
||||
|
||||
# source.properties contains a $MAJOR.$MINOR.$PATCH revision number,
|
||||
# but the more common nomenclature that Google uses is alphanumeric
|
||||
# version strings like "r20" or "r19c". Convert the source.properties
|
||||
# notation into an alphanumeric string.
|
||||
int_minor = int(minor)
|
||||
alphas = "abcdefghijklmnop"
|
||||
ascii_minor = alphas[int_minor] if int_minor > 0 else ''
|
||||
human = "r%s%s" % (major, ascii_minor)
|
||||
return (major, minor, human)
|
||||
|
||||
|
||||
def get_paths(os_name):
|
||||
mozbuild_path = os.environ.get('MOZBUILD_STATE_PATH',
|
||||
os.path.expanduser(os.path.join('~', '.mozbuild')))
|
||||
|
@ -211,9 +249,16 @@ def ensure_android_sdk_and_ndk(mozbuild_path, os_name, sdk_path, sdk_url, ndk_pa
|
|||
# may prompt about licensing, so we do this first.
|
||||
# Check for Android NDK only if we are not in artifact mode.
|
||||
if not artifact_mode and not emulator_only:
|
||||
install_ndk = True
|
||||
if os.path.isdir(ndk_path):
|
||||
print(ANDROID_NDK_EXISTS % ndk_path)
|
||||
else:
|
||||
try:
|
||||
_, _, human = get_ndk_version(ndk_path)
|
||||
if human == NDK_VERSION:
|
||||
print(ANDROID_NDK_EXISTS % ndk_path)
|
||||
install_ndk = False
|
||||
except GetNdkVersionError:
|
||||
pass # Just do the install.
|
||||
if install_ndk:
|
||||
# The NDK archive unpacks into a top-level android-ndk-$VER directory.
|
||||
install_mobile_android_sdk_or_ndk(ndk_url, mozbuild_path)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче