Skip to content

Commit

Permalink
Introduce feature sets for clients
Browse files Browse the repository at this point in the history
  • Loading branch information
inikulin committed Jan 26, 2024
1 parent 61d607a commit 9df801d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 11 deletions.
35 changes: 33 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,23 @@ jobs:
thing:
- x86_64-linux
- aarch64-linux
- arm64-android
- arm-android
- aarch64-ios
- x86_64-macos
include:
- apt_packages: ""
- custom_env: {}
- build_only: false
- cargo_args: ""

- thing: x86_64-linux
target: x86_64-unknown-linux-gnu
rust: stable
os: ubuntu-latest

- thing: aarch64-linux
build_only: true
target: aarch64-unknown-linux-gnu
rust: stable
os: ubuntu-latest
Expand All @@ -69,11 +76,32 @@ jobs:
CC: aarch64-linux-gnu-gcc
CXX: aarch64-linux-gnu-g++
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-g++

- thing: arm64-android
build_only: true
target: aarch64-linux-android
rust: stable
os: ubuntu-latest
cargo_args: --no-default-features --features server-client-common-default

- thing: arm-android
build_only: true
target: armv7-linux-androideabi
rust: stable
os: ubuntu-latest
cargo_args: --no-default-features --features server-client-common-default

- thing: aarch64-ios
build_only: true
target: aarch64-apple-ios
os: macos-latest
cargo_args: --no-default-features --features server-client-common-default

- thing: x86_64-macos
target: x86_64-apple-darwin
rust: stable
os: macos-latest

steps:
- uses: actions/checkout@v2
with:
Expand All @@ -86,13 +114,16 @@ jobs:
run: sudo apt update && sudo apt install -y ${{ matrix.apt_packages }}
shell: bash
- run: rustup target add ${{ matrix.target }}
- name: Set Android Linker path
if: endsWith(matrix.thing, '-android')
run: echo "CARGO_TARGET_$(echo ${{ matrix.target }} | tr \\-a-z _A-Z)_LINKER=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/$(echo ${{ matrix.target }} | sed s/armv7/armv7a/)21-clang++" >> "$GITHUB_ENV"
- name: Build tests
# We `build` because we want the linker to verify we are cross-compiling correctly for check-only targets.
run: cargo build --target ${{ matrix.target }}
run: cargo build --target ${{ matrix.target }} ${{matrix.cargo_args}}
shell: bash
env: ${{ matrix.custom_env }}
- name: Run tests
if: "!matrix.build_only"
run: _RJEM_MALLOC_CONF=prof:true cargo test --target ${{ matrix.target }}
run: _RJEM_MALLOC_CONF=prof:true cargo test --target ${{ matrix.target }} ${{matrix.cargo_args}}
shell: bash
env: ${{ matrix.custom_env }}
16 changes: 8 additions & 8 deletions foundations/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ categories = [
"external-ffi-bindings",
"memory-management",
]
keywords = [
"service",
"telemetry",
"settings",
"seccomp",
"metrics",
]
keywords = ["service", "telemetry", "settings", "seccomp", "metrics"]

[package.metadata.release]
# run in the context of workspace root
Expand All @@ -40,14 +34,17 @@ default = ["platform-common-default", "security"]

# All non platform-specific features
platform-common-default = [
"metrics",
"settings",
"jemalloc",
"telemetry",
"cli",
"testing",
]

# A subset of features that can be used both on server and client sides. Useful for libraries
# that can be used either way.
server-client-common-default = ["settings", "client-telemetry", "testing"]

# Enables metrics functionality.
metrics = [
"dep:foundations-macros",
Expand Down Expand Up @@ -80,6 +77,9 @@ telemetry = [
"telemetry-server",
]

# Enables a subset of telemetry features suitable for usage in clients.
client-telemetry = ["logging", "metrics", "tracing"]

# Enables the telemetry server.
telemetry-server = [
"dep:futures-util",
Expand Down
5 changes: 4 additions & 1 deletion foundations/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ mod security {
// so we can't use those gates here and must check at runtime the `TARGET` environment
// variable. This is unfortunate as it means we need to depend on bindgen even
// when targetting macOS. See https://github.com/rust-lang/cargo/issues/4932.
if target.contains("linux") && (target.contains("x86_64") || target.contains("aarch64")) {
if target.contains("linux")
&& !target.contains("android")
&& (target.contains("x86_64") || target.contains("aarch64"))
{
linux_build();
}
}
Expand Down
3 changes: 3 additions & 0 deletions foundations/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
//! - **default**: All features are enabled by default.
//! - **platform-common-default**: The same as **default**, but excludes platform-specific features,
//! such as **security**.
//! - **server-client-common-default**: A subset of features that can be used both on server and client sides.
//! Useful for libraries that can be used either way.
//! - **settings**: Enables serializable documented settings functionality.
//! - **telemetry**: Enables all the telemetry-related features (**metrics**, **logging**, **tracing**, **telemetry-server**).
//! - **telemetry-server**: Enables the telemetry server.
//! - **client-telemetry**: Enables a subset of telemetry features suitable for usage in clients (e.g. on mobile devices).
//! - **metrics**: Enables metrics functionality.
//! - **logging**: Enables logging functionality.
//! - **tracing**: Enables distributed tracing functionality.
Expand Down

0 comments on commit 9df801d

Please sign in to comment.