Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ build:macos_x86_64 --extra_execution_platforms=//platform/host:darwin_x86_64

# For all builds, use C++17
build --cxxopt="-std=c++17"
build --java_runtime_version=remotejdk_17

# Statically link C++ deps into Rust binaries (avoids RPATH issues)
build --@rules_rust//rust/settings:experimental_use_cc_common_link=True
Expand Down Expand Up @@ -97,6 +98,10 @@ build:android_arm64 --cpu=aarch64
build:android_arm64 --linkopt=-lc++_static
build:android_arm64 --linkopt=-lc++abi
build:android_arm64 --extra_toolchains=@androidndk//:all
# Abseil strips flag names on Android by default (ABSL_FLAGS_STRIP_NAMES=1),
# which breaks parsing flags by name (e.g. --socket) on the command line even
# though GetFlag() still works. Keep the names so server/tool flags work.
build:android_arm64 --copt=-DABSL_FLAGS_STRIP_NAMES=0

build:android_x86_64 --platforms=//platform/android:android_x86_64
build:android_x86_64 --action_env=ANDROID_NDK_HOME
Expand All @@ -105,6 +110,8 @@ build:android_x86_64 --cpu=x86_64
build:android_x86_64 --linkopt=-lc++_static
build:android_x86_64 --linkopt=-lc++abi
build:android_x86_64 --extra_toolchains=@androidndk//:all
# See android_arm64 note above.
build:android_x86_64 --copt=-DABSL_FLAGS_STRIP_NAMES=0

build:android --config=android_arm64

Expand Down
144 changes: 144 additions & 0 deletions .cursor/skills/subspace-builds/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
---
name: subspace-builds
description: Build and test Subspace across supported platforms and build systems. Use when the user asks how to build, test, cross-compile, run CI-equivalent checks, or work with Bazel, CMake, Android, Soong/Blueprint, AOSP, QNX, Linux, or macOS builds in this repository.
---

# Subspace Builds

## General Rules

- User-facing examples should use `bazel`; use `bazelisk` as a drop-in
replacement if `bazel` is not available.
- Prefer focused targets while iterating; use `bazel test //...` only when
broad verification is needed.
- Check `.bazelrc`, `.github/workflows/ci.yml`, and `docs/android.md` before changing platform build behavior.
- Do not check in generated protobuf files.

## Native Host Builds

Linux:

```bash
CC=clang bazel build //...
bazel test //...

cmake -S . -B build/cmake-Debug -DCMAKE_BUILD_TYPE=Debug
cmake --build build/cmake-Debug --parallel
ctest --test-dir build/cmake-Debug --output-on-failure
```

macOS Apple Silicon:

```bash
bazel build //... --config=macos_arm64
bazel test //... --config=macos_arm64
```

macOS Intel:

```bash
bazel build //... --config=macos_x86_64
bazel test //... --config=macos_x86_64
```

## Android With Bazel

Requires `ANDROID_NDK_HOME`.

```bash
bazel build \
//server:subspace_server \
//client:client_test \
//c_client:client_test \
//plugins:nop_plugin.so \
//plugins:split_buffer_free_test_plugin.so \
//android/jni:libsubspace_jni.so \
//android/java:subspace-java \
//android/java:subspace-java-test \
--config=android_arm64
```

Use `--config=android_x86_64` for x86_64 emulators and GitHub CI. The emulator
deployment and test flow is in `.github/scripts/android-test.sh`.

## Android With CMake

Requires `ANDROID_NDK_HOME`. Build a host `protoc` first and pass it into the
Android cross-compile so protobuf versions match:

```bash
cmake -S . -B build/host-protoc -DCMAKE_BUILD_TYPE=Release
cmake --build build/host-protoc --target protoc --parallel

cmake -S . -B build/android \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=arm64-v8a \
-DANDROID_PLATFORM=android-28 \
-DANDROID_STL=c++_shared \
-DCMAKE_BUILD_TYPE=Release \
-DPROTOC_EXECUTABLE="$PWD/build/host-protoc/_deps/protobuf-build/protoc"

cmake --build build/android --parallel
```

Use `-DANDROID_ABI=x86_64` for x86_64 emulators and GitHub CI. The emulator
deployment and test flow is in `.github/scripts/cmake-android-test.sh`.

## Android With Soong/Blueprint

Soong requires a full AOSP checkout; GitHub-hosted runners do not provide one.
Use a local AOSP tree or a self-hosted runner with AOSP already synced.

Place this repository at `external/subspace`, ensure `external/coroutines` and
`external/cpp_toolbelt` are present, and copy their repository-provided
`Android.bp.example` files to `Android.bp`.

Add to the product:

```make
PRODUCT_SOONG_NAMESPACES += external/subspace
PRODUCT_PACKAGES += \
subspace_server \
libsubspace_client \
libsubspace_jni \
subspace-java \
subspace_java_client_test
```

Build from AOSP root:

```bash
source build/envsetup.sh
lunch <product>-userdebug

m external.subspace-subspace_server-soong \
external.subspace-libsubspace_client-soong \
external.subspace-libsubspace_jni-soong \
external.subspace-subspace-java-soong \
external.subspace-subspace_java_client_test-soong
```

Run the device-side Java integration test:

```bash
adb shell subspace_java_client_test
```

## QNX With Bazel

Requires the QNX SDP and `QNX_SDP_PATH`.

```bash
bazel build //... --config=qnx_aarch64
bazel build //... --config=qnx_x86_64
```

If the default path in `.bazelrc` is wrong, set `QNX_SDP_PATH` in the
environment or user-local `user.bazelrc`.

## References

- Android details: `docs/android.md`
- General Bazel/CMake docs: `README.md`
- CI build matrix: `.github/workflows/ci.yml`
- Test runner rule: `.cursor/rules/test-runner.mdc`
Loading
Loading