Skip to content

Commit e4527ff

Browse files
committed
kbuild: rust-analyzer: support key-value cfgs
There are two kinds of configuration options (`cfg`s): names and key-value pairs. So far, we only needed to support the former for the `rust-analyzer` target. Since we are introducing `syn` (and its dependencies) in later patches, which require passing `feature` `cfg`s, support key-value `cfg`s too in the `rust-analyzer` target. Signed-off-by: Miguel Ojeda <[email protected]>
1 parent a5f77c5 commit e4527ff

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

rust/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L
413413

414414
rust-analyzer:
415415
$(Q)$(srctree)/scripts/generate_rust_analyzer.py \
416-
--cfgs='core=$(core-cfgs)' --cfgs='alloc=$(alloc-cfgs)' \
416+
--cfgs='core=$(call escsq,$(core-cfgs))' \
417+
--cfgs='alloc=$(call escsq,$(alloc-cfgs))' \
417418
$(realpath $(srctree)) $(realpath $(objtree)) \
418419
$(RUST_LIB_SRC) $(KBUILD_EXTMOD) > \
419420
$(if $(KBUILD_EXTMOD),$(extmod_prefix),$(objtree))/rust-project.json

scripts/generate_rust_analyzer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
import logging
99
import os
1010
import pathlib
11+
import shlex
1112
import sys
1213

1314
def args_crates_cfgs(cfgs):
1415
crates_cfgs = {}
1516
for cfg in cfgs:
1617
crate, vals = cfg.split("=", 1)
17-
crates_cfgs[crate] = vals.replace("--cfg", "").split()
18+
crates_cfgs[crate] = shlex.split(vals.replace("--cfg", ""))
1819

1920
return crates_cfgs
2021

0 commit comments

Comments
 (0)