[vlc-commits] [Git][videolan/vlc][master] 8 commits: rust: use CARGO found by the configure script
Steve Lhomme (@robUx4)
gitlab at videolan.org
Wed Jul 24 10:43:51 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
22e0f09e by Steve Lhomme at 2024-07-24T10:13:39+00:00
rust: use CARGO found by the configure script
And let cargo do the cd command.
- - - - -
7a6505f4 by Steve Lhomme at 2024-07-24T10:13:39+00:00
configure: pick the Rust target to use based on the host detection
- - - - -
bcbaddfb by Steve Lhomme at 2024-07-24T10:13:39+00:00
rust: use RUST_TARGET when calling cargo
- - - - -
8f98b6b4 by Steve Lhomme at 2024-07-24T10:13:39+00:00
configure: detect cargo/rustc from CARGO_HOME
- - - - -
b7e7305e by Steve Lhomme at 2024-07-24T10:13:39+00:00
configure: use CARGO_HOME from contribs if it's not set
Only for cross-compilation. We still want to allow the system compiler
for native compilation.
- - - - -
004e1980 by Steve Lhomme at 2024-07-24T10:13:39+00:00
configure: detect RUSTUP_HOME when cross compiling Rust
RUSTUP_HOME contains the target toolchain when it's not the native one.
- - - - -
1a50809c by Steve Lhomme at 2024-07-24T10:13:39+00:00
configure: detect rustc can compile for our target
It doesn't matter if it's a cross-compilation or not, we have the proper
folders to use if it is.
- - - - -
bfe0a6e7 by Steve Lhomme at 2024-07-24T10:13:39+00:00
rust: use the RUST_ENV to call cargo for building
- - - - -
2 changed files:
- configure.ac
- src/rust/Makefile.am
Changes:
=====================================
configure.ac
=====================================
@@ -1890,23 +1890,105 @@ AC_ARG_ENABLE([rust],
AS_HELP_STRING([--enable-rust],
[enable building Rust modules (default disabled)]))
AS_IF([test "${enable_rust}" = "yes"],[
+
+ rust_target_flags=
+ AS_IF([test "$vlc_winstore_app" = "1"],[
+ rust_target_flags="${rust_target_flags} --uwp"
+ ])
+ AS_IF([test "${win_ucrt_build}" = "yes"],[
+ rust_target_flags="${rust_target_flags} --ucrt"
+ ])
+ AS_IF([test "${HAVE_TVOS}" = "1"],[
+ rust_target_flags="${rust_target_flags} --darwin=tvos"
+ ],[
+ AS_IF([test "${HAVE_WATCHOS}" = "1"],[
+ rust_target_flags="${rust_target_flags} --darwin=watchos"
+ ],[
+ AS_IF([test "${HAVE_XROS}" = "1"],[
+ rust_target_flags="${rust_target_flags} --darwin=xros"
+ ],[
+ AS_IF([test "${HAVE_IOS}" = "1"],[
+ rust_target_flags="${rust_target_flags} --darwin=ios"
+ ],[
+ AS_IF([test "${HAVE_OSX}" = "1"],[
+ rust_target_flags="${rust_target_flags} --darwin=macos"
+ ])
+ ])
+ ])
+ ])
+ ])
+
+ AC_MSG_CHECKING([Rust target])
+ rust_target=$(${srcdir}/contrib/src/get-rust-target.sh \
+ ${rust_target_flags} \
+ ${host})
+ ac_status=$?
+ AS_IF([test $ac_status = 0],[
+ AC_MSG_RESULT([${rust_target}])
+ AC_SUBST([RUST_TARGET], ["${rust_target}"])
+ ],[
+ AC_MSG_RESULT([unsupported])
+ AC_MSG_ERROR([Unsupported Rust target for ${host}])
+ ])
+
+ AS_IF([test -z "${CARGO_HOME}" -a "${host}" != "${build}"],[
+ AC_MSG_CHECKING([CARGO_HOME from contribs])
+ AS_IF([test -d "${CONTRIB_DIR}/../bin/.cargo"],[
+ CARGO_HOME=$(cd "${CONTRIB_DIR}/../bin/.cargo" && pwd -P)
+ AC_MSG_RESULT([${CARGO_HOME}])
+ ],[
+ AC_MSG_RESULT([not found])
+ ])
+ ])
+
+ RUST_ENV=
+ AS_IF([test -n "${CARGO_HOME}"],[
+ RUST_ENV="${RUST_ENV} CARGO_HOME=\"${CARGO_HOME}\""
+ AS_IF([test -x "${CARGO_HOME}/bin/cargo"],[
+ ac_cv_prog_CARGO="${CARGO_HOME}/bin/cargo"
+ ])
+ AS_IF([test -x "${CARGO_HOME}/bin/rustc"],[
+ ac_cv_prog_RUSTC="${CARGO_HOME}/bin/rustc"
+ ])
+ ])
+
+ AS_IF([test "${host}" != "${build}"],[
+ dnl RUSTUP_HOME is needed to cross-compile Rust
+ AS_IF([test -z "${RUSTUP_HOME}"],[
+ AC_MSG_CHECKING([RUSTUP_HOME from contribs])
+ AS_IF([test -d "${CONTRIB_DIR}/../bin/.rustup"],[
+ RUSTUP_HOME=$(cd "${CONTRIB_DIR}/../bin/.rustup" && pwd -P)
+ AC_MSG_RESULT([${RUSTUP_HOME}])
+ ],[
+ AC_MSG_RESULT([not found])
+ ])
+ ])
+ ])
+
+ AS_IF([test -n "${RUSTUP_HOME}"],[
+ RUST_ENV="${RUST_ENV} RUSTUP_HOME=\"${RUSTUP_HOME}\""
+ ])
+
AC_CHECK_PROGS(RUSTC, [rustc], [no])
AS_IF([test "$RUSTC" = "no"],[
AC_MSG_ERROR([rustc not found but required to build Rust modules])
])
- AS_IF([test "${host}" = "${build}"],[
- AC_CACHE_CHECK([rustc host target], [ac_cv_rustc_host_target],
- [ac_cv_rustc_host_target=$($RUSTC --verbose --version | grep "host:" | cut -d" " -f2-)])
- AS_IF([test -n "${ac_cv_rustc_host_target}"],
- [AC_SUBST([RUST_TARGET], ["$ac_cv_rustc_host_target"])],
- [AC_MSG_ERROR(failed to extract rustc host target)])
+
+ AC_MSG_CHECKING([Rust compiler supports ${rust_target}])
+ ac_try="echo 'fn main() {}' | ${RUST_ENV} \"${RUSTC}\" --target=${rust_target} --emit=dep-info - -o -"
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ AS_IF([test $ac_status = 0],[
+ AC_MSG_RESULT([yes])
],[
- AC_MSG_ERROR([cross compilation is not yet supported for Rust modules (${host} != ${build})])
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([Required target ${rust_target} missing (using ${RUST_ENV})])
])
AC_CHECK_PROGS(CARGO, [cargo], [no])
AS_IF([test "$CARGO" = "no"],[
AC_MSG_ERROR([cargo not found. cargo is required to build Rust modules])
])
+ AC_SUBST([RUST_ENV])
AC_DEFINE(ENABLE_RUST, 1, [Define to 1 for building rust modules.])
])
AM_CONDITIONAL([HAVE_RUST], [test "${enable_rust}" = "yes"])
=====================================
src/rust/Makefile.am
=====================================
@@ -7,9 +7,8 @@ vlcrs-macros.cargo:
vlcrs-messages.cargo:
vlcrs-plugin.cargo:
vlcrs-utils.cargo:
- cd $(top_srcdir)/src/rust/$(@:.cargo=) && env \
- top_builddir="${abs_top_builddir}" \
- cargo build
+ env top_builddir="${abs_top_builddir}" \
+ $(RUST_ENV) $(CARGO) -C $(top_srcdir)/src/rust/$(@:.cargo=) --target=$(RUST_TARGET) build
if HAVE_RUST
TESTS += \
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3ef0bda7b41a14c837ad94beb84d7e25462c2684...bfe0a6e77f8849ed84e98d9ecaa950bacdedb10e
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3ef0bda7b41a14c837ad94beb84d7e25462c2684...bfe0a6e77f8849ed84e98d9ecaa950bacdedb10e
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