[vlc-devel] [PATCH] [RFC]: rav1e/rust: handle rustup/cargo from contribs (to fixup)

Thomas Guillem thomas at gllm.fr
Fri Aug 21 14:16:46 CEST 2020


Instead of installing rustup from extra/tools and installing cargo with all
common targets. Install only rustup and cargo with the correct target when
needed by a contrib package.

The rustup/cargo installation is in contrib/bin/.cargo. When a package requires
cargo from a contrib (like ".rav1e: rav1e .cargo-c"), rustup will be installed
if needed, and the correct target will be installed from cargo..

For now, every archs use a common rustup/cargo installation but this can be
easily changed (use contrib/bin/.$(ARCH)-cargo instead of contrib/bin/.cargo).

This is a RFC. If this patch is accepted, the "Add rustup to extras/tools"
commit be replaced by this one.
---
 contrib/src/main.mak          |  6 ++++--
 contrib/src/rav1e/rules.mak   |  5 ++---
 contrib/src/rustup/SHA512SUMS |  1 +
 contrib/src/rustup/rules.mak  | 27 +++++++++++++++++++++++++++
 extras/tools/SHA512SUMS       |  1 -
 extras/tools/bootstrap        |  1 -
 extras/tools/packages.mak     |  3 ---
 extras/tools/tools.mak        | 24 ------------------------
 8 files changed, 34 insertions(+), 34 deletions(-)
 create mode 100644 contrib/src/rustup/SHA512SUMS
 create mode 100644 contrib/src/rustup/rules.mak

diff --git a/contrib/src/main.mak b/contrib/src/main.mak
index 8deff6c6b57..49458be848b 100644
--- a/contrib/src/main.mak
+++ b/contrib/src/main.mak
@@ -453,8 +453,10 @@ else ifdef HAVE_LINUX
 RUST_TARGET = $(ARCH)-unknown-linux-gnu
 endif
 
-CARGO = cargo cinstall --target=$(RUST_TARGET) --prefix=$(PREFIX) \
-    --library-type staticlib --release
+CARGO_HOME = $(BUILDBINDIR)/.cargo
+CARGO = $(CARGO_HOME)/bin/cargo
+CARGOC_INSTALL = $(CARGO) cinstall \
+	--target=$(RUST_TARGET) --prefix=$(PREFIX) --library-type staticlib --release
 
 ifdef GPL
 REQUIRE_GPL =
diff --git a/contrib/src/rav1e/rules.mak b/contrib/src/rav1e/rules.mak
index b20ca17284c..a5d18c67976 100644
--- a/contrib/src/rav1e/rules.mak
+++ b/contrib/src/rav1e/rules.mak
@@ -20,8 +20,7 @@ rav1e: rav1e-$(RAV1E_VERSION).tar.gz .sum-rav1e
 	$(UNPACK)
 	$(MOVE)
 
-.rav1e: rav1e
-	cd $< && RUSTFLAGS="-C lto -C panic=abort -C opt-level=z" $(CARGO) \
+.rav1e: rav1e .cargo-c
+	cd $< && RUSTFLAGS="-C lto -C panic=abort -C opt-level=z" $(CARGOC_INSTALL) \
 	--no-default-features --features asm
 	touch $@
