Bug 1427790 - Bootstrap caskroom/versions/java8 for macOS+brew+mobile/android. r=froydnj
Two things have changed. One, Brew's java package became Java 9,
which doesn't work for building on Android. Two, Brew's cask system
also changed, requiring some small updates.
In order to actually use the install java toolchain, we need to use
the --with-java-bin-path configure option, which required some small
tweaks to the suggested mozconfigs.
MozReview-Commit-ID: JlZpdqaOkp0
--- a/python/mozboot/mozboot/android.py
+++ b/python/mozboot/mozboot/android.py
@@ -45,33 +45,35 @@ output as packages are downloaded and in
MOBILE_ANDROID_MOZCONFIG_TEMPLATE = '''
Paste the lines between the chevrons (>>> and <<<) into your mozconfig file:
<<<
# Build Firefox for Android:
ac_add_options --enable-application=mobile/android
ac_add_options --target=arm-linux-androideabi
+{extra_lines}
# With the following Android SDK and NDK:
-ac_add_options --with-android-sdk="%s"
-ac_add_options --with-android-ndk="%s"
+ac_add_options --with-android-sdk="{sdk_path}"
+ac_add_options --with-android-ndk="{ndk_path}"
>>>
'''
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
+{extra_lines}
# With the following Android SDK:
-ac_add_options --with-android-sdk="%s"
+ac_add_options --with-android-sdk="{sdk_path}"
# Write build artifacts to:
mk_add_options MOZ_OBJDIR=./objdir-frontend
>>>
'''
def install_mobile_android_sdk_or_ndk(url, path):
@@ -259,22 +261,39 @@ def ensure_android_packages(sdkmanager_t
cmd = args[0]
e = subprocess.CalledProcessError(retcode, cmd)
e.output = output
raise e
print(output)
-def suggest_mozconfig(os_name, artifact_mode=False):
+def suggest_mozconfig(os_name, artifact_mode=False, java_bin_path=None):
_mozbuild_path, sdk_path, ndk_path = get_paths(os_name)
+
+ extra_lines = []
+ if java_bin_path:
+ extra_lines += [
+ '# With the following java and javac:',
+ 'ac_add_options --with-java-bin-path="{}"'.format(java_bin_path),
+ ]
+ if extra_lines:
+ extra_lines.append('')
+
if artifact_mode:
- print(MOBILE_ANDROID_ARTIFACT_MODE_MOZCONFIG_TEMPLATE % (sdk_path))
+ template = MOBILE_ANDROID_ARTIFACT_MODE_MOZCONFIG_TEMPLATE
else:
- print(MOBILE_ANDROID_MOZCONFIG_TEMPLATE % (sdk_path, ndk_path))
+ template = MOBILE_ANDROID_MOZCONFIG_TEMPLATE
+
+ kwargs = dict(
+ sdk_path=sdk_path,
+ ndk_path=ndk_path,
+ extra_lines='\n'.join(extra_lines),
+ )
+ print(template.format(**kwargs))
def android_ndk_url(os_name, ver=NDK_VERSION):
# Produce a URL like
# 'https://dl.google.com/android/repository/android-ndk-$VER-linux-x86_64.zip
base_url = 'https://dl.google.com/android/repository/android-ndk'
if os_name == 'macosx':
--- a/python/mozboot/mozboot/osx.py
+++ b/python/mozboot/mozboot/osx.py
@@ -284,19 +284,25 @@ class OSXBootstrapper(BaseBootstrapper):
print(INSTALL_XCODE_COMMAND_LINE_TOOLS_STEPS)
sys.exit(1)
def _install_xcode_app_store(self):
subprocess.check_call(['open', XCODE_APP_STORE])
print('Once the install has finished, please relaunch this script.')
sys.exit(1)
+ def _ensure_homebrew_found(self):
+ if not hasattr(self, 'brew'):
+ self.brew = self.which('brew')
+ # Earlier code that checks for valid package managers ensures
+ # which('brew') is found.
+ assert self.brew is not None
+
def _ensure_homebrew_packages(self, packages, extra_brew_args=[]):
- self.brew = self.which('brew')
- assert self.brew is not None
+ self._ensure_homebrew_found()
cmd = [self.brew] + extra_brew_args
installed = self.check_output(cmd + ['list']).split()
printed = False
for package in packages:
if package in installed:
@@ -306,16 +312,22 @@ class OSXBootstrapper(BaseBootstrapper):
print(PACKAGE_MANAGER_PACKAGES % ('Homebrew',))
printed = True
subprocess.check_call(cmd + ['install', package])
return printed
def _ensure_homebrew_casks(self, casks):
+ self._ensure_homebrew_found()
+
+ # Ensure that we can access old versions of packages. This is
+ # idempotent, so no need to avoid repeat invocation.
+ self.check_output([self.brew, 'tap', 'caskroom/versions'])
+
# Change |brew install cask| into |brew cask install cask|.
return self._ensure_homebrew_packages(casks, extra_brew_args=['cask'])
def ensure_homebrew_system_packages(self):
packages = [
# We need to install Python because Mercurial requires the Python
# development headers which are missing from OS X (at least on
# 10.8) and because the build system wants a version newer than
@@ -364,17 +376,19 @@ class OSXBootstrapper(BaseBootstrapper):
# 2. Android pieces.
from mozboot import android
android.ensure_android('macosx', artifact_mode=artifact_mode,
no_interactive=self.no_interactive)
def suggest_homebrew_mobile_android_mozconfig(self, artifact_mode=False):
from mozboot import android
- android.suggest_mozconfig('macosx', artifact_mode=artifact_mode)
+ # Path to java and javac from the caskroom/versions/java8 cask.
+ android.suggest_mozconfig('macosx', artifact_mode=artifact_mode,
+ java_bin_path='/Library/Java/Home/bin')
def _ensure_macports_packages(self, packages):
self.port = self.which('port')
assert self.port is not None
installed = set(self.check_output([self.port, 'installed']).split())
missing = [package for package in packages if package not in installed]