diff --git a/python/mozboot/mozboot/android.py b/python/mozboot/mozboot/android.py index 6a1a3ba9fee0..c3453e7888c0 100644 --- a/python/mozboot/mozboot/android.py +++ b/python/mozboot/mozboot/android.py @@ -156,7 +156,7 @@ def ensure_dir(dir): raise -def ensure_android(os_name, artifact_mode=False, no_interactive=False): +def ensure_android(os_name, artifact_mode=False, ndk_only=False, no_interactive=False): ''' Ensure the Android SDK (and NDK, if `artifact_mode` is falsy) are installed. If not, fetch and unpack the SDK and/or NDK from the @@ -177,7 +177,11 @@ def ensure_android(os_name, artifact_mode=False, no_interactive=False): ensure_android_sdk_and_ndk(mozbuild_path, os_name, sdk_path=sdk_path, sdk_url=sdk_url, ndk_path=ndk_path, ndk_url=ndk_url, - artifact_mode=artifact_mode) + artifact_mode=artifact_mode, + ndk_only=ndk_only) + + if ndk_only: + return # We expect the |sdkmanager| tool to be at # ~/.mozbuild/android-sdk-$OS_NAME/tools/bin/sdkmanager. @@ -186,7 +190,7 @@ def ensure_android(os_name, artifact_mode=False, no_interactive=False): def ensure_android_sdk_and_ndk(mozbuild_path, os_name, sdk_path, sdk_url, ndk_path, ndk_url, - artifact_mode): + artifact_mode, ndk_only): ''' Ensure the Android SDK and NDK are found at the given paths. If not, fetch and unpack the SDK and/or NDK from the given URLs into @@ -204,6 +208,9 @@ def ensure_android_sdk_and_ndk(mozbuild_path, os_name, sdk_path, sdk_url, ndk_pa # The NDK archive unpacks into a top-level android-ndk-$VER directory. install_mobile_android_sdk_or_ndk(ndk_url, mozbuild_path) + if ndk_only: + return + # We don't want to blindly overwrite, since we use the # |sdkmanager| tool to install additional parts of the Android # toolchain. If we overwrite, we lose whatever Android packages @@ -289,11 +296,16 @@ def main(argv): parser = optparse.OptionParser() parser.add_option('-a', '--artifact-mode', dest='artifact_mode', action='store_true', help='If true, install only the Android SDK (and not the Android NDK).') + parser.add_option('--ndk-only', dest='ndk_only', action='store_true', + help='If true, install only the Android NDK (and not the Android SDK).') parser.add_option('--no-interactive', dest='no_interactive', action='store_true', help='Accept the Android SDK licenses without user interaction.') options, _ = parser.parse_args(argv) + if options.artifact_mode and options.ndk_only: + raise NotImplementedError('Use no options to install the NDK and the SDK.') + os_name = None if platform.system() == 'Darwin': os_name = 'macosx' @@ -306,6 +318,7 @@ def main(argv): "NDK) on {0} yet!".format(platform.system())) ensure_android(os_name, artifact_mode=options.artifact_mode, + ndk_only=options.ndk_only, no_interactive=options.no_interactive) suggest_mozconfig(os_name, options.artifact_mode)