[vlc-commits] [Git][videolan/vlc][master] 17 commits: contrib: cargo: install the minimum required to build Rust code via rustup
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sun Jul 14 12:12:27 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
f7eccbc7 by Steve Lhomme at 2024-07-14T11:08:10+00:00
contrib: cargo: install the minimum required to build Rust code via rustup
We can always do that in our rustup environment.
- - - - -
612dc3f8 by Steve Lhomme at 2024-07-14T11:08:10+00:00
contrib: cargo: install rustup without a rust version
We set the rust version later anyway, before picking the target we want.
- - - - -
4fbb542f by Steve Lhomme at 2024-07-14T11:08:10+00:00
contrib: rust: build rustup before adding the rust compiler
rustup may be detected from the system.
- - - - -
951c0594 by Steve Lhomme at 2024-07-14T11:08:10+00:00
contrib: rust: don't build rustup if it's found in the system
- - - - -
c6779a6f by Steve Lhomme at 2024-07-14T11:08:10+00:00
contrib: rust: build rustc before building cargo
rustc may be detected from the system.
- - - - -
4288bba9 by Steve Lhomme at 2024-07-14T11:08:10+00:00
contrib: cargo: detect cargo-c presence with cargo-capi
- - - - -
28ca2e14 by Steve Lhomme at 2024-07-14T11:08:10+00:00
contrib: rust: check rustc and cargo are installled
- - - - -
42a7574a by Steve Lhomme at 2024-07-14T13:33:17+02:00
contrib: rust: split cargo-c and rust+cargo
They are not the same thing. cargo-c is a rust crate.
It requires rustc and cargo to be installed. It doesn't need
any package download via the contrib downloads.
rustc and cargo also don't need any download via the contrib downloads if
rustup is already installed. It's the one that will do all the downloads.
- - - - -
5d54cd3b by Steve Lhomme at 2024-07-14T13:33:17+02:00
contrib: rust: split rustc+cargo and rustup
rustup requires a download when rustc+cargo do it via rustup.
We call rustup differently depending on whether it's installed from contribs
or comes from the system.
- - - - -
95f550c9 by Steve Lhomme at 2024-07-14T13:33:17+02:00
contrib: rav1e: depend on the rust compiler to be present
- - - - -
1ea77113 by Steve Lhomme at 2024-07-14T13:33:17+02:00
contrib: rust: disable x86_64 Solaris target
It's a deprecated Tier 3 target.
- - - - -
74d5cca0 by Steve Lhomme at 2024-07-14T13:33:17+02:00
contrib: rust: set the minimum Rust compiler version to support a target
We can build Tier 1 and Tier 2 targets.
The Rust compiler must support the minimum version to enable this target.
- - - - -
14eb1f95 by Steve Lhomme at 2024-07-14T13:33:17+02:00
contrib: add macros to check the minimum version of a system tool
- - - - -
512a9b56 by Steve Lhomme at 2024-07-14T13:33:17+02:00
contrib: rustc: check the native rustc/cargo version matches the minimum required
If it does, we don't need to install it. But it's only useful for native builds.
For native builds we need the cross compiled version of the RUST_TARGET.
- - - - -
e7be7965 by Steve Lhomme at 2024-07-14T13:33:17+02:00
Revert "contrib: rav1e: disable for iOS"
This reverts commit b1be2782db17611995026a517f46ff902d39d8a2.
This should work with more a recent rustc.
- - - - -
4295007b by Steve Lhomme at 2024-07-14T13:33:17+02:00
contrib: rav1e: use vlc_build for the compiled/generated files
Just like any other contrib.
Otherwise it's built in a "target" directory.
- - - - -
e4ea36ba by Steve Lhomme at 2024-07-14T13:33:17+02:00
extras/tools: ignore downloaded+patched config.guess
Needed since ef36847caabf29b1607334c49a514506b510c72d
- - - - -
8 changed files:
- + contrib/src/cargo-c/rules.mak
- contrib/src/main-rust.mak
- contrib/src/main.mak
- contrib/src/rav1e/rules.mak
- + contrib/src/rustc/rules.mak
- contrib/src/cargo/SHA512SUMS → contrib/src/rustup/SHA512SUMS
- contrib/src/cargo/rules.mak → contrib/src/rustup/rules.mak
- extras/tools/.gitignore
Changes:
=====================================
contrib/src/cargo-c/rules.mak
=====================================
@@ -0,0 +1,36 @@
+# cargo-c installation via cargo
+
+CARGOC_VERSION := 0.9.29
+
+ifdef BUILD_RUST
+PKGS_TOOLS += cargo-c
+
+ifneq ($(call system_tool_majmin, cargo-capi --version),)
+PKGS_FOUND += cargo-c
+endif
+
+endif
+
+ifdef HAVE_CROSS_COMPILE
+DEPS_cargo-c = rustc-cross $(DEPS_rustc-cross)
+else
+DEPS_cargo-c = rustc $(DEPS_rustc)
+endif
+
+.sum-cargo-c:
+ touch $@
+
+# Test if we can use the host libssl library
+ifeq ($(shell unset PKG_CONFIG_LIBDIR PKG_CONFIG_PATH; \
+ pkg-config "openssl >= 1.0.1" 2>/dev/null || \
+ pkg-config "libssl >= 2.5" 2>/dev/null || echo FAIL),)
+CARGOC_FEATURES=
+else
+# Otherwise, let cargo build and statically link its own openssl
+CARGOC_FEATURES=--features=cargo/vendored-openssl
+endif
+
+.cargo-c:
+ +unset PKG_CONFIG_LIBDIR PKG_CONFIG_PATH CFLAGS CPPFLAGS LDFLAGS; \
+ $(CARGO) install --locked $(CARGOC_FEATURES) cargo-c --version $(CARGOC_VERSION)
+ touch $@
=====================================
contrib/src/main-rust.mak
=====================================
@@ -3,8 +3,14 @@
#
# This file is under the same license as the vlc package.
+# default in Debian bookworm
+RUST_VERSION_MIN=1.63.0
+
ifdef HAVE_WIN32
ifdef HAVE_UCRT
+# does not work as Tier 2 before that
+RUST_VERSION_MIN=1.79.0
+
ifndef HAVE_WINSTORE # UWP is available as Tier 3
ifeq ($(HOST),i686-w64-mingw32)
RUST_TARGET = i686-pc-windows-gnullvm # ARCH is i386
@@ -34,8 +40,9 @@ endif
endif
else ifdef HAVE_MACOSX
RUST_TARGET = $(ARCH)-apple-darwin
-else ifdef HAVE_SOLARIS
-RUST_TARGET = x86_64-sun-solaris
+# else ifdef HAVE_SOLARIS
+# Solaris x86_64 is Tier 3
+# RUST_TARGET = x86_64-sun-solaris
else ifdef HAVE_LINUX
ifeq ($(HOST),arm-linux-gnueabihf)
RUST_TARGET = arm-unknown-linux-gnueabihf #add eabihf
@@ -78,8 +85,12 @@ endif
CARGO_ENV = TARGET_CC="$(CC)" TARGET_AR="$(AR)" TARGET_RANLIB="$(RANLIB)" \
TARGET_CFLAGS="$(CFLAGS)" RUSTFLAGS="$(RUSTFLAGS)"
+ifneq ($(call system_tool_majmin, cargo --version),)
+CARGO = RUSTUP_HOME=$(RUSTUP_HOME) CARGO_HOME=$(CARGO_HOME) $(CARGO_ENV) cargo
+else
CARGO = . $(CARGO_HOME)/env && \
- RUSTUP_HOME=$(RUSTUP_HOME) CARGO_HOME=$(CARGO_HOME) $(CARGO_ENV) cargo
+ RUSTUP_HOME=$(RUSTUP_HOME) CARGO_HOME=$(CARGO_HOME) $(CARGO_ENV) cargo
+endif
CARGO_INSTALL_ARGS = --target=$(RUST_TARGET) --prefix=$(PREFIX) \
--library-type staticlib --profile=$(CARGO_PROFILE)
=====================================
contrib/src/main.mak
=====================================
@@ -277,6 +277,10 @@ FULL_VERSION_REGEX := 's/[^0-9]*\([0-9]\([0-9a-zA-Z\.\-]*\)\)\(.*\)/\1/p'
system_tool_version = $(shell PATH="${SYSTEM_PATH}" $(1) 2>/dev/null | head -1 | sed -ne ${FULL_VERSION_REGEX} | $(2))
# Get the major.minor version of a system tool
system_tool_majmin = $(call system_tool_version, $(1), cut -d '.' -f -2)
+# Print the smallest version value of the given system tool (no spaces in the checked version)
+system_tool_min_version = $(shell printf "$(2) $(call system_tool_version, $(1), grep . && echo || echo 0.0.0)" | tr " " "\n" | sort -V | head -n1)
+# Check if native tool $1 is at least version $2
+system_tool_matches_min = $(shell test "$(call system_tool_min_version,$(1),$(2))" = "$(2)" || echo FAIL)
ifndef GIT
ifeq ($(shell git --version >/dev/null 2>&1 || echo FAIL),)
=====================================
contrib/src/rav1e/rules.mak
=====================================
@@ -5,13 +5,10 @@ RAV1E_URL := https://crates.io/api/v1/crates/rav1e/$(RAV1E_VERSION)/download
ifdef BUILD_RUST
ifdef BUILD_ENCODERS
-# Rav1e is not linking correctly on iOS arm64
-ifndef HAVE_IOS
PKGS += rav1e
PKGS_ALL += rav1e-vendor
endif
endif
-endif
ifeq ($(call need_pkg,"rav1e"),)
PKGS_FOUND += rav1e
@@ -25,12 +22,18 @@ $(TARBALLS)/rav1e-$(RAV1E_VERSION).tar.gz:
RAV1E_FEATURES=--features=asm
# we may not need cargo if the tarball is downloaded, but it will be needed by rav1e anyway
-DEPS_rav1e-vendor = cargo $(DEPS_cargo)
-DEPS_rav1e = rav1e-vendor $(DEPS_rav1e-vendor) cargo $(DEPS_cargo)
+ifdef HAVE_CROSS_COMPILE
+DEPS_rav1e-vendor = rustc-cross $(DEPS_rustc-cross)
+DEPS_rav1e = rustc-cross $(DEPS_rustc-cross)
+else
+DEPS_rav1e-vendor = rustc $(DEPS_rustc)
+DEPS_rav1e = rustc $(DEPS_rustc)
+endif
+DEPS_rav1e += rav1e-vendor $(DEPS_rav1e-vendor) cargo-c $(DEPS_cargo-c)
# rav1e-vendor
-rav1e-vendor-build: .cargo
+rav1e-vendor-build: .rustc
$(RM) -R $@
mkdir -p $@
tar xzfo $(TARBALLS)/rav1e-$(RAV1E_VERSION).tar.gz -C $@ --strip-components=1
@@ -64,7 +67,7 @@ rav1e: rav1e-$(RAV1E_VERSION).tar.gz .sum-rav1e
$(MOVE)
.rav1e: rav1e
- +cd $< && $(CARGOC_INSTALL) --no-default-features $(RAV1E_FEATURES)
+ +cd $< && $(CARGOC_INSTALL) --target-dir vlc_build --no-default-features $(RAV1E_FEATURES)
# No gcc in Android NDK25
ifdef HAVE_ANDROID
sed -i -e 's/ -lgcc//g' $(PREFIX)/lib/pkgconfig/rav1e.pc
=====================================
contrib/src/rustc/rules.mak
=====================================
@@ -0,0 +1,47 @@
+# rustc+cargo installation via rustup
+
+RUST_VERSION=1.79.0
+
+ifdef BUILD_RUST
+PKGS_TOOLS += rustc
+
+ifdef HAVE_CROSS_COMPILE
+PKGS_TOOLS += rustc-cross
+PKGS_ALL += rustc-cross
+endif
+
+ifneq ($(call system_tool_version, rustup --version, cat),)
+RUSTUP = RUSTUP_HOME=$(RUSTUP_HOME) CARGO_HOME=$(CARGO_HOME) rustup
+else
+RUSTUP = . $(CARGO_HOME)/env && \
+ RUSTUP_HOME=$(RUSTUP_HOME) CARGO_HOME=$(CARGO_HOME) rustup
+endif
+
+ifeq ($(call system_tool_matches_min, cargo --version,$(RUST_VERSION_MIN)),)
+PKGS_FOUND += rustc
+# TODO detect if the target is available
+# PKGS_FOUND += rustc-cross
+else
+DEPS_rustc = rustup $(DEPS_rustup)
+endif
+
+endif
+
+DEPS_rustc-cross = rustc $(DEPS_rustc) rustup $(DEPS_rustup)
+
+.sum-rustc:
+ touch $@
+
+.sum-rustc-cross:
+ touch $@
+
+.rustc:
+ +$(RUSTUP) set profile minimal
+ +$(RUSTUP) default $(RUST_VERSION)
+ touch $@
+
+.rustc-cross:
+ +$(RUSTUP) set profile minimal
+ +$(RUSTUP) default $(RUST_VERSION)
+ +$(RUSTUP) target add --toolchain $(RUST_VERSION) $(RUST_TARGET)
+ touch $@
=====================================
contrib/src/cargo/SHA512SUMS → contrib/src/rustup/SHA512SUMS
=====================================
=====================================
contrib/src/cargo/rules.mak → contrib/src/rustup/rules.mak
=====================================
@@ -1,23 +1,23 @@
-# cargo/cargo-c installation via rustup
+# rustup
-RUST_VERSION=1.79.0
-CARGOC_VERSION=0.9.29
RUSTUP_VERSION := 1.27.1
RUSTUP_URL := $(GITHUB)/rust-lang/rustup/archive/refs/tags/$(RUSTUP_VERSION).tar.gz
ifdef BUILD_RUST
-PKGS_TOOLS += cargo
+PKGS_TOOLS += rustup
+
+ifneq ($(call system_tool_version, rustup --version, cat),)
+PKGS_FOUND += rustup
endif
-RUSTUP = . $(CARGO_HOME)/env && \
- RUSTUP_HOME=$(RUSTUP_HOME) CARGO_HOME=$(CARGO_HOME) rustup
+endif
$(TARBALLS)/rustup-$(RUSTUP_VERSION).tar.gz:
- $(call download_pkg,$(RUSTUP_URL),cargo)
+ $(call download_pkg,$(RUSTUP_URL),rustup)
-.sum-cargo: rustup-$(RUSTUP_VERSION).tar.gz
+.sum-rustup: rustup-$(RUSTUP_VERSION).tar.gz
-cargo: rustup-$(RUSTUP_VERSION).tar.gz .sum-cargo
+rustup: rustup-$(RUSTUP_VERSION).tar.gz .sum-rustup
$(UNPACK)
$(MOVE)
@@ -31,14 +31,8 @@ else
CARGOC_FEATURES=--features=cargo/vendored-openssl
endif
-# When needed (when we have a Rust dependency not using cargo-c), the cargo-c
-# installation should go in a different package
-.cargo: cargo
+.rustup: rustup
cd $< && RUSTUP_INIT_SKIP_PATH_CHECK=yes \
RUSTUP_HOME=$(RUSTUP_HOME) CARGO_HOME=$(CARGO_HOME) \
- ./rustup-init.sh --no-modify-path -y --default-toolchain $(RUST_VERSION) --profile minimal
- +$(RUSTUP) default $(RUST_VERSION)
- +$(RUSTUP) target add $(RUST_TARGET)
- +unset PKG_CONFIG_LIBDIR PKG_CONFIG_PATH CFLAGS CPPFLAGS LDFLAGS; \
- $(CARGO) install --locked $(CARGOC_FEATURES) cargo-c --version $(CARGOC_VERSION)
+ ./rustup-init.sh --no-modify-path -y --default-toolchain none
touch $@
=====================================
extras/tools/.gitignore
=====================================
@@ -6,3 +6,7 @@ build/
*.tar.bz2
*.tar.xz
*.zip
+config.guess
+config.sub
+config.guess-[a-f0-9]*
+config.sub-[a-f0-9]*
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c8ac4ff61d5a6f0d881c95427fb916cd77fe9b94...e4ea36ba6034e79634cf7e32442a8207dcde44df
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c8ac4ff61d5a6f0d881c95427fb916cd77fe9b94...e4ea36ba6034e79634cf7e32442a8207dcde44df
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list