From 0ae5aeefc6a57f9570e0da01658238b37effc2fc Mon Sep 17 00:00:00 2001 From: mk-rw Date: Tue, 25 Nov 2025 02:52:00 -0500 Subject: [PATCH 1/3] build: Consolidate important dependencies in monorepo `Cargo.toml` Due to the splintered nature of dependencies in the workspace, it can be difficult to perform monorepo-wide updates of dependencies, which can create subtle bugs due to incompatible dependency versions. Additionally, some rather obscure bugs can occur with some dependencies (e.g. defmt, embassy-executor) due to linker behaviour. Thus, this branch aims to consolidate most dependencies which may be reused often in the global `Cargo.toml` which greatly simplifies not only updating dependencies, but also setting up new crates in the project (e.g. crates used on the boards often want dependencies with `defmt` compatibility, so we can enable this feature at the workspace level). Finally, it may be beneficial to include [`cargo-deny`](https://github.com/EmbarkStudios/cargo-deny) for granular control over dependencies, versioning and other cargo stuff (e.g., warning the user when a workspace-level dependency is duplicated) --- Cargo.lock | 3 ++ Cargo.toml | 86 ++++++++++++++++------------------------- apps/sergw/Cargo.toml | 2 +- boards/argus/Cargo.toml | 27 +++++-------- 4 files changed, 47 insertions(+), 71 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a036aba..c4c011c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -613,6 +613,9 @@ name = "embassy-futures" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc2d050bdc5c21e0862a89256ed8029ae6c290a93aecefc73084b3002cdebb01" +dependencies = [ + "defmt 1.0.1", +] [[package]] name = "embassy-hal-internal" diff --git a/Cargo.toml b/Cargo.toml index 50acab4..cb3bc52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,61 +1,41 @@ [workspace] resolver = "2" -members = ["boards/*", "common/*", "apps/sergw"] +members = ["apps/sergw", "boards/*", "common/*"] # Specify which members to build by default. Some libraries, such as messages, contain dev-dependencies that will give # compile errors if built directly. default-members = ["boards/*"] -[workspace.dependencies.chrono] -git = "https://github.com/uorocketry/chrono" -default-features = false - -[workspace.dependencies.cortex-m] -version = "0.7.6" -features = ["critical-section-single-core"] - -[workspace.dependencies.prost] -version = "0.14.1" -features = ["derive"] -default-features = false - -[workspace.dependencies.cortex-m-rt] -version = "0.7.1" - -[workspace.dependencies.defmt] -version = "0.3.2" - -[workspace.dependencies.defmt-rtt] -version = "0.4" - -[workspace.dependencies.embedded-alloc] -version = "0.6.0" - -[workspace.dependencies.enum_dispatch] -version = "0.3.11" - -[workspace.dependencies.heapless] -version = "0.9.1" - -[workspace.dependencies.messages] -path = "./common/messages" - -[workspace.dependencies.nb] -version = "1.1.0" - -[workspace.dependencies.panic-probe] -version = "0.3" -features = ["print-defmt"] - -[workspace.dependencies.serde] -version = "1.0.150" -default-features = false -features = ["derive"] - -[workspace.dependencies.serde-csv-core] -version = "0.3.2" -features = ["defmt"] - -[workspace.dependencies.smlang] -version = "0.8.0" +# Here we put together any dependencies that are used basically everywhere, and allow for more consistency between packages, and a smoother dependency upgrade experience +# Only minimal feature flags are enabled here, due to the additive nature of inheriting workspace dependencies (can only add feature flags when inheriting, not remove any) +# NOTE: defmt compatibility feature flags are enabled when available here, unsure how desirable this is +[workspace.dependencies] +chrono = { git = "https://github.com/uorocketry/chrono", default-features = false } +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } +cortex-m-rt = "0.7.1" +critical-section = "1.1" +csv = { path = './common/csv' } +defmt = "0.3.2" +defmt-rtt = "0.4" +embassy-embedded-hal = { version = "0.3.0", features = ["defmt"] } +embassy-executor = { version = "0.7.0", features = ["defmt"] } +embassy-futures = { version = "0.1.0", features = ["defmt"] } +embassy-net = { version = "0.7.0", features = ["defmt"] } +embassy-stm32 = { version = "0.2.0", features = ["defmt"] } +embassy-sync = { version = "0.6.2", features = ["defmt"] } +embassy-time = { version = "0.4.0", features = [ + "defmt", + "defmt-timestamp-uptime", +] } +embassy-usb = { version = "0.4.0", features = ["defmt"] } +embedded-alloc = "0.6.0" +enum_dispatch = "0.3.11" +heapless = "0.9.1" +messages = { path = "./common/messages" } +nb = "1.1.0" +panic-probe = { version = "0.3", features = ["print-defmt"] } +prost = { version = "0.14.1", default-features = false, features = ["derive"] } +serde = { version = "1.0.150", features = ["derive"], default-features = false } +serde-csv-core = { version = "0.3.2", features = ["defmt"] } +smlang = "0.8.0" diff --git a/apps/sergw/Cargo.toml b/apps/sergw/Cargo.toml index 9f15176..72f91bb 100644 --- a/apps/sergw/Cargo.toml +++ b/apps/sergw/Cargo.toml @@ -5,5 +5,5 @@ edition = "2021" [dependencies] clap = { version = "4.5.16", features = ["derive"] } +ctrlc = "3.4" serialport = "4" -ctrlc = "3.4" \ No newline at end of file diff --git a/boards/argus/Cargo.toml b/boards/argus/Cargo.toml index 0e6f6a4..3bca9f9 100644 --- a/boards/argus/Cargo.toml +++ b/boards/argus/Cargo.toml @@ -16,33 +16,30 @@ calibration = [] chrono = { workspace = true } cortex-m = { workspace = true } cortex-m-rt = { workspace = true } -critical-section = "1.1" -csv = { path = "../../common/csv" } +critical-section = { workspace = true } +csv = { workspace = true } defmt = { workspace = true } defmt-rtt = { workspace = true } derive_more = { version = "2.0.1", default-features = false, features = [ "full", ] } -embassy-embedded-hal = { version = "0.3.0" } -embassy-executor = { version = "0.7.0", features = [ +embassy-embedded-hal = { workspace = true } +embassy-executor = { workspace = true, features = [ "nightly", "task-arena-size-10240", "arch-cortex-m", "executor-thread", "executor-interrupt", - "defmt", ] } -embassy-futures = { version = "0.1.0" } -embassy-net = { version = "0.7.0", features = [ - "defmt", +embassy-futures = { workspace = true } +embassy-net = { workspace = true, features = [ "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns", ] } -embassy-stm32 = { version = "0.2.0", features = [ - "defmt", +embassy-stm32 = { workspace = true, features = [ "stm32h733vg", "time-driver-tim2", "exti", @@ -50,13 +47,9 @@ embassy-stm32 = { version = "0.2.0", features = [ "unstable-pac", "chrono", ] } -embassy-sync = { version = "0.6.2", features = ["defmt"] } -embassy-time = { version = "0.4.0", features = [ - "defmt", - "defmt-timestamp-uptime", - "tick-hz-32_768", -] } -embassy-usb = { version = "0.4.0", features = ["defmt"] } +embassy-sync = { workspace = true } +embassy-time = { workspace = true, features = ["tick-hz-32_768"] } +embassy-usb = { workspace = true } embedded-alloc = { workspace = true } embedded-hal = { version = "1.0.0", features = ["defmt-03"] } embedded-hal-async = { version = "1.0" } From 142cd7531b2fc36d27edb923d72e8138aa137ad1 Mon Sep 17 00:00:00 2001 From: mk-rw Date: Sat, 29 Nov 2025 11:32:27 -0500 Subject: [PATCH 2/3] fix: inconsistent quote marks --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index cb3bc52..ba5cdd6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ chrono = { git = "https://github.com/uorocketry/chrono", default-features = fals cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.1" critical-section = "1.1" -csv = { path = './common/csv' } +csv = { path = "./common/csv" } defmt = "0.3.2" defmt-rtt = "0.4" embassy-embedded-hal = { version = "0.3.0", features = ["defmt"] } From dcd9dff6f251bb8166e2ad96a40dcac633a495f8 Mon Sep 17 00:00:00 2001 From: mk-rw Date: Sat, 29 Nov 2025 12:53:01 -0500 Subject: [PATCH 3/3] feat(build): add cargo deny configuration This will allow us to catch a lot of dependency-based issues ahead of time, like vulnerabilities, maintenance, duplication, sources. For example, this will allow us to catch dependencies that should be using the global level dependency, but instead uses its own and (potentially) creates version conflicts and duplication of dependencies. --- deny.toml | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 deny.toml diff --git a/deny.toml b/deny.toml new file mode 100644 index 0000000..06ea9d2 --- /dev/null +++ b/deny.toml @@ -0,0 +1,64 @@ +[output] +# When outputting inclusion graphs in diagnostics that include features, this +# option can be used to specify the depth at which feature edges will be added. +# This option is included since the graphs can be quite large and the addition +# of features from the crate(s) to all of the graph roots can be far too verbose. +# This option can be overridden via `--feature-depth` on the cmd line +feature-depth = 1 + + +[licenses] +allow = [ + #"MIT", + #"Apache-2.0", + #"Apache-2.0 WITH LLVM-exception", +] +confidence-threshold = 0.8 +exceptions = [ + # Each entry is the crate and version constraint, and its specific allow + # list + #{ allow = ["Zlib"], crate = "adler32" }, +] + +[licenses.private] +# If true, ignores workspace crates that aren't published, or are only +# published to private registries. +ignore = true + +[bans] +multiple-versions = "warn" +# Lint level for when a crate version requirement is `*` +wildcards = "deny" +# The graph highlighting used when creating dotgraphs for crates +# with multiple versions +# * lowest-version - The path to the lowest versioned duplicate is highlighted +# * simplest-path - The path to the version with the fewest edges is highlighted +# * all - Both lowest-version and simplest-path are used +highlight = "all" +workspace-default-features = "allow" +external-default-features = "allow" +allow = [ + #"ansi_term@0.11.0", + #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is allowed" }, +] +deny = [ + #"ansi_term@0.11.0", + #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is banned" }, + # Wrapper crates can optionally be specified to allow the crate when it + # is a direct dependency of the otherwise banned crate + #{ crate = "ansi_term@0.11.0", wrappers = ["this-crate-directly-depends-on-ansi_term"] }, +] + +[bans.workspace-dependencies] +duplicates = 'deny' +include-path-dependencies = true +unused = 'deny' + +[sources] +unknown-registry = "warn" +unknown-git = "warn" +allow-registry = ["https://github.com/rust-lang/crates.io-index"] + +# Allow git sources from uorocketry +[sources.allow-org] +github = ["uorocketry"]