Bug 1557855 - Use a sensible default for --with-android-ndk. r=nalexander
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 07 Jun 2019 22:23:37 +0000
changeset 477925 fd3d6eb262be9f5dd13746eb0dd8e2991e1d59e1
parent 477924 c33cca3c0100dd941a06204afe009fe2174b9ff3
child 477926 bdd7b4bfa07a3faa58706b788c7eea301f8fcda2
push id36127
push usernbeleuzu@mozilla.com
push dateSat, 08 Jun 2019 09:39:25 +0000
treeherdermozilla-central@b26753fb35e7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1557855
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1557855 - Use a sensible default for --with-android-ndk. r=nalexander Use the same logic as for --with-android-sdk to use the NDK downloaded by mach bootstrap by default. Differential Revision: https://phabricator.services.mozilla.com/D34251
build/moz.configure/android-ndk.configure
python/mozboot/mozboot/android.py
--- a/build/moz.configure/android-ndk.configure
+++ b/build/moz.configure/android-ndk.configure
@@ -1,17 +1,27 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 
+@depends(mozbuild_state_path, '--help')
+@imports('os')
+@imports(_from='mozboot.android', _import='NDK_VERSION')
+def default_android_ndk_root(mozbuild_state_path, _):
+    path = os.path.join(mozbuild_state_path, 'android-ndk-%s' % NDK_VERSION)
+    if os.path.isdir(path):
+        return path
+
+
 js_option('--with-android-ndk', nargs=1,
-          help='location where the Android NDK can be found')
+          default=default_android_ndk_root,
+          help='location where the Android NDK can be found{|}')
 
 js_option('--with-android-toolchain', nargs=1,
           help='location of the Android toolchain')
 
 option('--with-android-googlevr-sdk', nargs=1,
        help='location of the Android GoogleVR SDK')
 
 
@@ -47,21 +57,26 @@ def android_version(value, min_version):
 
     return version
 
 
 add_old_configure_assignment('android_version', android_version)
 
 
 @depends('--with-android-ndk')
+@imports(_from='os.path', _import='isdir')
 def ndk(value):
-    if not value:
-        die('You must specify --with-android-ndk=/path/to/ndk when '
-            'building for Android')
-    return value[0]
+    if value:
+        if not isdir(value[0]):
+            die("The path you specified with --with-android-ndk (%s) is not "
+                "a directory" % value[0])
+        return value[0]
+
+    die('You must specify --with-android-ndk=/path/to/ndk when targeting Android, '
+        'or try |mach bootstrap|.')
 
 
 set_config('ANDROID_NDK', ndk)
 add_old_configure_assignment('android_ndk', ndk)
 
 
 @depends(ndk)
 @checking('for android ndk version')
--- a/python/mozboot/mozboot/android.py
+++ b/python/mozboot/mozboot/android.py
@@ -55,18 +55,16 @@ ac_add_options --enable-application=mobi
 # For x86 emulators (and x86 devices, which are uncommon):
 # ac_add_options --target=i686
 # For newer phones.
 # ac_add_options --target=aarch64
 # For x86_64 emulators (and x86_64 devices, which are even less common):
 # ac_add_options --target=x86_64
 
 {extra_lines}
-# With the following Android NDK:
-ac_add_options --with-android-ndk="{ndk_path}"
 <<<
 '''
 
 MOBILE_ANDROID_ARTIFACT_MODE_MOZCONFIG_TEMPLATE = '''
 Paste the lines between the chevrons (>>> and <<<) into your
 $topsrcdir/mozconfig file, or create the file if it does not exist:
 
 >>>