[05/10] rust: Avoid requiring development dependencies

Message ID 20220201135246.4096955-5-michael.tremer@ipfire.org
State Accepted
Commit 1aab9dfb5dab7ee4b6cc7c126d911f0c5c232400
Headers
Series [01/10] make.sh: Set a good default for rustc flags |

Commit Message

Michael Tremer Feb. 1, 2022, 1:52 p.m. UTC
  Cargo will always require all depenendencies, even if the package is not
being built against them. In order to avoid that, we will need the
nightly build of the Rust compiler which supports skipping those
dependencies.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 lfs/Config | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
  

Patch

diff --git a/lfs/Config b/lfs/Config
index a1e77f72c..fb5745df0 100644
--- a/lfs/Config
+++ b/lfs/Config
@@ -184,7 +184,13 @@  export CARGO_CONFIG
 
 CARGO = \
 	CARGOPATH=$(CARGO_PATH) \
-	cargo
+	RUSTC_BOOTSTRAP=1 \
+	cargo \
+	--offline
+
+CARGO_OPTIONS = \
+	$(MAKETUNING) \
+	-Z avoid-dev-deps
 
 define CARGO_PREPARE
 	mkdir -p $(CARGO_PATH) && \
@@ -195,11 +201,11 @@  endef
 CARGO_BUILD = \
 	$(CARGO) \
 	build \
-	$(MAKETUNING) \
-	--release
+	--release \
+	$(CARGO_OPTIONS)
 
 # Checks whether this crate has a right taregt
-CARGO_TARGET_CHECK = cargo metadata --format-version 1 | \
+CARGO_TARGET_CHECK = $(CARGO) metadata --format-version 1 --no-deps | \
 	jq -e ".packages[].targets[].kind | any(. == \"$(1)\")" | grep -q "true"
 
 define CARGO_INSTALL
@@ -214,7 +220,7 @@  define CARGO_INSTALL
 		echo "{\"files\":{},\"package\":\"\"}" > $(CRATE_PATH)/.cargo-checksum.json; \
 	fi && \
 	if $(call CARGO_TARGET_CHECK,bin); then \
-		$(CARGO) install --no-track --path .; \
+		$(CARGO) install $(CARGO_OPTIONS) --no-track --path .; \
 	fi
 endef