1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-28 23:29:45 +01:00

makefiles: Add "cargo-command" target for executing cargo

Examples of executed commands are `cargo check`, `cargo fix` or `cargo
doc`.
This commit is contained in:
chrysn 2024-08-21 21:47:34 +02:00
parent 184ffc89ab
commit d260ec88a6
2 changed files with 10 additions and 0 deletions

View File

@ -68,6 +68,15 @@ $(CARGO_LIB): cargo-preflight $(RIOTBUILD_CONFIG_HEADER_C) $(BUILDDEPS) $(CARGO_
--profile $(CARGO_PROFILE) \
$(CARGO_OPTIONS)
cargo-command: cargo-preflight $(RIOTBUILD_CONFIG_HEADER_C) $(CARGO_COMPILE_COMMANDS) FORCE
@[ x"$(CARGO_COMMAND)" != x"" ] || ($(COLOR_ECHO) "$(COLOR_RED)Error: Running cargo-command requires a CARGO_COMMAND to be set.$(COLOR_RESET) Set CARGO_COMMAND=\"cargo clippy --release --fix\" or any other cargo command to run with the right RIOT environment."; exit 1)
@# mind the "+" to pass down make's jobserver.
$(Q)+ CC= CFLAGS= CPPFLAGS= CXXFLAGS= \
RIOT_COMPILE_COMMANDS_JSON="$(CARGO_COMPILE_COMMANDS)" \
CARGO_BUILD_TARGET="$(RUST_TARGET)" \
PROFILE="$(CARGO_PROFILE)" \
$(CARGO_COMMAND)
$(APPLICATION_RUST_MODULE).module: $(CARGO_LIB) FORCE
$(Q)# Ensure no old object files persist. These would lead to duplicate
$(Q)# symbols, or worse, lingering behaivor of XFA entries.

View File

@ -254,3 +254,4 @@ info-rust:
@echo "and export these environment variables:"
@echo " RIOT_COMPILE_COMMANDS_JSON=\"$(CARGO_COMPILE_COMMANDS)\""
@echo " RIOTBUILD_CONFIG_HEADER_C=\"$(RIOTBUILD_CONFIG_HEADER_C)\""
@echo "You can also call cargo related commands with \`make cargo-command CARGO_COMMAND="cargo check"\`; beware that the way the profile is passed in is not consistent across cargo commands, and adding \`--profile $(CARGO_PROFILE)\` as part of CARGO_COMMAND may be necessary."