Bug 1114718 - Make |mach bootstrap| support 'mobile/android' builds on Arch Linux. r=mcomella
authorNick Alexander <nalexander@mozilla.com>
Mon, 19 Oct 2015 16:36:00 -0700
changeset 268882 9b249dc7978b6f96de67ea55b9696fbad3c26c4e
parent 268881 479539a438420df4feddae381c74c61be108bf5a
child 268883 3e148d8f5e0522a64968dc04562e6b1fd17ecbdf
push id29565
push usercbook@mozilla.com
push dateThu, 22 Oct 2015 09:41:55 +0000
treeherdermozilla-central@00ee97fb1a6c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella
bugs1114718
milestone44.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 1114718 - Make |mach bootstrap| support 'mobile/android' builds on Arch Linux. r=mcomella
python/mozboot/mozboot/archlinux.py
--- a/python/mozboot/mozboot/archlinux.py
+++ b/python/mozboot/mozboot/archlinux.py
@@ -54,34 +54,85 @@ class ArchlinuxBootstrapper(BaseBootstra
         'xorg-server-xvfb',
         'yasm',
         'zip',
         'gst-libav',
         'gst-plugins-good',
         'networkmanager',
     ]
 
-    AUR_PACKAGES = [
-        'https://aur.archlinux.org/cgit/aur.git/snapshot/uuid.tar.gz'
+    BROWSER_AUR_PACKAGES = [
+        'https://aur.archlinux.org/cgit/aur.git/snapshot/uuid.tar.gz',
+    ]
+
+    MOBILE_ANDROID_COMMON_PACKAGES = [
+        'zlib',  # mobile/android requires system zlib.
+        'jdk7-openjdk', # It would be nice to handle alternative JDKs.  See https://wiki.archlinux.org/index.php/Java.
+        'wget',  # For downloading the Android SDK and NDK.
+        'multilib/lib32-libstdc++5', # See comment about 32 bit binaries and multilib below.
+        'multilib/lib32-ncurses',
+        'multilib/lib32-readline',
+        'multilib/lib32-zlib',
     ]
 
     def __init__(self, version, dist_id, **kwargs):
         print 'Using an experimental bootstrapper for Archlinux.'
         BaseBootstrapper.__init__(self, **kwargs)
 
     def install_system_packages(self):
         self.pacman_install(*self.SYSTEM_PACKAGES)
-        self.aur_install(*self.AUR_PACKAGES)
 
     def install_browser_packages(self):
+        self.aur_install(*self.AUR_BROWSER_PACKAGES)
         self.pacman_install(*self.BROWSER_PACKAGES)
 
     def install_mobile_android_packages(self):
-        raise NotImplementedError('Bootstrap support for mobile-android is '
-                                  'not yet available for Archlinux')
+        import android
+
+        # Multi-part process:
+        # 1. System packages.
+        # 2. Android SDK and NDK.
+        # 3. Android packages.
+
+        # 1. This is hard to believe, but the Android SDK binaries are 32-bit
+        # and that conflicts with 64-bit Arch installations out of the box.  The
+        # solution is to add the multilibs repository; unfortunately, this
+        # requires manual intervention.
+        try:
+            self.pacman_install(*self.MOBILE_ANDROID_COMMON_PACKAGES)
+        except e:
+            print('Failed to install all packages.  The Android developer '
+                  'toolchain requires 32 bit binaries be enabled (see '
+                  'https://wiki.archlinux.org/index.php/Android).  You may need to '
+                  'manually enable the multilib repository following the instructions '
+                  'at https://wiki.archlinux.org/index.php/Multilib.')
+            raise e
+
+        # 2. The user may have an external Android SDK (in which case we save
+        # them a lengthy download), or they may have already completed the
+        # download. We unpack to ~/.mozbuild/{android-sdk-linux, android-ndk-r10e}.
+        mozbuild_path = os.environ.get('MOZBUILD_STATE_PATH', os.path.expanduser(os.path.join('~', '.mozbuild')))
+        self.sdk_path = os.environ.get('ANDROID_SDK_HOME', os.path.join(mozbuild_path, 'android-sdk-linux'))
+        self.ndk_path = os.environ.get('ANDROID_NDK_HOME', os.path.join(mozbuild_path, 'android-ndk-r10e'))
+        self.sdk_url = 'https://dl.google.com/android/android-sdk_r24.0.1-linux.tgz'
+        is_64bits = sys.maxsize > 2**32
+        if is_64bits:
+            self.ndk_url = 'https://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin'
+        else:
+            self.ndk_url = 'https://dl.google.com/android/ndk/android-ndk-r10e-linux-x86.bin'
+        android.ensure_android_sdk_and_ndk(path=mozbuild_path,
+                                           sdk_path=self.sdk_path, sdk_url=self.sdk_url,
+                                           ndk_path=self.ndk_path, ndk_url=self.ndk_url)
+        android_tool = os.path.join(self.sdk_path, 'tools', 'android')
+        android.ensure_android_packages(android_tool=android_tool)
+
+    def suggest_mobile_android_mozconfig(self):
+        import android
+        android.suggest_mozconfig(sdk_path=self.sdk_path,
+                                  ndk_path=self.ndk_path)
 
     def _update_package_manager(self):
         self.pacman_update
 
     def upgrade_mercurial(self, current):
         self.pacman_install('mercurial')
 
     def upgrade_python(self, current):