From 2c0e7ce8b60cb9b43105e8276a64d83edfa4383c Mon Sep 17 00:00:00 2001 From: Adam Chalmers Date: Fri, 8 Dec 2023 14:52:57 -0600 Subject: [PATCH] Make cxx a feature --- .github/workflows/ci.yml | 13 ++++++++----- modeling-cmds/Cargo.toml | 6 +++++- modeling-cmds/src/lib.rs | 1 + modeling-cmds/src/shared.rs | 5 ++++- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42f47f72..4caddb50 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,10 +49,14 @@ jobs: components: clippy - uses: Swatinem/rust-cache@v2.7.0 - - name: cargo clippy + - name: Run clippy shell: bash - run: | - cargo clippy --tests --benches --workspace --examples -- -D warnings + run: cargo clippy --tests --benches --workspace --examples -- -D warnings + env: + RUST_BACKTRACE: 1 + - name: Run clippy (all features) + shell: bash + run: cargo clippy --tests --benches --workspace --examples --all-features -- -D warnings env: RUST_BACKTRACE: 1 @@ -81,8 +85,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 - name: Install codespell - run: | - python -m pip install codespell + run: python -m pip install codespell - name: Run codespell # Edit this file to tweak the typo list and other configuration. run: codespell --config .codespellrc diff --git a/modeling-cmds/Cargo.toml b/modeling-cmds/Cargo.toml index 2661d32b..c0f64ba5 100644 --- a/modeling-cmds/Cargo.toml +++ b/modeling-cmds/Cargo.toml @@ -12,7 +12,7 @@ license = "MIT" [dependencies] chrono = "0.4.31" -cxx = "1.0" +cxx = { version = "1.0", optional = true } data-encoding = "2.5.0" diesel = { version = "2.1.1", features = ["serde_json", "mysql", "chrono", "r2d2", "uuid", "numeric"] } diesel_derives = "2.1.2" @@ -31,3 +31,7 @@ uuid = { version = "1.6.1", features = ["serde"] } [lints] workspace = true + +[features] +default = [] +cxx = ["dep:cxx"] \ No newline at end of file diff --git a/modeling-cmds/src/lib.rs b/modeling-cmds/src/lib.rs index 52ae0736..2850cce0 100644 --- a/modeling-cmds/src/lib.rs +++ b/modeling-cmds/src/lib.rs @@ -12,6 +12,7 @@ pub mod format; /// Modeling command IDs, used to associated requests and responses. /// Also used to construct commands which refer to previous commands. pub mod id; +#[cfg(feature = "cxx")] pub mod impl_extern_type; mod impl_traits; /// When a modeling command is successful, these responses could be returned. diff --git a/modeling-cmds/src/shared.rs b/modeling-cmds/src/shared.rs index 09004d9f..13c48f97 100644 --- a/modeling-cmds/src/shared.rs +++ b/modeling-cmds/src/shared.rs @@ -7,7 +7,9 @@ use parse_display_derive::{Display, FromStr}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::{impl_extern_type, units::UnitAngle}; +#[cfg(feature = "cxx")] +use crate::impl_extern_type; +use crate::units::UnitAngle; // A helper macro for allowing enums of only strings to be saved to the database. macro_rules! impl_string_enum_sql { @@ -726,6 +728,7 @@ impl_string_enum_sql! {FileImportFormat} // Enum: Connect Rust Enums to Cpp // add our native c++ names for our cxx::ExternType implementation +#[cfg(feature = "cxx")] impl_extern_type! { [Trivial] // File