[vlc-commits] [Git][videolan/vlc][master] 6 commits: extras: macosx: return error when xcrun fails

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Wed Sep 4 16:47:12 UTC 2024



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
48ce6937 by Alexandre Janniaux at 2024-09-04T16:06:27+00:00
extras: macosx: return error when xcrun fails

The `export a="$(cmd)` syntax will mask the return value of $(cmd),
which will not interrupt the script in case the xcrun command fails.

- - - - -
038c578f by Alexandre Janniaux at 2024-09-04T16:06:27+00:00
extras: xcode.sh: forward $HOME to build script

$HOME will be required to find default location like the default
$CARGO_HOME at $HOME/.cargo, but the script was ignoring the whole
environment and removing it.

- - - - -
96867630 by Alexandre Janniaux at 2024-09-04T16:06:27+00:00
configure.ac: remove check on rustc

Rustc and its behaviour is checked, but the buildsystem is not actually
using rustc, and instead let cargo use the correct variant of rustc for
the project.

- - - - -
aaa0b0f7 by Alexandre Janniaux at 2024-09-04T16:06:27+00:00
configure.ac: use CARGO_HOME with its default

CARGO_HOME defaults to $HOME/.cargo/, so the proper approach is to
define it when undefined, instead of only checking it when defined.

Note that it should be in %USERPROFILE%\.cargo\bin on Windows, which is
not handled by this patch.

- - - - -
12c9c09a by Alexandre Janniaux at 2024-09-04T16:06:27+00:00
configure.ac: add --with-rust-std parameter

The parameter is forwarded to Cargo to handle re-compiling the standard
library. This is required when targetting tier 3 targets like
aarch64-apple-tvos, where the standard library is not shipped with the
compiler binaries.

Initial design used --with-cargo-build-std which only triggered rebuild
of the std in cargo, but this new design for the option allows more
specification about what needs to be built, can be extended to support
--extern crate later when the std makes it easy to do so, and I felt it
was clearer to read the option, though finding it is a bit less easy.

Example:

    --with-rust-std=build-std=std,panic_abort

- - - - -
a1dead92 by Alexandre Janniaux at 2024-09-04T16:06:27+00:00
contrib: get-rust-target: add support for tvOS

The compiler supports the triplet by default.

- - - - -


5 changed files:

- configure.ac
- contrib/src/get-rust-target.sh
- extras/package/apple/xcode.sh
- extras/package/macosx/env.build.sh
- modules/Makefile.am


Changes:

=====================================
configure.ac
=====================================
@@ -1886,6 +1886,16 @@ AM_CONDITIONAL([ENABLE_SOUT], [test "${enable_sout}" != "no"])
 dnl
 dnl Rust Modules
 dnl
+AC_ARG_WITH([rust-std],
+    AS_HELP_STRING([--with-rust-std[=ARGS]],
+                   [Specify how to find Rust standard library. If ARGS is build-std=STDARGS, it forwards parameters to Cargo as -Z build-std=STDARGS. (default auto)]))
+AS_CASE(["${with_rust_std}"],
+        [build-std=*],  [cargo_build_std_args=-Z"${with_rust_std}"],
+        [auto],         [cargo_build_std_args=""],
+        [""],           [cargo_build_std_args=""],
+        [AC_MSG_ERROR([Unknown option ${with_rust_std} for --with-rust-std=])])
+AC_SUBST([CARGO_BUILD_STD], [${cargo_build_std_args}])
+
 AC_ARG_ENABLE([rust],
   AS_HELP_STRING([--enable-rust],
     [enable building Rust modules (default disabled)]))
@@ -1931,34 +1941,17 @@ AS_IF([test "${enable_rust}" = "yes"],[
     AC_MSG_ERROR([Unsupported Rust target for ${host}])
   ])
 
-  AS_IF([test -n "${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"
-    ])
-  ])
-
-  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 -z "${CARGO_HOME}"], [
+    dnl CARGO_HOME default to the home folder
+    dnl https://doc.rust-lang.org/cargo/guide/cargo-home.html
+    CARGO_HOME="${HOME}/.cargo"
   ])
 
-  AC_MSG_CHECKING([Rust compiler supports ${rust_target}])
-  ac_try="echo 'fn main() {}' | \"${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_RESULT([no])
-    AC_MSG_ERROR([Required target ${rust_target} missing])
-  ])
-  AC_CHECK_PROGS(CARGO, [cargo], [no])
+  AC_PATH_PROGS(CARGO, [cargo], [no], [${CARGO_HOME}/bin:${PATH}])
   AS_IF([test "$CARGO" = "no"],[
     AC_MSG_ERROR([cargo not found. cargo is required to build Rust modules])
   ])
