AGI uses the Bazel build system. The recommended version of Bazel is 2.0.0.
Bazel is able to fetch most of the dependencies required to build AGI, but currently the Android SDK and NDK both need to be downloaded and installed by hand.
Please see the following OS specific guides for setting up the build environment.
After setting up the build environment, AGI can be built in a terminal with:
cd <path-to-agi-source>
bazel build pkg
⚠️ We currently use NDK r21d to have access to the unified Khronos validation layer. Bazel 2.0.0 has no official support for r21d, so the following build warning is expected and can be ignored:WARNING: The major revision of the Android NDK referenced by android_ndk_repository rule 'androidndk' is 21. The major revisions supported by Bazel are [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]. Bazel will attempt to treat the NDK as if it was r20. This may cause compilation and linkage problems. Please download a supported NDK version.
This issue is tracked by google#305
The build output will be at <path-to-agi-source>/bazel-bin/pkg
.
Follow these instructions to install Chocolatey.
Start a console, with administrator privilege, and type:
choco install bazel --version 2.0.0
In the same console, install Python 2.7 and MSYS2 as well:
choco install python2
choco install msys2
Using the msys64 shell (installed by choco at C:\tools\msys64\mingw64
):
- Update MSYS with:
pacman -Syu
. - If the update ends with “close the window and run it again”, close and reopen the window and repeat 1.
- Fetch required tools with:
pacman -S curl git zip unzip patch
- Download gcc with:
curl -O http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-gcc-9.2.0-2-any.pkg.tar.xz
- Download gcc-libs with:
curl -O http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-gcc-libs-9.2.0-2-any.pkg.tar.xz
- Install gcc with:
pacman -U mingw-w64-x86_64-gcc*-9.2.0-2-any.pkg.tar.xz
- Close the MSYS terminal
A JDK is required to run a custom build of AGI. If you do not already have a suitable JDK installed, you can download the OpenJDK we use on our build bots.
Make sure the JAVA_HOME
environment variable points to the JDK.
Unzip the Android SDK to a directory of your choosing.
To fetch the required packages, using a console type:
cd <sdk-path>
tools\bin\sdkmanager.bat "platforms;android-26" "build-tools;29.0.2"
If you do not have adb installed you can do so with:
cd <sdk-path>
tools\bin\sdkmanager.bat platform-tools
Unzip the
Android NDK r21d
into a directory of your choosing, and set the ANDROID_NDK_HOME
environment
variable to point to this directory.
Either do this globally or in your shell every time.
Make sure the environment is setup before you run bazel (bazel shutdown
will shut it down).
-
Add
C:\tools\msys64\mingw64
to the PATH:set PATH=C:\tools\msys64\mingw64\bin;%PATH%
Runningwhere gcc
should now find mingw’s gcc. -
Add
C:\tools\python27
to the PATH:set PATH=C:\tools\python27;%PATH%
Alternatively, pass the path to python via the--python_path
to bazel. See the bazel documentation for more info. -
Set TMP to something very short.
C:\tmp
is known to work. For faster builds, add this folder to the excemptions of the Windows Defender anti-malware scanner.
The following environment variables will need to be set prior to building:
Variable | Target |
---|---|
ANDROID_HOME |
Path to Android SDK |
ANDROID_NDK_HOME |
Path to Android NDK |
BAZEL_SH |
C:\tools\msys64\usr\bin\bash.exe |
TMP |
C:\tmp |
Follow the MacOS Bazel Install directions to install bazel.
A JDK is required to run a custom build of AGI. If you do not already have a suitable JDK installed, you can download the OpenJDK we use on our build bots.
Make sure the JAVA_HOME
environment variable points to the JDK.
⚠️ If you find the application menu bar non-responsive when launching your build of AGI, the following command should fix it:sudo mkdir $JAVA_HOME/bin/Contents
Unzip the Android SDK to a directory of your choosing.
To fetch the required packages, using a console type:
cd <sdk-path>
tools/bin/sdkmanager "platforms;android-26" "build-tools;29.0.2"
If you do not have adb installed you can do so with:
cd <sdk-path>
tools/bin/sdkmanager platform-tools
Unzip the
Android NDK r21d
into a directory of your choosing, and set the ANDROID_NDK_HOME
environment
variable to point to this directory:
export ANDROID_NDK_HOME=<ndk-path>
After installing, ensure the XCode license is signed with:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license
Bazel can concurrently use more file handles than the OS supports by default. This can be easily fixed by typing:
sudo sysctl -w kern.maxfiles=122880
sudo sysctl -w kern.maxfilesperproc=102400
echo ulimit -S -n 102400 >> ~/.bashrc
Either do this globally or in your shell every time.
Make sure the environment is setup before you run bazel (bazel shutdown
will shut it down).
The following environment variables will need to be set prior to building:
Variable | Target |
---|---|
ANDROID_HOME |
Path to Android SDK |
ANDROID_NDK_HOME |
Path to Android NDK |
Follow the Ubuntu Bazel Install or theFedora/CentOS Bazel Install directions to install bazel.
Alternatively, bazel can be downloaded from its GitHub Releases Page.
A JDK is required to run a custom build of AGI. If you do not already have a suitable JDK installed, you can download the OpenJDK we use on our build bots.
Make sure the JAVA_HOME
environment variable points to the JDK.
Unzip the Android SDK to a directory of your choosing.
To fetch the required packages, using a console type:
cd <sdk-path>
tools/bin/sdkmanager "platforms;android-26" "build-tools;29.0.2"
If you do not have adb installed you can do so with:
cd <sdk-path>
tools/bin/sdkmanager platform-tools
Unzip the
Android NDK r21d
into a directory of your choosing, and set the ANDROID_NDK_HOME
environment
variable to point to this directory:
export ANDROID_NDK_HOME=<ndk-path>
sudo apt-get update
sudo apt-get install mesa-common-dev libncurses5-dev libgl1-mesa-dev zlib1g-dev
Either do this globally or in your shell every time.
Make sure the environment is setup before you run bazel (bazel shutdown
will shut it down).
The following environment variables will need to be set prior to building:
Variable | Target |
---|---|
ANDROID_HOME |
Path to Android SDK |
ANDROID_NDK_HOME |
Path to Android NDK |