Verified Commit 88ad5449 authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame 🎃
Browse files

Bug 41684: Use the NDK as Android compiler.

We used to use a package with the full Android SDK+NDK.
However, we have several projects that only need the NDK.
Passing the SDK to them involved unneeded rebuilds for every SDK change,
and longer iteration times for toolchain update as a consequence.

Projects still needing the Android SDK will need to include both.
parent 5ea37387
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
This projects downloads and repacks the Android NDK, which we use as the
default compiler for Android.

We used to set the `android-toolchain` project as `var/compiler`, but most of
the projects only need the NDK, so any error in `android-toolchain` would
trigger unneeded rebuilds, making iteration times longer.

We keep the NDK version in sync with the version used by Mozilla.
+9 −0
Original line number Diff line number Diff line
#!/bin/bash
[% c("var/set_default_env") -%]

unzip -qq $rootdir/[% c("input_files_by_name/ndk")%]
mv android-ndk-r[% c("var/release") %] [% project %]
[% c('tar', {
    tar_src => [ project ],
    tar_args => '-caf ' _ dest_dir _ '/' _ c('filename'),
  }) %]
+18 −0
Original line number Diff line number Diff line
# vim: filetype=yaml sw=2
filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.[% c("compress_tar") %]'
version: 29.0.14206865

var:
  release: 29
  setup: |
    mkdir -p /var/tmp/dist
    tar -C /var/tmp/dist -xf $rootdir/[% c("compiler_tarfile") %]
    export ANDROID_NDK_HOME=/var/tmp/dist/android-ndk/
    export ANDROID_NDK_ROOT=$ANDROID_NDK_HOME
    export NDK_HOST_TAG=linux-x86_64
    export PATH=$PATH:$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin

input_files:
  - URL: 'https://dl.google.com/android/repository/android-ndk-r[% c("var/release") %]-linux.zip'
    name: ndk
    sha256sum: 4abbbcdc842f3d4879206e9695d52709603e52dd68d3c1fff04b3b5e7a308ecf
+7 −7
Original line number Diff line number Diff line
This project is configured as `var/compiler` for Android.

It contains a few versions of the Android SDK, build tools and the NDK.
This project contains some packages that would normally be installed with
`sdkmanager`, such as the build tools, platform tools and platforms.

It defines several environment variables that various build systems look for,
such as `ANDROID_HOME`.
Optionally, it also prepares gradle.

The output artifact includes only one version of the NDK, because of its huge
size, but the setup commands can use a custom version of the NDK, since some
projects need different versions (e.g., GeckoView and Application Services).
We used to have a single package for the SDK and the NDK.
However, most of native binaries need only the NDK.
Therefore, we decided to split the project, to possibly reduce the iteration
time when updating the toolchains, as it is much easier to get the NDK right at
the first attempt.

# Known issues

+6 −8
Original line number Diff line number Diff line
@@ -3,20 +3,13 @@

distdir=$rootdir/[% project %]
mkdir -p $distdir

mkdir $distdir/android-sdk-linux
cd $distdir/android-sdk-linux
cd $distdir

# Command line tools
mkdir -p cmdline-tools
unzip -qq $rootdir/[% c("input_files_by_name/android_commandlinetools") %] -d cmdline-tools
mv cmdline-tools/cmdline-tools cmdline-tools/[% c("var/commandlinetools_version_string") %]

# NDK
mkdir ndk
unzip -qq $rootdir/[% c("input_files_by_name/android_ndk_compiler")%] -d ndk
ln -s android-ndk-r[% c("var/android_ndk_release_name") %] ndk/[% c("var/android_ndk_revision") %]

# Build tools
mkdir build-tools
unzip -qq $rootdir/[% c("input_files_by_name/build_tools") %] -d build-tools
@@ -38,6 +31,11 @@ mv $rootdir/platform-36.1-package.xml platforms/android-36.1/package.xml
# Platform tools
unzip -qq $rootdir/[% c("input_files_by_name/platform_tools") %]

# Placeholder for the NDK, as some projects expect the NDK to be in
# $ANDROID_HOME/ndk/<ndk-version>.
# We will add a symlink to the actual NDK in the setup when available.
mkdir ndk

# That's a quirk required by GeckoView but let's have it here instead of in the
# project's build script
mkdir emulator
Loading