[vlc-commits] macOS build.sh: Move out environment into separate sh file
David Fuhrmann
git at videolan.org
Sat Mar 10 10:32:22 CET 2018
vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sat Mar 3 13:28:36 2018 +0100| [92782a17dd7cbb4a9f30a03f93d1fcb69eaf00db] | committer: David Fuhrmann
macOS build.sh: Move out environment into separate sh file
This file is included and used in build.sh. Additionally, it can
be directly sourced into the current shell, to have a correct
environment for local builds.
The first parameter specifies if the environment for "vlc" or
"contrib" shall be provided.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=92782a17dd7cbb4a9f30a03f93d1fcb69eaf00db
---
extras/package/macosx/build.sh | 60 +++-------------------
extras/package/macosx/env.build.sh | 101 +++++++++++++++++++++++++++++++++++++
2 files changed, 108 insertions(+), 53 deletions(-)
diff --git a/extras/package/macosx/build.sh b/extras/package/macosx/build.sh
index c3343a989c..187f7f7ad3 100755
--- a/extras/package/macosx/build.sh
+++ b/extras/package/macosx/build.sh
@@ -8,6 +8,10 @@ info()
echo "[${green}build${normal}] $1"
}
+SCRIPTDIR=$(dirname "$0")
+source "$SCRIPTDIR/env.build.sh" "none"
+
+
ARCH="x86_64"
MINIMAL_OSX_VERSION="10.10"
OSX_VERSION=`xcrun --show-sdk-version`
@@ -134,39 +138,6 @@ export OSX_VERSION
export SDKROOT
export PATH="${vlcroot}/extras/tools/build/bin:${vlcroot}/contrib/${TRIPLET}/bin:${VLC_PATH}:/bin:/sbin:/usr/bin:/usr/sbin"
-# Select avcodec flavor to compile contribs with
-export USE_FFMPEG=1
-
-# The following symbols do not exist on the minimal macOS version (10.7), so they are disabled
-# here. This allows compilation also with newer macOS SDKs.
-# Added symbols in 10.13
-export ac_cv_func_open_wmemstream=no
-export ac_cv_func_fmemopen=no
-export ac_cv_func_open_memstream=no
-export ac_cv_func_futimens=no
-export ac_cv_func_utimensat=no
-
-# Added symbols between 10.11 and 10.12
-export ac_cv_func_basename_r=no
-export ac_cv_func_clock_getres=no
-export ac_cv_func_clock_gettime=no
-export ac_cv_func_clock_settime=no
-export ac_cv_func_dirname_r=no
-export ac_cv_func_getentropy=no
-export ac_cv_func_mkostemp=no
-export ac_cv_func_mkostemps=no
-
-# Added symbols between 10.7 and 10.11
-export ac_cv_func_ffsll=no
-export ac_cv_func_flsll=no
-export ac_cv_func_fdopendir=no
-export ac_cv_func_openat=no
-export ac_cv_func_fstatat=no
-export ac_cv_func_readlinkat=no
-
-# libnetwork does not exist yet on 10.7 (used by libcddb)
-export ac_cv_lib_network_connect=no
-
#
# vlc/extras/tools
#
@@ -185,20 +156,8 @@ spopd
# vlc/contribs
#
-# Usually, VLCs contrib libraries do not support partial availability at runtime.
-# Forcing those errors has two reasons:
-# - Some custom configure scripts include the right header for testing availability.
-# Those configure checks fail (correctly) with those errors, and replacements are
-# enabled. (e.g. ffmpeg)
-# - This will fail the build if a partially available symbol is added later on
-# in contribs and not mentioned in the list of symbols above.
-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 XCODE_FLAGS="MACOSX_DEPLOYMENT_TARGET=$MINIMAL_OSX_VERSION -sdk macosx$OSX_VERSION WARNING_CFLAGS=-Werror=partial-availability"
+vlcSetSymbolEnvironment
+vlcSetContribEnvironment "$MINIMAL_OSX_VERSION"
info "Building contribs"
spushd "${vlcroot}/contrib"
@@ -223,13 +182,8 @@ fi
fi
spopd
-unset CFLAGS
-unset CXXFLAGS
-unset OBJCFLAGS
-unset EXTRA_CFLAGS
-unset EXTRA_LDFLAGS
-unset XCODE_FLAGS
+vlcUnsetContribEnvironment
# Enable debug symbols by default
export CFLAGS="-g"
diff --git a/extras/package/macosx/env.build.sh b/extras/package/macosx/env.build.sh
new file mode 100755
index 0000000000..2cdfe33b6b
--- /dev/null
+++ b/extras/package/macosx/env.build.sh
@@ -0,0 +1,101 @@
+#!/bin/bash
+
+vlcSetSymbolEnvironment() {
+ echo "Setting symbol environment"
+
+ # The following symbols do not exist on the minimal macOS version (10.7), so they are disabled
+ # here. This allows compilation also with newer macOS SDKs.
+ # Added symbols in 10.13
+ export ac_cv_func_open_wmemstream=no
+ export ac_cv_func_fmemopen=no
+ export ac_cv_func_open_memstream=no
+ export ac_cv_func_futimens=no
+ export ac_cv_func_utimensat=no
+
+ # Added symbols between 10.11 and 10.12
+ export ac_cv_func_basename_r=no
+ export ac_cv_func_clock_getres=no
+ export ac_cv_func_clock_gettime=no
+ export ac_cv_func_clock_settime=no
+ export ac_cv_func_dirname_r=no
+ export ac_cv_func_getentropy=no
+ export ac_cv_func_mkostemp=no
+ export ac_cv_func_mkostemps=no
+
+ # Added symbols between 10.7 and 10.11
+ export ac_cv_func_ffsll=no
+ export ac_cv_func_flsll=no
+ export ac_cv_func_fdopendir=no
+ export ac_cv_func_openat=no
+ export ac_cv_func_fstatat=no
+ export ac_cv_func_readlinkat=no
+
+ # libnetwork does not exist yet on 10.7 (used by libcddb)
+ export ac_cv_lib_network_connect=no
+}
+
+vlcSetContribEnvironment() {
+ if [ -z "$1" ]; then
+ return 1
+ fi
+ local MINIMAL_OSX_VERSION="$1"
+
+ if [ -z "$SDKROOT" ]; then
+ export SDKROOT="$(xcrun --show-sdk-path)"
+ fi
+
+ echo "Setting contrib environment with minimum macOS version $MINIMAL_OSX_VERSION and SDK $SDKROOT"
+
+ # Select avcodec flavor to compile contribs with
+ export USE_FFMPEG=1
+
+ # Usually, VLCs contrib libraries do not support partial availability at runtime.
+ # Forcing those errors has two reasons:
+ # - Some custom configure scripts include the right header for testing availability.
+ # Those configure checks fail (correctly) with those errors, and replacements are
+ # enabled. (e.g. ffmpeg)
+ # - This will fail the build if a partially available symbol is added later on
+ # in contribs and not mentioned in the list of symbols above.
+ 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 XCODE_FLAGS="MACOSX_DEPLOYMENT_TARGET=$MINIMAL_OSX_VERSION -sdk $SDKROOT WARNING_CFLAGS=-Werror=partial-availability"
+}
+
+vlcUnsetContribEnvironment() {
+ echo "Unsetting contrib environment"
+
+ unset CFLAGS
+ unset CXXFLAGS
+ unset OBJCFLAGS
+
+ unset EXTRA_CFLAGS
+ unset EXTRA_LDFLAGS
+ unset XCODE_FLAGS
+}
+
+
+# Parameter handling
+
+# First parameter: mode to use this script:
+# vlc (default): auto-setup environment suitable for building vlc itself
+# contrib: auto-setup environment suitable for building vlc contribs
+# none: do not perform any auto-setup (used for scripts)
+VLC_ENV_MODE="vlc"
+if [ "$1" = "contrib" ]; then
+ VLC_ENV_MODE="contrib"
+fi
+if [ "$1" = "none" ]; then
+ VLC_ENV_MODE="none"
+fi
+
+if [ "$VLC_ENV_MODE" = "contrib" ]; then
+ vlcSetSymbolEnvironment
+ vlcSetContribEnvironment "10.10"
+elif [ "$VLC_ENV_MODE" = "vlc" ]; then
+ vlcSetSymbolEnvironment
+ vlcUnsetContribEnvironment
+fi
More information about the vlc-commits
mailing list