Skip to contentSkip to conversation

rust: Fix `make rustfmt` failure

PATCH New Zhao Liu 1 participant 1 message Nov 24

Subsystems (2)
lore
Share & tools
lore

Zhao Liu

author
#0 lore raw

PATCH 1/1 rust: Fix `make rustfmt` failure

At present, make rustfmt triggers the following error:

[0/1] Running external command rustfmt (wrapped by meson to set env) Failed to find targets
This utility formats all bin and lib files of the current crate using rustfmt.
...
FAILED: meson-internal__rustfmt

Since commit 6d28fc60891f moved Cargo.toml to the top-level source directory, rust/ is neither the workspace root nor a package directory. Now "cargo fmt" only formats the package in the current directory, so running it from rust/ (i.e. @CURRENT_SOURCE_DIR@) finds no targets.

So fix this by specifying the project source root (where Cargo.toml is), just like CI did in commit 6d28fc60891f.

Fixes 6d28fc60891f ("rust: switch to cargo subprojects")
---
 rust/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
rust/meson.build +1 -1
index c0c4e52c1b0c..08edbd50ad11 100644
@@ -30,7 +30,7 @@ cargo = find_program('cargo', required: false)
 if cargo.found()
   run_target('rustfmt',
     command: [config_host['MESON'], 'devenv',
-              '--workdir', '@CURRENT_SOURCE_DIR@',
+              '--workdir', meson.project_source_root(),
               cargo, 'fmt'],
     depends: genrs)
 endif
Signature · 1 line
2.34.1