Bug 1221200 - Offer Fennec artifact builds in |mach bootstrap|. r=nalexander

MozReview-Commit-ID: D2dw6qfPa5k
This commit is contained in:
Sambuddha Basu
2016-02-27 17:01:31 +05:30
parent 08a9307352
commit 962c9adbde
7 changed files with 132 additions and 32 deletions

View File

@@ -74,6 +74,23 @@ ac_add_options --with-android-ndk="%s"
>>>
'''
MOBILE_ANDROID_ARTIFACT_MODE_MOZCONFIG_TEMPLATE = '''
Paste the lines between the chevrons (>>> and <<<) into your mozconfig file:
<<<
# Build Firefox for Android Artifact Mode:
ac_add_options --enable-application=mobile/android
ac_add_options --target=arm-linux-androideabi
ac_add_options --enable-artifact-builds
# With the following Android SDK:
ac_add_options --with-android-sdk="%s"
# Write build artifacts to:
mk_add_options MOZ_OBJDIR=./objdir-frontend
>>>
'''
def check_output(*args, **kwargs):
"""Run subprocess.check_output even if Python doesn't provide it."""
@@ -177,15 +194,17 @@ def install_mobile_android_sdk_or_ndk(url, path):
os.chdir(old_path)
def ensure_android_sdk_and_ndk(path, sdk_path, sdk_url, ndk_path, ndk_url):
def ensure_android_sdk_and_ndk(path, sdk_path, sdk_url, ndk_path, ndk_url, artifact_mode):
'''
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 |path|.
'''
# It's not particularyl bad to overwrite the NDK toolchain, but it does take
# It's not particularly bad to overwrite the NDK toolchain, but it does take
# a while to unpack, so let's avoid the disk activity if possible. The SDK
# 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:
if os.path.isdir(ndk_path):
print(ANDROID_NDK_EXISTS % ndk_path)
else:
@@ -232,7 +251,10 @@ def ensure_android_packages(android_tool, packages=None):
raise Exception(MISSING_ANDROID_PACKAGES % (', '.join(missing), ', '.join(failing)))
def suggest_mozconfig(sdk_path=None, ndk_path=None):
def suggest_mozconfig(sdk_path=None, ndk_path=None, artifact_mode=False):
if artifact_mode:
print(MOBILE_ANDROID_ARTIFACT_MODE_MOZCONFIG_TEMPLATE % (sdk_path))
else:
print(MOBILE_ANDROID_MOZCONFIG_TEMPLATE % (sdk_path, ndk_path))

View File

@@ -85,11 +85,17 @@ class ArchlinuxBootstrapper(BaseBootstrapper):
self.pacman_install(*self.BROWSER_PACKAGES)
def install_mobile_android_packages(self):
self.ensure_mobile_android_packages()
def install_mobile_android_artifact_mode_packages(self):
self.ensure_mobile_android_packages(artifact_mode=True)
def ensure_mobile_android_packages(self, artifact_mode=False):
import android
# Multi-part process:
# 1. System packages.
# 2. Android SDK and NDK.
# 2. Android SDK. Android NDK only if we are not in artifact mode.
# 3. Android packages.
# 1. This is hard to believe, but the Android SDK binaries are 32-bit
@@ -117,14 +123,19 @@ class ArchlinuxBootstrapper(BaseBootstrapper):
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)
ndk_path=self.ndk_path, ndk_url=self.ndk_url,
artifact_mode=artifact_mode)
android_tool = os.path.join(self.sdk_path, 'tools', 'android')
android.ensure_android_packages(android_tool=android_tool)
def suggest_mobile_android_mozconfig(self):
def suggest_mobile_android_mozconfig(self, artifact_mode=False):
import android
android.suggest_mozconfig(sdk_path=self.sdk_path,
ndk_path=self.ndk_path)
ndk_path=self.ndk_path,
artifact_mode=artifact_mode)
def suggest_mobile_android_artifact_mode_mozconfig(self):
self.suggest_mobile_android_mozconfig(artifact_mode=True)
def _update_package_manager(self):
self.pacman_update

View File

@@ -136,6 +136,28 @@ class BaseBootstrapper(object):
raise NotImplementedError('%s does not yet implement suggest_mobile_android_mozconfig()' %
__name__)
def install_mobile_android_artifact_mode_packages(self):
'''
Install packages required to build Firefox for Android (application
'mobile/android', also known as Fennec) in Artifact Mode.
'''
raise NotImplementedError(
'Cannot bootstrap Firefox for Android Artifact Mode: '
'%s does not yet implement install_mobile_android_artifact_mode_packages()'
% __name__)
def suggest_mobile_android_artifact_mode_mozconfig(self):
'''
Print a message to the console detailing what the user's mozconfig
should contain.
Firefox for Android Artifact Mode needs an application and an ABI set,
and it needs paths to the Android SDK.
'''
raise NotImplementedError(
'%s does not yet implement suggest_mobile_android_artifact_mode_mozconfig()'
% __name__)
def which(self, name):
"""Python implementation of which.

View File

@@ -22,12 +22,24 @@ from mozboot.archlinux import ArchlinuxBootstrapper
APPLICATION_CHOICE = '''
Please choose the version of Firefox you want to build:
%s
Note: (For Firefox for Android)
Firefox for Android is built on top of the Gecko technology platform. Gecko is Mozilla's web rendering engine, similar to Edge, Blink, and WebKit. Gecko is implemented in C++ and JavaScript. If you want to work on web rendering, this is what you want.
The Firefox for Android Front-End is built using Java, the Android Platform SDK, JavaScript, HTML, and CSS. If you want to work on the look-and-feel of Firefox for Android, this is what you want.
If you don't know what you want, start with just the Firefox for Android Artifact Mode. Your builds will be much shorter than if you build Gecko as well. But don't worry! You can always switch configurations later.
You can learn more about Artifact builds from https://developer.mozilla.org/en-US/docs/Artifact_builds
Your choice:
'''
APPLICATIONS_LIST=[
('Firefox for Desktop', 'browser'),
('Firefox for Android', 'mobile_android')
('Firefox for Android', 'mobile_android'),
('Firefox for Android Artifact Mode', 'mobile_android_artifact_mode')
]
# This is a workaround for the fact that we must support python2.6 (which has
@@ -35,6 +47,7 @@ APPLICATIONS_LIST=[
APPLICATIONS = dict(
desktop=APPLICATIONS_LIST[0],
android=APPLICATIONS_LIST[1],
android_artifact_mode=APPLICATIONS_LIST[2],
)
FINISHED = '''
@@ -119,7 +132,7 @@ class Bootstrapper(object):
def bootstrap(self):
if self.choice is None:
# Like ['1. Firefox for Desktop', '2. Firefox for Android'].
# Like ['1. Firefox for Desktop', '2. Firefox for Android', '3. Firefox for Android Artifact Mode'].
labels = ['%s. %s' % (i + 1, name) for (i, (name, _)) in enumerate(APPLICATIONS_LIST)]
prompt = APPLICATION_CHOICE % '\n'.join(labels)
prompt_choice = self.instance.prompt_int(prompt=prompt, low=1, high=len(APPLICATIONS))

View File

@@ -99,7 +99,13 @@ class CentOSFedoraBootstrapper(BaseBootstrapper):
elif self.distro == 'Fedora':
self.install_fedora_mobile_android_packages()
def install_fedora_mobile_android_packages(self):
def install_mobile_android_artifact_mode_packages(self):
if self.distro in ('CentOS', 'CentOS Linux'):
BaseBootstrapper.install_mobile_android_artifact_mode_packages(self)
elif self.distro == 'Fedora':
self.install_fedora_mobile_android_packages(artifact_mode=True)
def install_fedora_mobile_android_packages(self, artifact_mode=False):
import android
# Install Android specific packages.
@@ -114,12 +120,17 @@ class CentOSFedoraBootstrapper(BaseBootstrapper):
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)
ndk_path=self.ndk_path, ndk_url=self.ndk_url,
artifact_mode=artifact_mode)
def suggest_mobile_android_mozconfig(self):
def suggest_mobile_android_mozconfig(self, artifact_mode=False):
import android
android.suggest_mozconfig(sdk_path=self.sdk_path,
ndk_path=self.ndk_path)
ndk_path=self.ndk_path,
artifact_mode=artifact_mode)
def suggest_mobile_android_artifact_mode_mozconfig(self):
self.suggest_mobile_android_mozconfig(artifact_mode=True)
def upgrade_mercurial(self):
self.dnf_update('mercurial')

View File

@@ -101,11 +101,17 @@ class DebianBootstrapper(BaseBootstrapper):
self.apt_install(*self.browser_packages)
def install_mobile_android_packages(self):
self.ensure_mobile_android_packages()
def install_mobile_android_artifact_mode_packages(self):
self.ensure_mobile_android_packages(artifact_mode=True)
def ensure_mobile_android_packages(self, artifact_mode=False):
import android
# Multi-part process:
# 1. System packages.
# 2. Android SDK and NDK.
# 2. Android SDK. Android NDK only if we are not in artifact mode.
# 3. Android packages.
# 1. This is hard to believe, but the Android SDK binaries are 32-bit
@@ -129,17 +135,22 @@ class DebianBootstrapper(BaseBootstrapper):
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)
ndk_path=self.ndk_path, ndk_url=self.ndk_url,
artifact_mode=artifact_mode)
# 3. We expect the |android| tool to at
# ~/.mozbuild/android-sdk-linux/tools/android.
android_tool = os.path.join(self.sdk_path, 'tools', 'android')
android.ensure_android_packages(android_tool=android_tool)
def suggest_mobile_android_mozconfig(self):
def suggest_mobile_android_mozconfig(self, artifact_mode=False):
import android
android.suggest_mozconfig(sdk_path=self.sdk_path,
ndk_path=self.ndk_path)
ndk_path=self.ndk_path,
artifact_mode=artifact_mode)
def suggest_mobile_android_artifact_mode_mozconfig(self):
self.suggest_mobile_android_mozconfig(artifact_mode=True)
def _update_package_manager(self):
self.apt_update()

View File

@@ -193,9 +193,15 @@ class OSXBootstrapper(BaseBootstrapper):
def install_mobile_android_packages(self):
getattr(self, 'ensure_%s_mobile_android_packages' % self.package_manager)()
def install_mobile_android_artifact_mode_packages(self):
getattr(self, 'ensure_%s_mobile_android_packages' % self.package_manager)(artifact_mode=True)
def suggest_mobile_android_mozconfig(self):
getattr(self, 'suggest_%s_mobile_android_mozconfig' % self.package_manager)()
def suggest_mobile_android_artifact_mode_mozconfig(self):
getattr(self, 'suggest_%s_mobile_android_mozconfig' % self.package_manager)(artifact_mode=True)
def ensure_xcode(self):
if self.os_version < StrictVersion('10.7'):
if not os.path.exists('/Developer/Applications/Xcode.app'):
@@ -326,10 +332,10 @@ class OSXBootstrapper(BaseBootstrapper):
subprocess.check_call([self.brew, '-v', 'install', 'llvm',
'--with-clang', '--all-targets'])
def ensure_homebrew_mobile_android_packages(self):
def ensure_homebrew_mobile_android_packages(self, artifact_mode=False):
# Multi-part process:
# 1. System packages.
# 2. Android SDK and NDK.
# 2. Android SDK. Android NDK only if we are not in artifact mode.
# 3. Android packages.
import android
@@ -363,17 +369,19 @@ class OSXBootstrapper(BaseBootstrapper):
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)
ndk_path=self.ndk_path, ndk_url=self.ndk_url,
artifact_mode=artifact_mode)
# 3. We expect the |android| tool to at
# ~/.mozbuild/android-sdk-macosx/tools/android.
android_tool = os.path.join(self.sdk_path, 'tools', 'android')
android.ensure_android_packages(android_tool=android_tool)
def suggest_homebrew_mobile_android_mozconfig(self):
def suggest_homebrew_mobile_android_mozconfig(self, artifact_mode=False):
import android
android.suggest_mozconfig(sdk_path=self.sdk_path,
ndk_path=self.ndk_path)
ndk_path=self.ndk_path,
artifact_mode=artifact_mode)
def _ensure_macports_packages(self, packages):
self.port = self.which('port')
@@ -410,10 +418,10 @@ class OSXBootstrapper(BaseBootstrapper):
self.run_as_root([self.port, '-v', 'install', MACPORTS_CLANG_PACKAGE])
self.run_as_root([self.port, 'select', '--set', 'clang', 'mp-' + MACPORTS_CLANG_PACKAGE])
def ensure_macports_mobile_android_packages(self):
def ensure_macports_mobile_android_packages(self, artifact_mode=False):
# Multi-part process:
# 1. System packages.
# 2. Android SDK and NDK.
# 2. Android SDK. Android NDK only if we are not in artifact mode.
# 3. Android packages.
import android
@@ -443,17 +451,19 @@ class OSXBootstrapper(BaseBootstrapper):
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)
ndk_path=self.ndk_path, ndk_url=self.ndk_url,
artifact_mode=artifact_mode)
# 3. We expect the |android| tool to at
# ~/.mozbuild/android-sdk-macosx/tools/android.
android_tool = os.path.join(self.sdk_path, 'tools', 'android')
android.ensure_android_packages(android_tool=android_tool)
def suggest_macports_mobile_android_mozconfig(self):
def suggest_macports_mobile_android_mozconfig(self, artifact_mode=False):
import android
android.suggest_mozconfig(sdk_path=self.sdk_path,
ndk_path=self.ndk_path)
ndk_path=self.ndk_path,
artifact_mode=artifact_mode)
def ensure_package_manager(self):
'''