From 9df801d88a38fc4be3999330fb3a779f07da80ea Mon Sep 17 00:00:00 2001 From: Ivan Nikulin Date: Fri, 26 Jan 2024 12:43:37 +0000 Subject: [PATCH] Introduce feature sets for clients --- .github/workflows/ci.yml | 35 +++++++++++++++++++++++++++++++++-- foundations/Cargo.toml | 16 ++++++++-------- foundations/build.rs | 5 ++++- foundations/src/lib.rs | 3 +++ 4 files changed, 48 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0c36a7..e0cae1f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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: @@ -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 }} diff --git a/foundations/Cargo.toml b/foundations/Cargo.toml index 3108905..fe97d85 100644 --- a/foundations/Cargo.toml +++ b/foundations/Cargo.toml @@ -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 @@ -40,7 +34,6 @@ default = ["platform-common-default", "security"] # All non platform-specific features platform-common-default = [ - "metrics", "settings", "jemalloc", "telemetry", @@ -48,6 +41,10 @@ platform-common-default = [ "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", @@ -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", diff --git a/foundations/build.rs b/foundations/build.rs index c4b94c3..80502a9 100644 --- a/foundations/build.rs +++ b/foundations/build.rs @@ -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(); } } diff --git a/foundations/src/lib.rs b/foundations/src/lib.rs index 350bdb9..847a039 100644 --- a/foundations/src/lib.rs +++ b/foundations/src/lib.rs @@ -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.