-
diff --git a/contrib/src/rustup/SHA512SUMS b/contrib/src/rustup/SHA512SUMS
new file mode 100644
index 00000000000..6101c68ba6c
--- /dev/null
+++ b/contrib/src/rustup/SHA512SUMS
@@ -0,0 +1 @@
+14a978a3cf699956722d8443070b9f8a043f1252cc1a7ed300b14637a0e6d654f34088d4403790c676500cbab327e30fdb7f81be0b9bde29e552143f26912ac7  rustup-1.22.1.tar.gz
diff --git a/contrib/src/rustup/rules.mak b/contrib/src/rustup/rules.mak
new file mode 100644
index 00000000000..b1d86c67cb2
--- /dev/null
+++ b/contrib/src/rustup/rules.mak
@@ -0,0 +1,27 @@
+# cargo/cargo-c installation via rustup
+
+RUSTUP_VERSION=1.22.1
+RUSTUP_URL=https://github.com/rust-lang/rustup/archive/$(RUSTUP_VERSION).tar.gz
+
+$(TARBALLS)/rustup-$(RUSTUP_VERSION).tar.gz:
+	$(call download_pkg,$(RUSTUP_URL),rustup)
+
+.sum-rustup: rustup-$(RUSTUP_VERSION).tar.gz
+
+rustup: rustup-$(RUSTUP_VERSION).tar.gz .sum-rustup
+	$(UNPACK)
+	$(MOVE)
+
+$(CARGO_HOME)/bin/rustup: rustup
+	cd $< && RUSTUP_INIT_SKIP_PATH_CHECK=yes \
+	  RUSTUP_HOME=$(CARGO_HOME) CARGO_HOME=$(CARGO_HOME) \
+	  ./rustup-init.sh --no-modify-path -y
+
+.cargo: $(CARGO_HOME)/bin/rustup
+	$(CARGO_HOME)/bin/rustup default stable
+	$(CARGO_HOME)/bin/rustup target add $(RUST_TARGET)
+	touch $@
+
+.cargo-c: .cargo
+	$(CARGO) install cargo-c
+	touch $@
diff --git a/extras/tools/SHA512SUMS b/extras/tools/SHA512SUMS
index 09456a7bf72..e3e02d8d3d0 100644
--- a/extras/tools/SHA512SUMS
+++ b/extras/tools/SHA512SUMS
@@ -20,4 +20,3 @@ d24849b93de58b20f518c071687e7bfa653a96600382f36c4cf7fc1047656458f75f093b911b786b
 8d23dde18525dccaa648ca01df40151e7f00cec4846bd611c8970dbcfc1fb57a453facfe4d41462e7c3c8bb548d44b961a04e4fc3073ab6b65063e53f42bf6fd  nasm-2.14.tar.gz
 1650bf9e3eddeb0b0fbb415c2b8e0a7c094421e991fa8139fd77fae0f6ee7ee980b7cf5e98d883c3a884f99abcb06fa26e3980af3a3a5bb6dd655124755782c2  ninja-1.8.2.tar.gz
 ad5ec826879d3d85088ca40d768599a4c8e66983f2a6a7ebe8ab12051cad18b4ade9a2afd30fe543b0a75900822992c8ef7161d369489e2211dd7a1a8ccc32ed  meson-0.54.2.tar.gz
-14a978a3cf699956722d8443070b9f8a043f1252cc1a7ed300b14637a0e6d654f34088d4403790c676500cbab327e30fdb7f81be0b9bde29e552143f26912ac7  rustup-1.22.1.tar.gz
diff --git a/extras/tools/bootstrap b/extras/tools/bootstrap
index 9cd3425bbe2..8e3e0351239 100755
--- a/extras/tools/bootstrap
+++ b/extras/tools/bootstrap
@@ -148,7 +148,6 @@ check gettext
 check help2man
 check meson 0.54.2
 check ninja
-check rustup
 
 DEPS_ONLY="help2man"
 
diff --git a/extras/tools/packages.mak b/extras/tools/packages.mak
index 2206b3930d8..daad1ad2b2e 100644
--- a/extras/tools/packages.mak
+++ b/extras/tools/packages.mak
@@ -65,6 +65,3 @@ MESON_URL=https://github.com/mesonbuild/meson/releases/download/$(MESON_VERSION)
 
 NINJA_VERSION=1.8.2
 NINJA_URL=https://github.com/ninja-build/ninja/archive/v$(NINJA_VERSION).tar.gz
-
-RUSTUP_VERSION=1.22.1
-RUSTUP_URL=https://github.com/rust-lang/rustup/archive/$(RUSTUP_VERSION).tar.gz
\ No newline at end of file
diff --git a/extras/tools/tools.mak b/extras/tools/tools.mak
index 31f40ceeaa2..c74e86bcf51 100644
--- a/extras/tools/tools.mak
+++ b/extras/tools/tools.mak
@@ -439,30 +439,6 @@ CLEAN_PKG += ninja
 DISTCLEAN_PKG += ninja-$(NINJA_VERSION).tar.gz
 CLEAN_FILE += .buildninja
 
-#
-# rustup installation
-#
-
-rustup-$(RUSTUP_VERSION).tar.gz:
-	$(call download_pkg,$(RUSTUP_URL),rustup)
-
-rustup: rustup-$(RUSTUP_VERSION).tar.gz
-	$(UNPACK)
-	$(MOVE)
-
-.buildrustup: rustup
-	cd $< && RUSTUP_HOME=$(PREFIX) CARGO_HOME=$(PREFIX) ./rustup-init.sh --no-modify-path -y
-	rustup default stable
-	rustup target add x86_64-pc-windows-gnu i686-pc-windows-gnu aarch64-linux-android\
-		arm-linux-androideabi i686-linux-android x86_64-linux-android aarch64-apple-ios\
-		x86_64-apple-ios x86_64-unknown-linux-gnu i686-unknown-linux-gnu
-	cargo install cargo-c
-	touch $@
-
-CLEAN_PKG += rustup
-DISTCLEAN_PKG += rustup-$(RUSTUP_VERSION).tar.gz
-CLEAN_FILE += .buildrustup
-
 #
 #
 #
-- 
2.28.0



More information about the vlc-devel mailing list