diff options
author | Jeffery To <jeffery.to@gmail.com> | 2023-09-23 20:24:37 +0800 |
---|---|---|
committer | Jeffery To <jeffery.to@gmail.com> | 2023-10-11 15:50:24 +0800 |
commit | 0dfc1b508d5e5b361978ef9783cb63775176c305 (patch) | |
tree | 87d123b9d63916b84de9d88e81502e38a6bf4a0b /lang/rust/rust-host-build.mk | |
parent | 9db7284d589dc8490f8c7dbe56af731fce953eda (diff) |
rust: Use make's jobserver when building packages
This allows cargo to use make's jobserver when building packages, by
marking the cargo command as recursive (with the + prefix[1]) and
setting MAKEFLAGS.
This also:
* Give cargo/x.py the build directory instead of having to change the
current directory (and opening subshells)
* Set PKG_BUILD_PARALLEL/HOST_BUILD_PARALLEL for Rust packages to enable
the use of make's jobserver
[1]: https://www.gnu.org/software/make/manual/html_node/POSIX-Jobserver.html
Signed-off-by: Jeffery To <jeffery.to@gmail.com>
Diffstat (limited to 'lang/rust/rust-host-build.mk')
-rw-r--r-- | lang/rust/rust-host-build.mk | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/lang/rust/rust-host-build.mk b/lang/rust/rust-host-build.mk index 38ce963e0..e56292937 100644 --- a/lang/rust/rust-host-build.mk +++ b/lang/rust/rust-host-build.mk @@ -17,29 +17,27 @@ include $(RUST_INCLUDE_DIR)/rust-values.mk CARGO_HOST_VARS= \ $(CARGO_HOST_CONFIG_VARS) \ - CC=$(HOSTCC_NOCACHE) + CC=$(HOSTCC_NOCACHE) \ + MAKEFLAGS="$(HOST_JOBS)" # $(1) path to the package (optional) # $(2) additional arguments to cargo (optional) define Host/Compile/Cargo - ( \ - cd $(HOST_BUILD_DIR) ; \ - $(CARGO_HOST_VARS) \ - cargo install -v \ - --profile $(CARGO_HOST_PROFILE) \ - $(if $(RUST_HOST_FEATURES),--features "$(RUST_HOST_FEATURES)") \ - --root $(HOST_INSTALL_DIR) \ - --path "$(if $(strip $(1)),$(strip $(1)),.)" $(2) ; \ - ) + +$(CARGO_HOST_VARS) \ + cargo install -v \ + --profile $(CARGO_HOST_PROFILE) \ + $(if $(RUST_HOST_FEATURES),--features "$(RUST_HOST_FEATURES)") \ + --root $(HOST_INSTALL_DIR) \ + --path "$(HOST_BUILD_DIR)/$(if $(strip $(1)),$(strip $(1)))" \ + $(if $(filter --jobserver%,$(HOST_JOBS)),,-j1) \ + $(2) endef define Host/Uninstall/Cargo - ( \ - cd $(HOST_BUILD_DIR) ; \ - $(CARGO_HOST_VARS) \ - cargo uninstall -v \ - --root $(HOST_INSTALL_DIR) || true ; \ - ) + +$(CARGO_HOST_VARS) \ + cargo uninstall -v \ + --root $(HOST_INSTALL_DIR) \ + || true endef define RustBinHostBuild |