[vlc-devel] [PATCH 2/7] extras: fix arch handling in macOS build script

naich64 david.fuhrmann at gmail.com
Mon Nov 30 08:46:15 CET 2020


Hi Felix,

Thanks for those patches.

> Am 29.11.2020 um 20:12 schrieb Felix Paul Kühne <fkuehne at videolan.org>:
> 
> From: Felix Paul Kühne <felix at feepk.net>
> 
> ---
> extras/package/macosx/build.sh | 43 +++++++++++++++++++++++++---------
> 1 file changed, 32 insertions(+), 11 deletions(-)
> 
> diff --git a/extras/package/macosx/build.sh b/extras/package/macosx/build.sh
> index 87a3129bb5..44b16ce59b 100755
> --- a/extras/package/macosx/build.sh
> +++ b/extras/package/macosx/build.sh
> @@ -11,6 +11,7 @@ info()
> ARCH="x86_64"
> MINIMAL_OSX_VERSION="10.7"
> OSX_KERNELVERSION=`uname -r | cut -d. -f1`
> +BUILD_ARCH=`uname -m | cut -d. -f1`
> SDKROOT=$(xcrun --show-sdk-path)
> VLCBUILDDIR=""
> 
> @@ -54,6 +55,14 @@ spopd()
>     popd > /dev/null
> }
> 
> +get_actual_arch() {
> +    if [ "$1" = "aarch64" ]; then
> +        echo "arm64"
> +    else
> +        echo "$1"
> +    fi
> +}
> +
> while getopts "hvrcpi:k:a:j:C:b:" OPTION
> do
>      case $OPTION in
> @@ -124,16 +133,25 @@ builddir=`pwd`
> 
> info "Building in \"$builddir\""
> 
> -TRIPLET=$ARCH-apple-darwin$OSX_KERNELVERSION
> +BUILD_TRIPLET=$BUILD_ARCH-apple-darwin$OSX_KERNELVERSION
> +HOST_TRIPLET=$ARCH-apple-darwin$OSX_KERNELVERSION
> +ACTUAL_ARCH=`get_actual_arch $ARCH`

This takes arch from the command line options. Can’t we just drop get_actual_arch, and pass the intended arch, like arm64, to the script directly?

> 
> python3Path=$(echo /Library/Frameworks/Python.framework/Versions/3.*/bin | awk '{print $1;}')
> if [ ! -d "$python3Path" ]; then
> 	python3Path=""
> fi
> 
> +export AR="`xcrun --find ar`"
> +export AS="`xcrun --find as`"
> export CC="`xcrun --find clang`"
> export CXX="`xcrun --find clang++`"
> +export LD="`xcrun --find ld`"
> +export NM="`xcrun --find nm`"
> export OBJC="`xcrun --find clang`"
> +export RANLIB="`xcrun --find ranlib`"
> +export STRINGS="`xcrun --find strings`"
> +export STRIP="`xcrun --find strip`"

Ok for now, but maybe we can drop that section altogether eventually? Tools seem to be aliased into /usr/bin nowadays.

> export SDKROOT
> export PATH="${vlcroot}/extras/tools/build/bin:${vlcroot}/contrib/${TRIPLET}/bin:$python3Path:${VLC_PATH}:/bin:/sbin:/usr/bin:/usr/sbin"
> 
> @@ -216,15 +234,15 @@ export CFLAGS="-Werror=partial-availability"
> export CXXFLAGS="-Werror=partial-availability"
> export OBJCFLAGS="-Werror=partial-availability"
> 
> -export EXTRA_CFLAGS="-isysroot $SDKROOT -mmacosx-version-min=$MINIMAL_OSX_VERSION -DMACOSX_DEPLOYMENT_TARGET=$MINIMAL_OSX_VERSION"
> -export EXTRA_LDFLAGS="-Wl,-syslibroot,$SDKROOT -mmacosx-version-min=$MINIMAL_OSX_VERSION -isysroot $SDKROOT -DMACOSX_DEPLOYMENT_TARGET=$MINIMAL_OSX_VERSION"
> +export EXTRA_CFLAGS="-isysroot $SDKROOT -mmacosx-version-min=$MINIMAL_OSX_VERSION -DMACOSX_DEPLOYMENT_TARGET=$MINIMAL_OSX_VERSION -arch $ACTUAL_ARCH"
> +export EXTRA_LDFLAGS="-Wl,-syslibroot,$SDKROOT -mmacosx-version-min=$MINIMAL_OSX_VERSION -isysroot $SDKROOT -DMACOSX_DEPLOYMENT_TARGET=$MINIMAL_OSX_VERSION -arch $ACTUAL_ARCH"
> # xcodebuild only allows to set a build-in sdk, not a custom one. Therefore use the default included SDK here
> export XCODE_FLAGS="MACOSX_DEPLOYMENT_TARGET=$MINIMAL_OSX_VERSION -sdk macosx WARNING_CFLAGS=-Werror=partial-availability"
> 
> info "Building contribs"
> spushd "${vlcroot}/contrib"
> -mkdir -p contrib-$TRIPLET && cd contrib-$TRIPLET
> -../bootstrap --build=$TRIPLET --host=$TRIPLET > $out
> +mkdir -p contrib-$HOST_TRIPLET && cd contrib-$HOST_TRIPLET
> +../bootstrap --build=x86_64-apple-darwin14 --host=$HOST_TRIPLET > $out

Why hardcoding darwin14 here? Shouldn’t we rather use $BUILD_TRIPLET, like you already use for the configure call of VLC?

> if [ "$REBUILD" = "yes" ]; then
>     make clean
> fi
> @@ -238,7 +256,7 @@ if [ "$CONTRIBFROMSOURCE" = "yes" ]; then
>     fi
> 
> else
> -if [ ! -e "../$TRIPLET" ]; then
> +if [ ! -e "../$HOST_TRIPLET" ]; then
>     make prebuilt > $out
> fi
> fi
> @@ -253,9 +271,10 @@ unset EXTRA_LDFLAGS
> unset XCODE_FLAGS
> 
> # Enable debug symbols by default
> -export CFLAGS="-g"
> -export CXXFLAGS="-g"
> -export OBJCFLAGS="-g"
> +export CFLAGS="-g -arch $ACTUAL_ARCH"
> +export CXXFLAGS="-g -arch $ACTUAL_ARCH"
> +export OBJCFLAGS="-g -arch $ACTUAL_ARCH"
> +export LDFLAGS="-arch $ACTUAL_ARCH"
> 
> #
> # vlc/bootstrap
> @@ -285,8 +304,8 @@ fi
> if [ "${vlcroot}/configure" -nt Makefile ]; then
> 
>   ${vlcroot}/extras/package/macosx/configure.sh \
> -      --build=$TRIPLET \
> -      --host=$TRIPLET \
> +      --build=$BUILD_TRIPLET \
> +      --host=$HOST_TRIPLET \
>       --with-macosx-version-min=$MINIMAL_OSX_VERSION \
>       --with-macosx-sdk=$SDKROOT \
>       $CONFIGFLAGS \
> @@ -327,7 +346,9 @@ if [ "$PACKAGETYPE" = "u" ]; then
>     find VLC.app/ -type f -name "Growl" -exec strip -x {} \;
>     find VLC.app/ -type f -name "Breakpad" -exec strip -x {} \;
> 
> +if [ "$BUILD_TRIPLET" = "$HOST_TRIPLET" ]; then
>     bin/vlc-cache-gen VLC.app/Contents/MacOS/plugins
> +fi
> 
>     info "Building VLC release archive"
>     make package-macosx-release
> -- 
> 2.24.3 (Apple Git-128)
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list