[vlc-commits] macOS build.sh: Move PATH and triplet calculation out in helper funcs
David Fuhrmann
git at videolan.org
Sat Mar 10 10:32:23 CET 2018
vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sat Mar 10 10:28:16 2018 +0100| [ee8920f98eacf76be7122a400a75e90c4d4f9b1c] | committer: David Fuhrmann
macOS build.sh: Move PATH and triplet calculation out in helper funcs
This should give a complete environment when using env.build.sh
as a standalone helper.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ee8920f98eacf76be7122a400a75e90c4d4f9b1c
---
extras/package/macosx/build.sh | 24 ++++++---------------
extras/package/macosx/env.build.sh | 44 ++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 18 deletions(-)
diff --git a/extras/package/macosx/build.sh b/extras/package/macosx/build.sh
index 187f7f7ad3..3d7264d5ff 100755
--- a/extras/package/macosx/build.sh
+++ b/extras/package/macosx/build.sh
@@ -15,16 +15,12 @@ source "$SCRIPTDIR/env.build.sh" "none"
ARCH="x86_64"
MINIMAL_OSX_VERSION="10.10"
OSX_VERSION=`xcrun --show-sdk-version`
-OSX_KERNELVERSION=`uname -r | cut -d. -f1`
SDKROOT=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$OSX_VERSION.sdk
VLCBUILDDIR=""
CORE_COUNT=`getconf NPROCESSORS_ONLN 2>&1`
let JOBS=$CORE_COUNT+1
-if [ ! -z "$VLC_FORCE_KERNELVERSION" ]; then
- OSX_KERNELVERSION="$VLC_FORCE_KERNELVERSION"
-fi
usage()
{
@@ -121,23 +117,15 @@ fi
info "Building VLC for the Mac OS X"
-spushd `dirname $0`/../../..
-vlcroot=`pwd`
-spopd
+TRIPLET=$(vlcGetTriplet)
+export SDKROOT
+vlcSetBaseEnvironment
+vlcroot="$(vlcGetRootDir)"
-builddir=`pwd`
+builddir="$(pwd)"
info "Building in \"$builddir\""
-TRIPLET=$ARCH-apple-darwin$OSX_KERNELVERSION
-
-export CC="`xcrun --find clang`"
-export CXX="`xcrun --find clang++`"
-export OBJC="`xcrun --find clang`"
-export OSX_VERSION
-export SDKROOT
-export PATH="${vlcroot}/extras/tools/build/bin:${vlcroot}/contrib/${TRIPLET}/bin:${VLC_PATH}:/bin:/sbin:/usr/bin:/usr/sbin"
-
#
# vlc/extras/tools
#
@@ -264,6 +252,6 @@ elif [ "$PACKAGETYPE" = "n" -o "$PACKAGE" = "yes" ]; then
make package-macosx
fi
-if [ ! -z "$VLCBUILDDIR" ];then
+if [ ! -z "$VLCBUILDDIR" ]; then
popd
fi
diff --git a/extras/package/macosx/env.build.sh b/extras/package/macosx/env.build.sh
index 2cdfe33b6b..e04ac79b58 100755
--- a/extras/package/macosx/env.build.sh
+++ b/extras/package/macosx/env.build.sh
@@ -1,5 +1,47 @@
#!/bin/bash
+vlcGetTriplet() {
+ local OSX_KERNELVERSION=$(uname -r | cut -d. -f1)
+ if [ ! -z "$VLC_FORCE_KERNELVERSION" ]; then
+ OSX_KERNELVERSION="$VLC_FORCE_KERNELVERSION"
+ fi
+
+ local LOCAL_ARCH="x86_64"
+ if [ -n "$ARCH" ]; then
+ LOCAL_ARCH="$ARCH"
+ fi
+
+ echo "$LOCAL_ARCH-apple-darwin$OSX_KERNELVERSION"
+}
+
+# Gets VLCs root dir based on location of this file, also follow symlinks
+vlcGetRootDir() {
+ local SOURCE="${BASH_SOURCE[0]}"
+ while [ -h "$SOURCE" ]; do
+ local DIR="$(cd -P "$( dirname "$SOURCE" )" && pwd)"
+ SOURCE="$(readlink "$SOURCE")"
+ [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # Relative symlink needs dir prepended
+ done
+ echo "$(cd -P "$(dirname "$SOURCE")/../../../" && pwd)"
+}
+
+vlcSetBaseEnvironment() {
+ local LOCAL_TRIPLET="$TRIPLET"
+ if [ -z "$LOCAL_TRIPLET" ]; then
+ LOCAL_TRIPLET="$(vlcGetTriplet)"
+ fi
+
+ local VLC_ROOT_DIR="$(vlcGetRootDir)"
+
+ echo "Setting base environment"
+ echo "Using VLC root dir $VLC_ROOT_DIR and triplet $LOCAL_TRIPLET"
+
+ export CC="$(xcrun --find clang)"
+ export CXX="$(xcrun --find clang++)"
+ export OBJC="$(xcrun --find clang)"
+ export PATH="${VLC_ROOT_DIR}/extras/tools/build/bin:${VLC_ROOT_DIR}/contrib/${LOCAL_TRIPLET}/bin:${VLC_PATH}:/bin:/sbin:/usr/bin:/usr/sbin"
+}
+
vlcSetSymbolEnvironment() {
echo "Setting symbol environment"
@@ -93,9 +135,11 @@ if [ "$1" = "none" ]; then
fi
if [ "$VLC_ENV_MODE" = "contrib" ]; then
+ vlcSetBaseEnvironment
vlcSetSymbolEnvironment
vlcSetContribEnvironment "10.10"
elif [ "$VLC_ENV_MODE" = "vlc" ]; then
+ vlcSetBaseEnvironment
vlcSetSymbolEnvironment
vlcUnsetContribEnvironment
fi
More information about the vlc-commits
mailing list