Skip to content

Commit da280a6

Browse files
committed
cmake: Consistent expansion of include path
Accept both space and semicolon separated paths and defines from cmake. The add_custom_command really wants to replace the semicolons with spaces, whereas the 'file' command doesn't. To make this work, have the build.rs split on either space or semicolon. This fixes a problem where `cargo check` and `rust-analyzer` fail to run correctly when the Zephyr build is configured for release, and they are trying to do a debug build. With this fix, the debug build from cargo will work, allowing the analysis or verification. Signed-off-by: David Brown <[email protected]>
1 parent cf3dc6c commit da280a6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ endfunction()
5757
function(get_include_dirs target dirs)
5858
get_target_property(include_dirs ${target} INTERFACE_INCLUDE_DIRECTORIES)
5959
if(include_dirs)
60-
set(${dirs} ${include_dirs} PARENT_SCOPE)
60+
set(${dirs} "${include_dirs}" PARENT_SCOPE)
6161
else()
6262
set(${dirs} "" PARENT_SCOPE)
6363
endif()

zephyr-sys/build.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ fn main() -> Result<()> {
108108
fn define_args(bindings: Builder, prefix: &str, var_name: &str) -> Builder {
109109
let text = env::var(var_name).unwrap();
110110
let mut bindings = bindings;
111-
for entry in text.split(" ") {
111+
// Split on either spaces or semicolons, to allow some flexibility in what cmake might generate
112+
// for us.
113+
for entry in text.split(&[' ', ';']) {
112114
if entry.is_empty() {
113115
continue;
114116
}

0 commit comments

Comments
 (0)