+
   AC_DEFINE(ENABLE_RUST, 1, [Define to 1 for building rust modules.])
 ])
 AM_CONDITIONAL([HAVE_RUST], [test "${enable_rust}" = "yes"])


=====================================
contrib/src/get-rust-target.sh
=====================================
@@ -4,8 +4,9 @@
 #
 # Authors: Denis Charmet <typx at dinauz.org>
 #          Steve Lhomme <robux4 at videolabs.io>
+#          Alexandre Janniaux <ajanni at videolabs.io>
 #
-# Transform a compilation triplet into a Rust Tier 1 and Tier 2 target
+# Transform a compilation triplet from autoconf to cargo/llvm dialect
 # based on https://doc.rust-lang.org/rustc/platform-support.html
 
 DARWIN=
@@ -164,6 +165,15 @@ case $OS in
           esac
         fi
         ;;
+      tvos)
+        if test -z "$SIMULATOR"; then
+          case $ARCH in
+            aarch64|arm64)
+              return_triplet aarch64-apple-tvos
+              ;;
+           esac
+        fi
+        ;;
 
     esac
     abort_err "Unsupported Darwin triplet '$TRIPLET' for '$DARWIN'"


=====================================
extras/package/apple/xcode.sh
=====================================
@@ -17,9 +17,9 @@ for arch in $ARCHS; do
     BUILD_DIR="${BUILT_PRODUCTS_DIR}/build-${PLATFORM_NAME}-${arch}/"
     if [ ! -f "${BUILD_DIR}/build/config.h" ] || [ ! -d "${SRCROOT}/contrib/${arch}-${PLATFORM_NAME}" ]; then
         mkdir -p "${BUILD_DIR}"
-        (cd "${BUILD_DIR}" && env -i NO_COLOR=1 V=1 VERBOSE=1 MAKEFLAGS="$MAKEFLAGS" "${SCRIPTDIR}/build.sh" \
+        (cd "${BUILD_DIR}" && env -i HOME="${HOME}" NO_COLOR=1 V=1 VERBOSE=1 MAKEFLAGS="$MAKEFLAGS" "${SCRIPTDIR}/build.sh" \
             --enable-shared --arch="${arch}" --sdk="${PLATFORM_NAME}")
     else
-        (cd "${BUILD_DIR}/build/" && env -i NO_COLOR=1 ./compile MAKEFLAGS="$MAKEFLAGS" V=1 VERBOSE=1)
+        (cd "${BUILD_DIR}/build/" && env -i HOME="${HOME}" NO_COLOR=1 ./compile MAKEFLAGS="$MAKEFLAGS" V=1 VERBOSE=1)
     fi
 done


=====================================
extras/package/macosx/env.build.sh
=====================================
@@ -146,7 +146,7 @@ vlcSetContribEnvironment() {
     local MINIMAL_OSX_VERSION="$1"
 
     if [ -z "$SDKROOT" ]; then
-        export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
+        SDKROOT="$(xcrun --sdk macosx --show-sdk-path)" && export SDKROOT
     fi
 
     echo "Setting contrib environment with minimum macOS version $MINIMAL_OSX_VERSION and SDK $SDKROOT"


=====================================
modules/Makefile.am
=====================================
@@ -32,7 +32,7 @@ LIBTOOL_CARGO = \
 	RUSTFLAGS="${RUSTFLAGS}" \
 	CARGO_TARGET_DIR="target-rust" \
 	LIBTOOL="$(LIBTOOL)" \
-	$(LIBTOOL_CARGO_EXE) $(CARGO) rustc $(CARGO_BUILD_ARGS)
+	$(LIBTOOL_CARGO_EXE) $(CARGO) $(CARGO_BUILD_STD) rustc $(CARGO_BUILD_ARGS)
 
 CARGO_PLUGINS_INV = ${LTLIBRARIES:%rs_plugin.la=%rs_plugin}
 CARGO_PLUGINS_CUT = ${CARGO_PLUGINS_INV:%.la=}



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fb18df85ca73deffe66bb83a06fd09bb9de4b09d...a1dead92dc1e54d2377bc90c445f23b1e1ad01f4

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fb18df85ca73deffe66bb83a06fd09bb9de4b09d...a1dead92dc1e54d2377bc90c445f23b1e1ad01f4
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