Fixed path issues when sourcing.
This commit is contained in:
parent
31e5646091
commit
08a22cb754
1 changed files with 35 additions and 23 deletions
|
@ -25,19 +25,27 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
G_SCRIPT=$0
|
TC_G_SCRIPT_PATH="${BASH_SOURCE}"
|
||||||
G_BUILDROOT=${PWD}
|
while [ -L "${TC_G_SCRIPT_PATH}" ]; do
|
||||||
G_PIURL=https://github.com/tttapa/docker-arm-cross-toolchain/releases/latest/download/x-tools-
|
TC_G_SCRIPT_DIR="$(cd -P "$(dirname "${TC_G_SCRIPT_PATH}")" >/dev/null 2>&1 && pwd)"
|
||||||
|
TC_G_SCRIPT_PATH="$(readlink "${TC_G_SCRIPT_PATH}")"
|
||||||
|
[[ ${TC_G_SCRIPT_PATH} != /* ]] && TC_G_SCRIPT_PATH="${TC_G_SCRIPT_DIR}/${TC_G_SCRIPT_PATH}"
|
||||||
|
done
|
||||||
|
TC_G_SCRIPT_PATH="$(readlink -f "${TC_G_SCRIPT_PATH}")"
|
||||||
|
TC_G_SCRIPT_DIR="$(cd -P "$(dirname -- "${TC_G_SCRIPT_PATH}")" >/dev/null 2>&1 && pwd)"
|
||||||
|
TC_G_SCRIPT=$(basename ${SCRIPT_PATH})
|
||||||
|
|
||||||
|
|
||||||
|
TC_G_PIURL=https://github.com/tttapa/docker-arm-cross-toolchain/releases/latest/download/x-tools-
|
||||||
|
|
||||||
|
|
||||||
function buildMacOSXToolchain() {
|
function buildMacOSXToolchain() {
|
||||||
local SDK=$1
|
local SDK=$1
|
||||||
local XCODE=$2
|
local XCODE=$2
|
||||||
local PLATFORM=$3
|
local PLATFORM=$3
|
||||||
local BASE=$(pwd)
|
|
||||||
local CLANG=
|
local CLANG=
|
||||||
local RTPATH=
|
local RTPATH=
|
||||||
local CROSSTOOLS="${BASE}/x-tools/${PLATFORM}"
|
local CROSSTOOLS="${TC_G_SCRIPT_DIR}/x-tools/${PLATFORM}"
|
||||||
|
|
||||||
mkdir -p work
|
mkdir -p work
|
||||||
|
|
||||||
|
@ -49,25 +57,25 @@ function buildMacOSXToolchain() {
|
||||||
if [[ ! -f x-tools/${PLATFORM}/toolchain.cmake ]]; then
|
if [[ ! -f x-tools/${PLATFORM}/toolchain.cmake ]]; then
|
||||||
pushd work/osxcross
|
pushd work/osxcross
|
||||||
# Have we built Apple's clang?
|
# Have we built Apple's clang?
|
||||||
if [[ ! -d "${BASE}/clang" ]]; then
|
if [[ ! -d "${TC_G_SCRIPT_DIR}/clang" ]]; then
|
||||||
UNATTENDED=1 INSTALLPREFIX=${BASE}/clang ./build_apple_clang.sh
|
UNATTENDED=1 INSTALLPREFIX=${TC_G_SCRIPT_DIR}/clang ./build_apple_clang.sh
|
||||||
pushd build/clang*/build_stage2
|
pushd build/clang*/build_stage2
|
||||||
make install
|
make install
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
# Use our fresh new clang.
|
# Use our fresh new clang.
|
||||||
source <("${CROSSTOOLS}/bin/osxcross-conf" 2>/dev/null)
|
source <("${CROSSTOOLS}/bin/osxcross-conf" 2>/dev/null)
|
||||||
export PATH="${BASE}/clang/bin:${CROSSTOOLS}/bin:${PATH}"
|
export PATH="${TC_G_SCRIPT_DIR}/clang/bin:${CROSSTOOLS}/bin:${PATH}"
|
||||||
export CC="${BASE}/clang/bin/clang"
|
export CC="${TC_G_SCRIPT_DIR}/clang/bin/clang"
|
||||||
export CXX="${BASE}/clang/bin/clang++"
|
export CXX="${TC_G_SCRIPT_DIR}/clang/bin/clang++"
|
||||||
# Do we have an existing SDK tarball?
|
# Do we have an existing SDK tarball?
|
||||||
if [[ ! -f "${BASE}/${SDK}" ]]; then
|
if [[ ! -f "${TC_G_SCRIPT_DIR}/${SDK}" ]]; then
|
||||||
# Nope. Build tarball and keep for later.
|
# Nope. Build tarball and keep for later.
|
||||||
./tools/gen_sdk_package_pbzx.sh "${BASE}/${XCODE}"
|
./tools/gen_sdk_package_pbzx.sh "${TC_G_SCRIPT_DIR}/${XCODE}"
|
||||||
mv -f MacOSX* "${BASE}/."
|
mv -f MacOSX* "${TC_G_SCRIPT_DIR}/."
|
||||||
fi
|
fi
|
||||||
# Put tarball in place.
|
# Put tarball in place.
|
||||||
cp -f "${BASE}/${SDK}" tarballs/.
|
cp -f "${TC_G_SCRIPT_DIR}/${SDK}" tarballs/.
|
||||||
# Build SDK.
|
# Build SDK.
|
||||||
UNATTENDED=1 TARGET_DIR="${CROSSTOOLS}" ./build.sh
|
UNATTENDED=1 TARGET_DIR="${CROSSTOOLS}" ./build.sh
|
||||||
# Fix fubar in osxcross.
|
# Fix fubar in osxcross.
|
||||||
|
@ -84,7 +92,7 @@ function buildMacOSXToolchain() {
|
||||||
NO_GCC
|
NO_GCC
|
||||||
# Build compiler runtime.
|
# Build compiler runtime.
|
||||||
#***TODO*** This fails to find <optional> for x86.
|
#***TODO*** This fails to find <optional> for x86.
|
||||||
RTPATH="${BASE}/clang/lib/clang"
|
RTPATH="${TC_G_SCRIPT_DIR}/clang/lib/clang"
|
||||||
CLANG=$(ls -1 "${RTPATH}" | grep -F . | sort | tail -n1)
|
CLANG=$(ls -1 "${RTPATH}" | grep -F . | sort | tail -n1)
|
||||||
if [[ "${CLANG}" == "" ]]; then
|
if [[ "${CLANG}" == "" ]]; then
|
||||||
CLANG=$(ls -1 "${RTPATH}" | sort | tail -n1)
|
CLANG=$(ls -1 "${RTPATH}" | sort | tail -n1)
|
||||||
|
@ -151,21 +159,21 @@ function install_x86_windows() {
|
||||||
|
|
||||||
function install_aarch64_pi() {
|
function install_aarch64_pi() {
|
||||||
# Raspberry Pi, aarch64.
|
# Raspberry Pi, aarch64.
|
||||||
wget -O- ${G_PIURL}aarch64-rpi3-linux-gnu.tar.xz | tar xJ
|
wget -O- ${TC_G_PIURL}aarch64-rpi3-linux-gnu.tar.xz | tar xJ
|
||||||
#***TODO*** sysroot
|
#***TODO*** sysroot
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function install_armv6_pi() {
|
function install_armv6_pi() {
|
||||||
# Raspberry Pi, armv6.
|
# Raspberry Pi, armv6.
|
||||||
wget -O- ${G_PIURL}armv6-rpi-linux-gnueabihf.tar.xz | tar xJ
|
wget -O- ${TC_G_PIURL}armv6-rpi-linux-gnueabihf.tar.xz | tar xJ
|
||||||
#***TODO*** sysroot
|
#***TODO*** sysroot
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function install_armv8_pi() {
|
function install_armv8_pi() {
|
||||||
# Raspberry Pi, armv8.
|
# Raspberry Pi, armv8.
|
||||||
wget -O- ${G_PIURL}armv8-rpi3-linux-gnueabihf.tar.xz | tar xJ
|
wget -O- ${TC_G_PIURL}armv8-rpi3-linux-gnueabihf.tar.xz | tar xJ
|
||||||
#***TODO*** sysroot
|
#***TODO*** sysroot
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,15 +242,15 @@ function use_toolchain() {
|
||||||
case "${ARCH}" in
|
case "${ARCH}" in
|
||||||
aarch64)
|
aarch64)
|
||||||
TRIPLE="aarch64-apple-darwin22.4"
|
TRIPLE="aarch64-apple-darwin22.4"
|
||||||
OSXCROSS_LOCATION=${G_BUILDROOT}/x-tools/aarch64-macos-apple
|
OSXCROSS_LOCATION=${TC_G_SCRIPT_DIR}/x-tools/aarch64-macos-apple
|
||||||
;;
|
;;
|
||||||
x86)
|
x86)
|
||||||
TRIPLE="i386-apple-darwin17"
|
TRIPLE="i386-apple-darwin17"
|
||||||
OSXCROSS_LOCATION=${G_BUILDROOT}/x-tools/x86_64-macos-apple
|
OSXCROSS_LOCATION=${TC_G_SCRIPT_DIR}/x-tools/x86_64-macos-apple
|
||||||
;;
|
;;
|
||||||
x86_64)
|
x86_64)
|
||||||
TRIPLE="x86_64-apple-darwin17"
|
TRIPLE="x86_64-apple-darwin17"
|
||||||
OSXCROSS_LOCATION=${G_BUILDROOT}/x-tools/x86_64-macos-apple
|
OSXCROSS_LOCATION=${TC_G_SCRIPT_DIR}/x-tools/x86_64-macos-apple
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
CROSS_OS="darwin"
|
CROSS_OS="darwin"
|
||||||
|
@ -268,6 +276,10 @@ function use_toolchain() {
|
||||||
TRIPLE="armv8-rpi3-linux-gnueabihf"
|
TRIPLE="armv8-rpi3-linux-gnueabihf"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
CROSS_OS="linux"
|
||||||
|
CC="${TRIPLE}-gcc"
|
||||||
|
CXX="${TRIPLE}-g++"
|
||||||
|
RANLIB="${TRIPLE}-ranlib"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
windows)
|
windows)
|
||||||
|
@ -288,7 +300,7 @@ function use_toolchain() {
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo "export TOOLCHAIN_FILE=\"${G_BUILDROOT}/cmake/${TRIPLE}.cmake\""
|
echo "export TOOLCHAIN_FILE=\"${TC_G_SCRIPT_DIR}/cmake/${TRIPLE}.cmake\""
|
||||||
echo "export CC=\"${CC}\""
|
echo "export CC=\"${CC}\""
|
||||||
echo "export CXX=\"${CXX}\""
|
echo "export CXX=\"${CXX}\""
|
||||||
echo "export RANLIB=\"${RANLIB}\""
|
echo "export RANLIB=\"${RANLIB}\""
|
||||||
|
@ -372,7 +384,7 @@ if [[ ${HELP} -eq 1 ]]; then
|
||||||
Kangaroo Punch Toolchain Installer
|
Kangaroo Punch Toolchain Installer
|
||||||
http://skunkworks.kangaroopunch.com
|
http://skunkworks.kangaroopunch.com
|
||||||
|
|
||||||
Usage: ${G_SCRIPT} [install|use] [architecture] [platform]
|
Usage: ${TC_G_SCRIPT} [install|use] [architecture] [platform]
|
||||||
|
|
||||||
Where [architecture] and [platform] are one of:
|
Where [architecture] and [platform] are one of:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue