AGI uses the Bazel build system. The recommended version of Bazel is 6.5.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
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 6.5.0
In the same console, install Python and MSYS2 as well:
choco install python
choco install msys2
From the Start Menu select the MSYS2 64bit / MSYS2 MinGW 64-bit
shell:
- Update MSYS2 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-10.2.0-10-any.pkg.tar.zst
- Download gcc-libs with:
curl -O http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-gcc-libs-10.2.0-10-any.pkg.tar.zst
- Install the downloaded packages with:
pacman -U mingw-w64-x86_64-gcc*-10.2.0-10-any.pkg.tar.zst
- Close the MSYS2 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.
If you have Android Studio installed, use it to install:
- SDK Platform:
API Level 34
- SDK Tools:
NDK (Side by side) - 21.3.6528147
Otherwise you can use the basic Android command line tools:
-
Create a directory for the Android SDK, for example
C:\Android\sdk\
. -
Create the subdirectories
<sdk-path>\cmdline-tools\latest\
. This exact name allows the tools to determine the SDK directory. -
Download the tools from Android Studio downloads.
-
Extract the tools somewhere and move the contents of
cmdline-tools\
to the created<sdk-path>\cmdline-tools\latest\
. -
Use a console to fetch the required packages:
cd <sdk-path> cmdline-tools\latest\bin\sdkmanager.bat "platforms;android-34" cmdline-tools\latest\bin\sdkmanager.bat "build-tools;30.0.3" cmdline-tools\latest\bin\sdkmanager.bat "ndk;21.3.6528147"
-
If you do not have adb installed you can do so with:
cd <sdk-path> cmdline-tools\latest\bin\sdkmanager.bat platform-tools
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 MSYS2 binary directories to the PATH:
set PATH=C:\tools\msys64\usr\bin;C:\tools\msys64\mingw64\bin;%PATH%
Runningwhere gcc
should now find mingw’s gcc. -
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, e.g. C:\Android\sdk |
ANDROID_NDK_HOME |
Path to Android NDK, e.g. %ANDROID_HOME%\ndk\21.3.6528147 |
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-34" "build-tools;30.0.3"
If you do not have adb installed you can do so with:
cd <sdk-path>
tools/bin/sdkmanager platform-tools
Install
Android NDK r21d (installing the App Bundle is needed in order to keep the notarization)
into the /Applications/ folder, and set the ANDROID_NDK_HOME
environment pointing to NDK subdirectory:
export ANDROID_NDK_HOME=/Applications/AndroidNDK6528147.app/Contents/NDK
After installing, ensure the XCode license is signed with:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license
We use Clang-12 to build AGI on Linux which should be part of XCode 12. If there is no clang on the system it and can be downloaded from https://apt.llvm.org/. After downloading and installing Clang-12, add it to environment.
export CC=clang-12
Alternatively, GCC can also be used for compiling AGI but we cannot guarantee that every GCC version will be able to compile AGI.
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.
We use Clang-12 to build AGI on Linux which can be downloaded from https://apt.llvm.org/ After downloading and installing Clang-12, add it to environment.
export CC=clang-12
Alternatively, GCC can also be used for compiling AGI but we cannot guarantee that every GCC version will be able to compile AGI.
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-34" "build-tools;30.0.3"
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 |