Skip to content

Instantly share code, notes, and snippets.

@thomcc
Last active September 6, 2018 20:45
Show Gist options
  • Save thomcc/620fafc6b246cead296912e2773c8bb2 to your computer and use it in GitHub Desktop.
Save thomcc/620fafc6b246cead296912e2773c8bb2 to your computer and use it in GitHub Desktop.
Doing a local build of the logins archive

Doing a local build of the logins archive:

Note that we're working on improving this, but this is where we are currently. The first 5 steps you should only need to do once, and after that you can just run ./gradlew library:assembleRelease from the right dir (step 6).

Also note that this is somewhat sensitive to your local config, so while I've tried to test and make sure it works, well, hopefully I didn't forget any steps that I have already done in the past.

  1. Install NDK r15c from https://developer.android.com/ndk/downloads/older_releases (yes, this sucks, but newer versions don't understand the --deprecated-headers argument required to build OpenSSL against a v21 toolchain).

    • Extract it and put it somewhere we'll call $NDK_HOME.
  2. Install rustup from https://rustup.rs. You can do this while part 1 is happening.

    • If you already have it, run rustup update
    • Run rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android
    • Run rustup toolchain add beta (TODO: this may not still be necessary, but just to be safe...).
  3. Clone mozilla/application-services and make sure it's up to date.

    • It had commits very recently making some of these things work, so really, make sure it's up to date.
  4. Setup your NDK toolchains.

    • Create a directory where we'll install the standalone toolchains -- this is optional, but if you don't do it we'll install them somewhere in /tmp, and so you may end up doing this more than once.
      • mkdir -p ~/.ndk-standalone-toolchains
      • export ANDROID_NDK_TOOLCHAIN_DIR=$HOME/.ndk-standalone-toolchains
      • Add that to some rc file or whatever is required for it to stick around.
    • cd path/to/application-services/libs
    • ./setup_toolchains_local.sh $NDK_HOME
      • $NDK_HOME is where you installed the NDK earlier.
      • Say yes if/when prompted.
      • When this is done, it should have set $ANDROID_NDK_API_VERSION (to 21), you probably will want to put this in an rcfile as before.
      • If this part fails, let me know and I can give you the more manual process for setting these up.
  5. Build openssl and sqlcipher

    • cd path/to/application-services/libs (Same dir you were just in for step 4)
    • ./build-all.sh android (Go make some coffee or something, this will take some time as it has to compile sqlcipher and openssl for x86, arm, and arm64).
    • Note that if something goes wrong here
      • You should have $ANDROID_NDK_TOOLCHAIN_DIR set in your env (see step 4)
        • You should also have $ANDROID_NDK_API_VERSION set. $ANDROID_NDK_API_VERSION generally should be 21 for things you're going to release, but for local work it can be a newer version.
      • The following directories should exist, and point to standalone NDK toolchains $ANDROID_NDK_TOOLCHAIN_DIR/{x86,arm,arm64}-$ANDROID_NDK_API_VERSION.
  6. Build the actual logins aar

    • cd path/to/application-services/logins-api/android
    • ./gradlew library:assembleRelease (this is also likely to take a while, but not as long as building the libs before).
      • You can do a debug build with library:assembleDebug. (This does a debug build of the rust as well, so it's substantially slower ).
    • The output aar file is in library/build/outputs/aar/logins-{release,debug}.aar, depending if you did a release or debug build.
    • If this fails due to duplicate .so files, make sure you delete library/src/main/jniLibs and anything inside it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment