feat: generate rust-project.json for LSP

Add a CMake module that writes rust-project.json on every configure so
rust-analyzer can resolve the no-Cargo crate layout, sysroot crates,
and proc-macro attributes without Cargo.

Co-Authored-By: qwen (lmstudio/qwen3.8-27b@q3_k_xl): LSP setup
This commit is contained in:
2026-09-05 05:29:23 +02:00
parent c3a7680e36
commit d5728334d6
5 changed files with 82 additions and 0 deletions
+14
View File
@@ -19,6 +19,7 @@ The project contains:
entry helpers
- `macros/src/lib.rs`: host-side `#[rslibc_macros::main]` attribute macro
- `runtime/main.rs`: minimal example entry point
- `cmake/RustLSP.cmake`: generates `rust-project.json` for rust-analyzer
- `CMakeLists.txt`: direct `rustc` library, macro, and executable commands
## No-Std Design
@@ -112,6 +113,19 @@ Run it on Windows:
- `RelWithDebInfo`: `-C opt-level=3 -C debuginfo=2`
- Other or unset configurations: `-C opt-level=0 -C debuginfo=2`
## LSP
rust-analyzer works without Cargo through a generated manifest:
- `cmake/RustLSP.cmake` runs on every configure and writes
`rust-project.json` (git-ignored) describing the three crates and the
toolchain sysroot, so `core`, `alloc`, and proc-macro attributes resolve.
- Requires the rustup components:
`rustup component add rust-analyzer rust-src`.
- Open the repository root in the editor so rust-analyzer picks up
`rust-project.json`. Re-run CMake configure after changing the crate
layout or switching toolchains.
## Verification
After changing the source or build configuration, run a clean release build