[vlc-commits] extras: fix arch handling in macOS build script
Felix Paul Kühne
git at videolan.org
Mon Dec 14 05:49:13 UTC 2020
vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Wed Dec 9 07:23:08 2020 +0100| [26ea97a175b24aa3c493e95d07af69f717a22824] | committer: Felix Paul Kühne
extras: fix arch handling in macOS build script
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=26ea97a175b24aa3c493e95d07af69f717a22824
---
extras/package/macosx/build.sh | 32 +++++++++--------
extras/package/macosx/env.build.sh | 72 +++++++++++++++++++++++++++++---------
2 files changed, 74 insertions(+), 30 deletions(-)
diff --git a/extras/package/macosx/build.sh b/extras/package/macosx/build.sh
index 69395ef5d0..18cde8bc4f 100755
--- a/extras/package/macosx/build.sh
+++ b/extras/package/macosx/build.sh
@@ -17,7 +17,6 @@ VLCBUILDDIR=""
CORE_COUNT=`getconf NPROCESSORS_ONLN 2>&1`
let JOBS=$CORE_COUNT+1
-
usage()
{
cat << EOF
@@ -34,7 +33,7 @@ OPTIONS:
-p Build packages for all artifacts
-i <n|u> Create an installable package (n: nightly, u: unsigned stripped release archive)
-k <sdk> Use the specified sdk (default: $SDKROOT)
- -a <arch> Use the specified arch (default: $ARCH)
+ -a <arch> Use the specified arch (default: $HOST_ARCH)
-C Use the specified VLC build dir
-b <url> Enable breakpad support and send crash reports to this URL
-d Disable debug mode (on by default)
@@ -79,7 +78,7 @@ do
PACKAGETYPE=$OPTARG
;;
a)
- ARCH=$OPTARG
+ HOST_ARCH=$OPTARG
;;
k)
SDKROOT=$OPTARG
@@ -115,9 +114,13 @@ if [ "$QUIET" = "yes" ]; then
out="/dev/null"
fi
-info "Building VLC for the Mac OS X"
+ACTUAL_HOST_ARCH=`get_actual_arch $HOST_ARCH`
+BUILD_ARCH=`get_buildsystem_arch $BUILD_ARCH`
+
+info "Building VLC for macOS, architecture ${ACTUAL_HOST_ARCH} on a ${BUILD_ARCH} device"
-TRIPLET=$(vlcGetTriplet)
+BUILD_TRIPLET=$(vlcGetBuildTriplet)
+HOST_TRIPLET=$(vlcGetHostTriplet)
export SDKROOT
vlcSetBaseEnvironment
vlcroot="$(vlcGetRootDir)"
@@ -157,11 +160,11 @@ info "Building contribs"
spushd "${vlcroot}/contrib"
if [ "$REBUILD" = "yes" ]; then
- rm -rf contrib-$TRIPLET
- rm -rf $TRIPLET
+ rm -rf contrib-$HOST_TRIPLET
+ rm -rf $HOST_TRIPLET
fi
-mkdir -p contrib-$TRIPLET && cd contrib-$TRIPLET
-../bootstrap --build=$TRIPLET --host=$TRIPLET > $out
+mkdir -p contrib-$HOST_TRIPLET && cd contrib-$HOST_TRIPLET
+../bootstrap --build=$BUILD_TRIPLET --host=$HOST_TRIPLET > $out
if [ "$CONTRIBFROMSOURCE" = "yes" ]; then
make list
@@ -182,6 +185,7 @@ spopd
vlcUnsetContribEnvironment
+vlcSetLibVLCEnvironment
#
# vlc/bootstrap
@@ -214,8 +218,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 \
@@ -237,7 +241,6 @@ make -j$JOBS
info "Preparing VLC.app"
make VLC.app
-
if [ "$PACKAGETYPE" = "u" ]; then
info "Copying app with debug symbols into VLC-debug.app and stripping"
rm -rf VLC-debug.app
@@ -248,14 +251,15 @@ if [ "$PACKAGETYPE" = "u" ]; then
(cd VLC-debug.app/Contents/MacOS/lib/ && rm libvlccore.dylib && mv libvlccore.*.dylib libvlccore.dylib)
(cd VLC-debug.app/Contents/MacOS/lib/ && rm libvlc.dylib && mv libvlc.*.dylib libvlc.dylib)
-
find VLC.app/ -name "*.dylib" -exec strip -x {} \;
find VLC.app/ -type f -name "VLC" -exec strip -x {} \;
find VLC.app/ -type f -name "Sparkle" -exec strip -x {} \;
find VLC.app/ -type f -name "Growl" -exec strip -x {} \;
find VLC.app/ -type f -name "Breakpad" -exec strip -x {} \;
- bin/vlc-cache-gen VLC.app/Contents/MacOS/plugins
+ 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
diff --git a/extras/package/macosx/env.build.sh b/extras/package/macosx/env.build.sh
index 755722fb9b..6bd0b4eca2 100755
--- a/extras/package/macosx/env.build.sh
+++ b/extras/package/macosx/env.build.sh
@@ -1,16 +1,40 @@
#!/bin/bash
-ARCH="x86_64"
+HOST_ARCH="x86_64"
+BUILD_ARCH=`uname -m | cut -d. -f1`
MINIMAL_OSX_VERSION="10.11"
+get_actual_arch() {
+ if [ "$1" = "aarch64" ]; then
+ echo "arm64"
+ else
+ echo "$1"
+ fi
+}
+
+get_buildsystem_arch() {
+ if [ "$1" = "arm64" ]; then
+ echo "aarch64"
+ else
+ echo "$1"
+ fi
+}
-vlcGetTriplet() {
+vlcGetOSXKernelVersion() {
local OSX_KERNELVERSION=$(uname -r | cut -d. -f1)
if [ ! -z "$VLC_FORCE_KERNELVERSION" ]; then
OSX_KERNELVERSION="$VLC_FORCE_KERNELVERSION"
fi
- echo "$ARCH-apple-darwin$OSX_KERNELVERSION"
+ echo "$OSX_KERNELVERSION"
+}
+
+vlcGetBuildTriplet() {
+ echo "$BUILD_ARCH-apple-darwin$(vlcGetOSXKernelVersion)"
+}
+
+vlcGetHostTriplet() {
+ echo "$HOST_ARCH-apple-darwin$(vlcGetOSXKernelVersion)"
}
# Gets VLCs root dir based on location of this file, also follow symlinks
@@ -25,30 +49,31 @@ vlcGetRootDir() {
}
vlcSetBaseEnvironment() {
- local LOCAL_TRIPLET="$TRIPLET"
- if [ -z "$LOCAL_TRIPLET" ]; then
- LOCAL_TRIPLET="$(vlcGetTriplet)"
+ local LOCAL_BUILD_TRIPLET="$BUILD_TRIPLET"
+ if [ -z "$LOCAL_BUILD_TRIPLET" ]; then
+ LOCAL_BUILD_TRIPLET="$(vlcGetBuildTriplet)"
fi
local VLC_ROOT_DIR="$(vlcGetRootDir)"
echo "Setting base environment"
- echo "Using VLC root dir $VLC_ROOT_DIR and triplet $LOCAL_TRIPLET"
+ echo "Using VLC root dir $VLC_ROOT_DIR, build triplet $LOCAL_BUILD_TRIPLET and host triplet $(vlcGetHostTriplet)"
+ export AR="$(xcrun --find ar)"
export CC="$(xcrun --find clang)"
export CXX="$(xcrun --find clang++)"
+ export NM="$(xcrun --find nm)"
export OBJC="$(xcrun --find clang)"
export OBJCXX="$(xcrun --find clang++)"
- export AR="$(xcrun --find ar)"
export RANLIB="$(xcrun --find ranlib)"
- export NM="$(xcrun --find nm)"
+ export STRIP="$(xcrun --find strip)"
python3Path=$(echo /Library/Frameworks/Python.framework/Versions/3.*/bin | awk '{print $1;}')
if [ ! -d "$python3Path" ]; then
python3Path=""
fi
- export PATH="${VLC_ROOT_DIR}/extras/tools/build/bin:${VLC_ROOT_DIR}/contrib/${LOCAL_TRIPLET}/bin:$python3Path:${VLC_PATH}:/bin:/sbin:/usr/bin:/usr/sbin"
+ export PATH="${VLC_ROOT_DIR}/extras/tools/build/bin:${VLC_ROOT_DIR}/contrib/${LOCAL_BUILD_TRIPLET}/bin:$python3Path:${VLC_PATH}:/bin:/sbin:/usr/bin:/usr/sbin"
}
vlcSetSymbolEnvironment() {
@@ -110,13 +135,13 @@ vlcSetContribEnvironment() {
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="-isysroot $SDKROOT -mmacosx-version-min=$MINIMAL_OSX_VERSION -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_HOST_ARCH"
+ export EXTRA_LDFLAGS="-isysroot $SDKROOT -mmacosx-version-min=$MINIMAL_OSX_VERSION -DMACOSX_DEPLOYMENT_TARGET=$MINIMAL_OSX_VERSION -arch $ACTUAL_HOST_ARCH"
export XCODE_FLAGS="MACOSX_DEPLOYMENT_TARGET=$MINIMAL_OSX_VERSION -sdk $SDKROOT WARNING_CFLAGS=-Werror=partial-availability"
}
vlcUnsetContribEnvironment() {
- echo "Unsetting contrib flags, prepare VLC flags"
+ echo "Unsetting contrib flags"
unset CFLAGS
unset CXXFLAGS
@@ -125,13 +150,26 @@ vlcUnsetContribEnvironment() {
unset EXTRA_CFLAGS
unset EXTRA_LDFLAGS
unset XCODE_FLAGS
+}
+
+vlcSetLibVLCEnvironment() {
+ echo "Setting libVLC flags"
# Enable debug symbols by default
- export CFLAGS="-g"
- export CXXFLAGS="-g"
- export OBJCFLAGS="-g"
+ export CFLAGS="-g -arch $ACTUAL_HOST_ARCH"
+ export CXXFLAGS="-g -arch $ACTUAL_HOST_ARCH"
+ export OBJCFLAGS="-g -arch $ACTUAL_HOST_ARCH"
+ export LDFLAGS="-arch $ACTUAL_HOST_ARCH"
}
+vlcUnsetLibVLCEnvironment() {
+ echo "Unsetting libVLC flags"
+
+ unset CFLAGS
+ unset CXXFLAGS
+ unset OBJCFLAGS
+ unset LDFLAGS
+}
# Parameter handling
@@ -151,9 +189,11 @@ fi
if [ "$VLC_ENV_MODE" = "contrib" ]; then
vlcSetBaseEnvironment
vlcSetSymbolEnvironment
+ vlcUnsetLibVLCEnvironment
vlcSetContribEnvironment "$MINIMAL_OSX_VERSION"
elif [ "$VLC_ENV_MODE" = "vlc" ]; then
vlcSetBaseEnvironment
vlcSetSymbolEnvironment
vlcUnsetContribEnvironment
+ vlcSetLibVLCEnvironment
fi
More information about the vlc-commits
mailing list