Skip to content

cmake: Add ZEPHYR_BASE environnement variable to sample-cargo-config.toml #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DenisD3D
Copy link

In order to use a Jetbrains IDE, I've followed the step bellows :

  • Open Clion and configure Zephyr integration like for a c project
  • Add Zephyr rust lang support and compile the project at least once
  • Install rust extension
  • Rust extension sync fails due to missing zephyr crate
  • Symlink sample-cargo-config.toml to .cargo config : ln -s ../build/rust/sample-cargo-config.toml .cargo/config.toml
  • Sync fails due to missing ZEPHYR_BASE environnement variable (https://github.com/zephyrproject-rtos/zephyr-lang-rust/blob/main/zephyr-sys/build.rs#L30)
error: failed to run custom build command for `zephyr-sys v0.1.0 (/home/denisd3d/zephyrproject/modules/lang/rust/zephyr-sys)`
Caused by:
  process didn't exit successfully: `/home/denisd3d/zephyrproject/mfrc522test/build/rust/target/debug/build/zephyr-sys-9bae334ee684fef7/build-script-build` (exit status: 1)
  --- stdout
  Clang version: ClangVersion { parsed: Some((20, 1)), full: "clang version 20.1.6 (Fedora 20.1.6-1.fc42)" }
  --- stderr
  Error: environment variable not found
  Stack backtrace:
     0: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
               at /home/denisd3d/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/anyhow-1.0.98/src/backtrace.rs:27:14
     1: <core::result::Result<T,F> as core::ops::try_trait::FromResidual<core::result::Result<core::convert::Infallible,E>>>::from_residual
               at /home/denisd3d/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:2050:27
     2: build_script_build::main
               at ./build.rs:30:23

This PR add ZEPHYR_BASE environment variable to the generated sample-cargo-config.toml.
With it, Jetbrains rust extension successfully sync and provide basic completions.

Copy link
Collaborator

@d3zd3z d3zd3z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great idea. I've only tested it with editors and tools that run from the command line instead of are run independently.

@d3zd3z d3zd3z force-pushed the add-zephyr-base-to-cargo-config branch from 792c8a0 to c126b2e Compare July 9, 2025 15:28
@d3zd3z
Copy link
Collaborator

d3zd3z commented Jul 9, 2025

I rebased this to grab a merged commit that fixes the CI failure on doc pushing.

@d3zd3z
Copy link
Collaborator

d3zd3z commented Jul 9, 2025

And apparently, github's "maintainers can push changes" is completely useless, because it doesn't run CI. @DenisD3D do you have a chance to rebase this and push? Otherwise, I can do this to a new PR and we can merge that one.

It works fine, there is just a bit of a delay between the push, and when the UI offers to run CI.

@d3zd3z d3zd3z force-pushed the add-zephyr-base-to-cargo-config branch from c126b2e to f0710fa Compare July 9, 2025 15:36
…toml

Improve Jetbrains IDE rust integration support

Signed-off-by: Denis Daviaud <[email protected]>
Signed-off-by: David Brown <[email protected]>
@d3zd3z d3zd3z force-pushed the add-zephyr-base-to-cargo-config branch from f0710fa to 2930b91 Compare July 9, 2025 15:41
@DenisD3D
Copy link
Author

DenisD3D commented Jul 9, 2025

Thanks,
I don't think I have the permission to merge though as I'm not a maintainer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants