When working on Application Services, it's important to set up your environment for building the Rust code and the Android or iOS code needed by the application.
Building for the first time is more complicated than a typical Rust project. To build for an end-to-end experience that enables you to test changes in client applications like Firefox for Android (Fenix) and Firefox iOS, there are a number of build systems required for all the dependencies. The initial setup is likely to take a number of hours to complete.
Complete this section before moving to the android/iOS build instructions.
- Make sure you cloned the repository:
$ git clone https://github.com/mozilla/application-services # (or use the ssh link)
$ cd application-services
$ git submodule update --init --recursive-
Install Rust: install via rustup
-
Install your system dependencies:
- Install the system dependencies required for building NSS
- Install gyp:
apt install gyp(required for NSS) - Install ninja-build:
apt install ninja-build - Install python3 (at least 3.6):
apt install python3 - Install zlib:
apt install zlib1g-dev
- Install gyp:
- Install the system dependencies required for SQLcipher
- Install tcl:
apt install tclsh(required for SQLcipher)
- Install tcl:
- Install Xcode: check the ci config for the correct version.
- Install Xcode tools:
xcode-select --install - Install homebrew: via homebrew (it's what we use for ci)
- Install the system dependencies required for building NSS
- Install ninja:
brew install ninja - Install gyp (via https://github.com/mogemimi/pomdog/wiki/How-to-Install-GYP)
- Install ninja:
- Install swift-protobuf:
brew install swift-protobuf
Install windows build tools
Why Windows Subsystem for Linux (WSL)?
It's currently tricky to get some of these builds working on Windows, primarily due to our use of SQLcipher. By using WSL it is possible to get builds working, but still have them published to your "native" local maven cache so it's available for use by a "native" Android Studio.
- Install WSL (recommended over native tooling)
- Install unzip:
sudo apt install unzip - Install python3:
sudo apt install python3Note: must be python 3.6 or later - Install system build tools:
sudo apt install build-essential - Install zlib:
sudo apt-get install zlib1g-dev - Install tcl:
sudo apt install tcl-dev
- Install the system dependencies required for building NSS
-
Check dependencies and environment variables by running:
./libs/verify-desktop-environment.sh
Note that this script might instruct you to set some environment variables, set those by adding them to your
.zshrcor.bashrcso they are set by default on your terminal
- Run cargo test:
cargo test
Once you have successfully run ./libs/verify-desktop-environment.sh and cargo test you can move to the Building for Fenix and Building for iOS sections below to setup your local environment for testing with our client applications.
The following instructions assume that you are building application-services for Fenix, and want to take advantage of the
Fenix Auto-publication workflow for android-components and application-services.
- Install Android SDK, JAVA, NDK and set required env vars
- Clone the Fenix repository (not inside the Application Service repository).
- Clone the android-components repository (not inside the Application Service repository).
- Install Java 11 for your system
- Set
JAVA_HOMEto point to the JDK 11 installation directory. - Download and install Android Studio.
- Set
ANDROID_SDK_ROOTandANDROID_HOMEto the Android Studio sdk location and add it to your rc file (either.zshrcor.bashrcdepending on the shell you use for your terminal). - Configure the required versions of NDK
Configure menu > System Settings > Android SDK > SDK Tools > NDK > Show Package Details > NDK (Side by side)- 21.4.7075529 (required by Fenix; note: a specific NDK version isn't configured, this maps to default NDK version for the AGP version)
- 21.3.6528147 (required by Application Services, as configured)
- If you are on Windows using WSL - drop to the section below, Windows setup for Android (WSL) before proceeding.
- Check dependencies, environment variables
- Run
./libs/verify-android-environment.sh - Follow instructions and rerun until it is successful.
- Run
Note: For non-Ubuntu linux versions, it may be necessary to execute $ANDROID_HOME/tools/bin/sdkmanager "build-tools;26.0.2" "platform-tools" "platforms;android-26" "tools". See also this gist for additional information.
Configure maven to use the native windows maven repository - then, when doing ./gradlew install from WSL, it ends up in the Windows maven repo. This means we can do a number of things with Android Studio in "native" windows and have then work correctly with stuff we built in WSL.
- Install maven:
sudo apt install maven - Confirm existence of (or create) a
~/.m2folder - In the
~/.m2create a file calledsettings.xml - Add the content below replacing
{username}with your username:
<settings>
<localRepository>/mnt/c/Users/{username}/.m2/repository</localRepository>
</settings>- Install Carthage:
brew install carthage - Install xcpretty:
gem install xcpretty - Run
./libs/verify-ios-environment.shto check your setup and environment variables. - Make any corrections recommended by the script and re-run.
- Follow the guide for using local a-s builds in iOS
Note: The built Xcode project is located at
megazords/ios/MozillaAppServices.xcodeproj.