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
|
||||
G_BUILDROOT=${PWD}
|
||||
G_PIURL=https://github.com/tttapa/docker-arm-cross-toolchain/releases/latest/download/x-tools-
|
||||
TC_G_SCRIPT_PATH="${BASH_SOURCE}"
|
||||
while [ -L "${TC_G_SCRIPT_PATH}" ]; do
|
||||
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() {
|
||||
local SDK=$1
|
||||
local XCODE=$2
|
||||
local PLATFORM=$3
|
||||
local BASE=$(pwd)
|
||||
local CLANG=
|
||||
local RTPATH=
|
||||
local CROSSTOOLS="${BASE}/x-tools/${PLATFORM}"
|
||||
local CROSSTOOLS="${TC_G_SCRIPT_DIR}/x-tools/${PLATFORM}"
|
||||
|
||||
mkdir -p work
|
||||
|
||||
|
@ -49,25 +57,25 @@ function buildMacOSXToolchain() {
|
|||
if [[ ! -f x-tools/${PLATFORM}/toolchain.cmake ]]; then
|
||||
pushd work/osxcross
|
||||
# Have we built Apple's clang?
|
||||
if [[ ! -d "${BASE}/clang" ]]; then
|
||||
UNATTENDED=1 INSTALLPREFIX=${BASE}/clang ./build_apple_clang.sh
|
||||
if [[ ! -d "${TC_G_SCRIPT_DIR}/clang" ]]; then
|
||||
UNATTENDED=1 INSTALLPREFIX=${TC_G_SCRIPT_DIR}/clang ./build_apple_clang.sh
|
||||
pushd build/clang*/build_stage2
|
||||
make install
|
||||
popd
|
||||
fi
|
||||
# Use our fresh new clang.
|
||||
source <("${CROSSTOOLS}/bin/osxcross-conf" 2>/dev/null)
|
||||
export PATH="${BASE}/clang/bin:${CROSSTOOLS}/bin:${PATH}"
|
||||
export CC="${BASE}/clang/bin/clang"
|
||||
export CXX="${BASE}/clang/bin/clang++"
|
||||
export PATH="${TC_G_SCRIPT_DIR}/clang/bin:${CROSSTOOLS}/bin:${PATH}"
|
||||
export CC="${TC_G_SCRIPT_DIR}/clang/bin/clang"
|
||||
export CXX="${TC_G_SCRIPT_DIR}/clang/bin/clang++"
|
||||
# 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.
|
||||
./tools/gen_sdk_package_pbzx.sh "${BASE}/${XCODE}"
|
||||
mv -f MacOSX* "${BASE}/."
|
||||
./tools/gen_sdk_package_pbzx.sh "${TC_G_SCRIPT_DIR}/${XCODE}"
|
||||
mv -f MacOSX* "${TC_G_SCRIPT_DIR}/."
|
||||
fi
|
||||
# Put tarball in place.
|
||||
cp -f "${BASE}/${SDK}" tarballs/.
|
||||
cp -f "${TC_G_SCRIPT_DIR}/${SDK}" tarballs/.
|
||||
# Build SDK.
|
||||
UNATTENDED=1 TARGET_DIR="${CROSSTOOLS}" ./build.sh
|
||||
# Fix fubar in osxcross.
|
||||
|
@ -84,7 +92,7 @@ function buildMacOSXToolchain() {
|
|||
NO_GCC
|
||||
# Build compiler runtime.
|
||||
#***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)
|
||||
if [[ "${CLANG}" == "" ]]; then
|
||||
CLANG=$(ls -1 "${RTPATH}" | sort | tail -n1)
|
||||
|
@ -151,21 +159,21 @@ function install_x86_windows() {
|
|||
|
||||
function install_aarch64_pi() {
|
||||
# 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
|
||||
}
|
||||
|
||||
|
||||
function install_armv6_pi() {
|
||||
# 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
|
||||
}
|
||||
|
||||
|
||||
function install_armv8_pi() {
|
||||
# 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
|
||||
}
|
||||
|
||||
|
@ -234,15 +242,15 @@ function use_toolchain() {
|
|||
case "${ARCH}" in
|
||||
aarch64)
|
||||
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)
|
||||
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)
|
||||
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
|
||||
CROSS_OS="darwin"
|
||||
|
@ -268,6 +276,10 @@ function use_toolchain() {
|
|||
TRIPLE="armv8-rpi3-linux-gnueabihf"
|
||||
;;
|
||||
esac
|
||||
CROSS_OS="linux"
|
||||
CC="${TRIPLE}-gcc"
|
||||
CXX="${TRIPLE}-g++"
|
||||
RANLIB="${TRIPLE}-ranlib"
|
||||
;;
|
||||
|
||||
windows)
|
||||
|
@ -288,7 +300,7 @@ function use_toolchain() {
|
|||
|
||||
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 CXX=\"${CXX}\""
|
||||
echo "export RANLIB=\"${RANLIB}\""
|
||||
|
@ -372,7 +384,7 @@ if [[ ${HELP} -eq 1 ]]; then
|
|||
Kangaroo Punch Toolchain Installer
|
||||
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:
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue