Skip to content

Commit 9df801d

Browse files
committed
Introduce feature sets for clients
1 parent 61d607a commit 9df801d

File tree

4 files changed

+48
-11
lines changed

4 files changed

+48
-11
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,23 @@ jobs:
5151
thing:
5252
- x86_64-linux
5353
- aarch64-linux
54+
- arm64-android
55+
- arm-android
56+
- aarch64-ios
5457
- x86_64-macos
5558
include:
5659
- apt_packages: ""
5760
- custom_env: {}
5861
- build_only: false
62+
- cargo_args: ""
63+
5964
- thing: x86_64-linux
6065
target: x86_64-unknown-linux-gnu
6166
rust: stable
6267
os: ubuntu-latest
68+
6369
- thing: aarch64-linux
70+
build_only: true
6471
target: aarch64-unknown-linux-gnu
6572
rust: stable
6673
os: ubuntu-latest
@@ -69,11 +76,32 @@ jobs:
6976
CC: aarch64-linux-gnu-gcc
7077
CXX: aarch64-linux-gnu-g++
7178
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-g++
79+
80+
- thing: arm64-android
81+
build_only: true
82+
target: aarch64-linux-android
83+
rust: stable
84+
os: ubuntu-latest
85+
cargo_args: --no-default-features --features server-client-common-default
86+
87+
- thing: arm-android
7288
build_only: true
89+
target: armv7-linux-androideabi
90+
rust: stable
91+
os: ubuntu-latest
92+
cargo_args: --no-default-features --features server-client-common-default
93+
94+
- thing: aarch64-ios
95+
build_only: true
96+
target: aarch64-apple-ios
97+
os: macos-latest
98+
cargo_args: --no-default-features --features server-client-common-default
99+
73100
- thing: x86_64-macos
74101
target: x86_64-apple-darwin
75102
rust: stable
76103
os: macos-latest
104+
77105
steps:
78106
- uses: actions/checkout@v2
79107
with:
@@ -86,13 +114,16 @@ jobs:
86114
run: sudo apt update && sudo apt install -y ${{ matrix.apt_packages }}
87115
shell: bash
88116
- run: rustup target add ${{ matrix.target }}
117+
- name: Set Android Linker path
118+
if: endsWith(matrix.thing, '-android')
119+
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"
89120
- name: Build tests
90121
# We `build` because we want the linker to verify we are cross-compiling correctly for check-only targets.
91-
run: cargo build --target ${{ matrix.target }}
122+
run: cargo build --target ${{ matrix.target }} ${{matrix.cargo_args}}
92123
shell: bash
93124
env: ${{ matrix.custom_env }}
94125
- name: Run tests
95126
if: "!matrix.build_only"
96-
run: _RJEM_MALLOC_CONF=prof:true cargo test --target ${{ matrix.target }}
127+
run: _RJEM_MALLOC_CONF=prof:true cargo test --target ${{ matrix.target }} ${{matrix.cargo_args}}
97128
shell: bash
98129
env: ${{ matrix.custom_env }}

foundations/Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,7 @@ categories = [
1414
"external-ffi-bindings",
1515
"memory-management",
1616
]
17-
keywords = [
18-
"service",
19-
"telemetry",
20-
"settings",
21-
"seccomp",
22-
"metrics",
23-
]
17+
keywords = ["service", "telemetry", "settings", "seccomp", "metrics"]
2418

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

4135
# All non platform-specific features
4236
platform-common-default = [
43-
"metrics",
4437
"settings",
4538
"jemalloc",
4639
"telemetry",
4740
"cli",
4841
"testing",
4942
]
5043

44+
# A subset of features that can be used both on server and client sides. Useful for libraries
45+
# that can be used either way.
46+
server-client-common-default = ["settings", "client-telemetry", "testing"]
47+
5148
# Enables metrics functionality.
5249
metrics = [
5350
"dep:foundations-macros",
@@ -80,6 +77,9 @@ telemetry = [
8077
"telemetry-server",
8178
]
8279

80+
# Enables a subset of telemetry features suitable for usage in clients.
81+
client-telemetry = ["logging", "metrics", "tracing"]
82+
8383
# Enables the telemetry server.
8484
telemetry-server = [
8585
"dep:futures-util",

foundations/build.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ mod security {
6161
// so we can't use those gates here and must check at runtime the `TARGET` environment
6262
// variable. This is unfortunate as it means we need to depend on bindgen even
6363
// when targetting macOS. See https://github.com/rust-lang/cargo/issues/4932.
64-
if target.contains("linux") && (target.contains("x86_64") || target.contains("aarch64")) {
64+
if target.contains("linux")
65+
&& !target.contains("android")
66+
&& (target.contains("x86_64") || target.contains("aarch64"))
67+
{
6568
linux_build();
6669
}
6770
}

foundations/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@
2323
//! - **default**: All features are enabled by default.
2424
//! - **platform-common-default**: The same as **default**, but excludes platform-specific features,
2525
//! such as **security**.
26+
//! - **server-client-common-default**: A subset of features that can be used both on server and client sides.
27+
//! Useful for libraries that can be used either way.
2628
//! - **settings**: Enables serializable documented settings functionality.
2729
//! - **telemetry**: Enables all the telemetry-related features (**metrics**, **logging**, **tracing**, **telemetry-server**).
2830
//! - **telemetry-server**: Enables the telemetry server.
31+
//! - **client-telemetry**: Enables a subset of telemetry features suitable for usage in clients (e.g. on mobile devices).
2932
//! - **metrics**: Enables metrics functionality.
3033
//! - **logging**: Enables logging functionality.
3134
//! - **tracing**: Enables distributed tracing functionality.

0 commit comments

Comments
 (0)