Skip to content

Commit

Permalink
docs: update build and dev-env, remove wrapper stuff, ref #204
Browse files Browse the repository at this point in the history
  • Loading branch information
iboB committed Nov 25, 2024
1 parent e0f06c7 commit 28d2f5f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 60 deletions.
48 changes: 6 additions & 42 deletions doc/dev/build.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
# Build

These are the build instruction and build documentation for the Alpaca Core Local SDK.

If you're not only interested in building the project but also setting up a development environment, you might want also to check out the [development environment documentation](dev-env.md).

> [!IMPORTANT]
> When cloning this repo, don't forget to fetch the submodules.
> * Either: `$ git clone https://github.com/alpaca-core/ac-local.git --recurse-submodules`
> * Or:
> * `$ git clone https://github.com/alpaca-core/ac-local.git`
> * `$ cd ac-local`
> * `$ git submodule update --init --recursive`
> If you're not only interested in building the project but also setting up a development environment, you might want also to check out the [development environment documentation](dev-env.md).
## Prerequisites

Expand All @@ -20,48 +10,22 @@ The minimum requirements are:
* MSVC 19.30 (Visual Studio 2022 v17.00) or later
* GCC 11 or later
* Clang 14 or later
* [CMake](https://cmake.org/) 3.22 or later
* [CMake](https://cmake.org/) 3.24 or later
* For some build flavors and optional components:
* Android: CMake 3.24 is needed to properly find JNI
* The Java wrapper should work with Java 8+, but Java 17+ is needed to build the Java tests and examples
* To build the Swift wrapper, you need Swift 6.0.0 or later. Moreover, on non-macOS systems you need to use the clang compiler shipped with your swift installation.
* GUI Demos: [SDL2](https://wiki.libsdl.org/SDL2/FrontPage)
* Different computational backends require their respective SDKs and dependencies

If you want practical steps on for specific environments, check the [developer environments documentation](dev-env.md).

## Configure

Some useful presets are provided in `CMakePresets.json`. As a convention each presets writes the configured files in `<repo-root>/out/build/<preset-name>`. Note that most of the included CMake presets all also require [ninja](https://ninja-build.org/).

Example:

* `$ cmake --preset=release`
* Configuration files are written in `<repo-root>/out/build/release`

For finer grain control or if you're using the repo as a subdirectory:

### CMake Options

* `AC_BUILD_LOCAL` - build the local inference api and integrations of inference libraries
* `AC_INFERENCE_LIBS` - `all` or `none` or semicolon separated list. Which inference libraries to build. The supported ones are:
* `dummy`: a dummy inference library for testing and experimenting
* `llama.cpp`: wrapping our fork of [ggerganov/llama.cpp](https://github.com/ggerganov/llama.cpp)
* `whisper`: wrapping our fork of [ggerganov/whisper.cpp](https://github.com/ggerganov/whisper.cpp)
* `AC_BUILD_ACORD`: build the Alpaca Core daemon. This is `OFF` by default if the project is a subdir. Only available if `AC_BUILD_LOCAL` is `ON`.
* Advanced and `OFF` by default if the project is a subdir:
* `AC_BUILD_TOOLS` - build all tools for all active components. No finer-grain options are available yet
* `AC_BUILD_TESTS` - build all tests for all active components. No finer-grain options are available yet. Git LFS is required for some tests
* `AC_BUILD_EXAMPLES` - build all examples for all active components. No finer-grain options are available yet. Git LFS is required for some examples
* `AC_BUILD_POC` - build proof of concept, sandbox, and experimental projects
* Wrapper config.
* Wrapper options are have three possible values: `ON`, `OFF`, and `AUTO`. `AUTO` will try to detect if the wrapper can be built.
* `AC_WRAPPER_DEFAULT_VALUE`: this is not a CMake option, but you can define it for the initial configuration. It determines what the dafault value for wrapper options will be. If it's not defined, it defaults to `OFF` when the project is a subdir, and `AUTO` if it's root.
* `AC_C_WRAPPER`: build C wrapper. `AUTO` equals `ON`. C should always be available if you have C++.
* `AC_JAVA_WRAPPER`: build Java wrapper. `AUTO` checks if JNI is available
* `AC_COCOA_WRAPPER`: build Cocoa wrapper. `AUTO` checks for `APPLE`
* `AC_SWIFT_WRAPPER`: build Swift wrapper. `AUTO` checks if `swiftc` is available
* Only available when ac-local is the root project and `OFF` by default:
* `AC_LOCAL_BUILD_TOOLS` - build tools for all components. No finer-grain options are available yet
* `AC_LOCAL_BUILD_TESTS` - build tests for all active components. No finer-grain options are available yet. Git LFS is required for some tests
* `AC_LOCAL_BUILD_EXAMPLES` - build examples for all active components. No finer-grain options are available yet. Git LFS is required for some examples
* From ac-build and only available when ac-local is the root project and `OFF` by default:
* `SAN_ADDR`: enable address sanitizer.
* `SAN_UB`: enable undefined behavior sanitizer. Not supported on Windows.
* `SAN_LEAK`: enable leak sanitizer. Only supported on Linux.
Expand Down
26 changes: 8 additions & 18 deletions doc/dev/dev-env.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ We use Ubuntu 24.04, but the setup will likely work for other versions as well.
* `$ git lfs install` - do not forget this!
* `$ sudo apt install cmake`
* `$ sudo apt install ninja-build`
* `$ sudo apt install ruby` - needed for schema codegen
* `$ sudo apt install libssl-dev` (optional for HTTPS downloads)
* `$ sudo apt install libsdl2-dev` (optional for GUI demos)
* Optionally for the java wrapper: `$ sudo apt install openjdk-17-jdk`
* Compute backends (may or may not be applicable to your system):
* Cuda: `$ sudo apt install nvidia-cuda-toolkit`
* Vulkan: `$ sudo apt install libvulkan-dev`
Expand All @@ -32,11 +32,9 @@ We use Manjaro so some packages might have different names in pure AUR Arch Linu
* `$ sudo pacman -S cmake`
* `$ sudo pacman -S gcc`
* `$ sudo pacman -S ninja`
* `$ sudo pacman -S ruby` - needed for schema codegen
* `$ sudo pacman -S openssl` (optional for HTTPS downloads)
* `$ sudo pacman -S sdl2` (optional for GUI demos)
* Optionally for the java wrapper: `$ sudo pacman -S jdk-openjdk`
* Optionally for the swift wrapper: `$ pamac build swift-bin`
* Note that to build the swift wrapper, you will have to configure with `-DCMAKE_CXX_COMPILER=/usr/lib/swift/bin/clang++ -DCMAKE_C_COMPILER=/usr/lib/swift/bin/clang`
* Compute backends (may or may not be applicable to your system):
* Cuda: `$ sudo pacman -S cuda`
* Vulkan: `$ sudo pacman -Sg vulkan-devel`
Expand All @@ -55,6 +53,8 @@ Install the following software (we recommend using Chocolatey, Scoop, or WinGet,
* [CMake](https://cmake.org/download/) 3.24 or later
* OpenSSL 3 (Optional for HTTPS downloads). Windows binary builds available [here](https://slproweb.com/products/Win32OpenSSL.html) (Install the Win64 non-light version))
* set the `OPEN_SSL_ROOT_DIR` environment variable to the OpenSSL installation directory
* Ruby 3+ is needed for the schema codegen:
* If you don't use a package manager, use [Ruby Installer](https://rubyinstaller.org/)
* SDL2 (Optional, for GUI demos and tools). If you also install the Vulkan SDK, follow the steps for it below. They also provide SDL2. Alternatively:
* Binary builds available [here](https://github.com/libsdl-org/SDL/releases) (note that first entries there will be for SDL3, scroll to find the latest SDL2 release).
* Add the SDL2 installation directory to the `CMAKE_PREFIX_PATH` environment variable
Expand All @@ -65,13 +65,6 @@ Install the following software (we recommend using Chocolatey, Scoop, or WinGet,
* [Android gradle plugin](https://developer.android.com/build/releases/gradle-plugin)
* Set the `ANDROID_HOME` environment variable to the Android SDK installation directory
* Set the `ANDROID_NDK_ROOT` environment variable to the Android NDK installation directory
* For the Java wrapper (optional):
* JDK. [Microsoft OpenJDK 17](https://learn.microsoft.com/en-us/java/openjdk/download#openjdk-17) works, but any other JDK 17 or later should be fine as well
* Set the `JAVA_HOME` environment variable to the JDK installation directory
* For the Swift wrapper (optional):
* Install Swift in any of the ways described [here](https://www.swift.org/install/windows)
* Note that on you need to use the clang compiler shipped with your swift installation
* Also note that installing the Swift will add clang++ to your system path. If you also use other clang compilers, you will have to juggle the system path around accorting to what you currently need.
* Optional compute backends which may or may not be applicable to your system:
* [CUDA 12](https://developer.nvidia.com/cuda-downloads)
* Vulkan SDK
Expand All @@ -89,7 +82,7 @@ Enable git LFS: `> git lfs install`
* Even if you want to target Android, you do *not* need the Android development components.
* If you already have them, it's fine. You do not need to uninstall them.
* We don't support android builds through Visual Studio
* Use "open folder" in Visual Studio to open the project directory, configure, and build.
* Use "open folder" in Visual Studio to open project directories, configure, and build.
* Alternatively configuring with a Visual Studio generator will likely work, but it's not supported

### VS Code Setup
Expand All @@ -107,13 +100,13 @@ Enable git LFS: `> git lfs install`
* CMake Tools
* CMake Language Support
* C/C++
* Open the project directory in VS Code, configure, and build.
* Open project directories in VS Code, configure, and build.

## macOS

We use macOS Sequoia, but the setup will likely work for earlier versions as well.

Note, however, that we do not support x86 macOS. We only support Apple Silicon.
Note that since most plugins don't support accelleration on x86 macOS, we don't support it either. We only support Apple Silicon.

On macOS we recommend using VS Code or Xcode.

Expand All @@ -133,9 +126,6 @@ Technically you can setup the requirements manually, but, please, just use [Home
* Install Android Studio
* Install SDK with API Level at least 32 and NDK
* Set the `ANDROID_NDK_ROOT` environment variable to the Android NDK installation directory
* Optionally for the Java wrapper: `$ brew install openjdk` or `$ brew install openjdk@17` (both should work)
* Set the `JAVA_HOME` environment variable to the JDK installation directory, but note that CMake doesn't deal well with the brew symlinks for openjdk.
* Brew will symlink the installation to `/opt/homebrew/opt/openjdk`. *Do not* set this to `JAVA_HOME`. Instead, set it to the actual installation directory, which will likely be `/opt/homebrew/opt/openjdk/libexec/openjdk.jdk/Contents/Home`

### Visual Studio Code Setup

Expand All @@ -144,6 +134,6 @@ Technically you can setup the requirements manually, but, please, just use [Home
* CMake Tools
* CMake Language Support
* C/C++
* Open the project directory in VS Code, configure, and build.
* Open project directories in VS Code, configure, and build.

### Xcode Setup

0 comments on commit 28d2f5f

Please sign in to comment.