I'm working on an embedded application where I'm following the project layout described by ferrous systems.
In short:
- I have a workspace with multiple projects that are libs, containing most of my application code. These libs contain unittests and can be built with the normal host compiler.
- In a subfolder I have another workspace which mainly contains binaries (that depend on the libs). These binaries are cross-compiled to the target only.
+-- root
+-- lib1
+-- src
+-- tests
+-- ...
+-- Cargo.toml <- normal lib, contained in workspace
+-- lib2
+-- src
+-- tests
+-- ...
+-- Cargo.toml <- normal lib, contained in workspace
+-- cross-bin
+-- .cargo/config.toml <- cross compiler setup
+-- src
+-- ..
+-- Cargo.toml <- cross build, depends on lib1 & lib2, not in workspace
+-- Cargo.toml <- workspace config for lib1 & lib2
The cross-bin
can't be part of the workspace since it's .cargo/config.toml
would be ignored in that case.
To get rust analyzer to still provide info for the embedded build I set the two as linked projects (in VSCode):
"rust-analyzer.linkedProjects": [
"Cargo.toml",
"cross-bin/Cargo.toml",
],
This creates one problem: By default VSCode will run clippy
on all targets - which lets clippy (and therefore rust-analyzer) output an error for the cross-compiled binary:
error[E0463]: can't find crate for `test`
The linked article therefore recommends to disable --all-targets
in the config.
But this creates the "issue" that e.g. clippy is not run on the test cases.
Is there a way to have different configs for the two workspaces, given the project structure that we want to make testing easier?