"use" mode now echos the needed settings instead of actually setting them.

This commit is contained in:
Scott Duensing 2023-11-13 17:31:02 -06:00
parent e89cdf12e8
commit 31e5646091

View file

@ -25,7 +25,9 @@
#
PIURL=https://github.com/tttapa/docker-arm-cross-toolchain/releases/latest/download/x-tools-
G_SCRIPT=$0
G_BUILDROOT=${PWD}
G_PIURL=https://github.com/tttapa/docker-arm-cross-toolchain/releases/latest/download/x-tools-
function buildMacOSXToolchain() {
@ -141,35 +143,47 @@ function install_x86_64_windows() {
}
function install_x86_windows() {
# x86 Windows.
install_x86_64_windows
}
function install_aarch64_pi() {
# Raspberry Pi, aarch64.
wget -O- ${PIURL}aarch64-rpi3-linux-gnu.tar.xz | tar xJ
wget -O- ${G_PIURL}aarch64-rpi3-linux-gnu.tar.xz | tar xJ
#***TODO*** sysroot
}
function install_armv6_pi() {
# Raspberry Pi, armv6.
wget -O- ${PIURL}armv6-rpi-linux-gnueabihf.tar.xz | tar xJ
wget -O- ${G_PIURL}armv6-rpi-linux-gnueabihf.tar.xz | tar xJ
#***TODO*** sysroot
}
function install_armv8_pi() {
# Raspberry Pi, armv8.
wget -O- ${PIURL}armv8-rpi3-linux-gnueabihf.tar.xz | tar xJ
wget -O- ${G_PIURL}armv8-rpi3-linux-gnueabihf.tar.xz | tar xJ
#***TODO*** sysroot
}
function install_x86_64_macos() {
# MacOS x86, x86_64.
# MacOS x86_64.
#***TODO*** https://stackoverflow.com/questions/67712376/after-updating-gcc-clang-cant-find-libstdc-anymore
buildMacOSXToolchain MacOSX10.13.sdk.tar.xz Xcode_9.4.1.xip x86_64-macos-apple
}
function install_x86_macos() {
# MacOS x86.
install_x86_64_macos
}
function install_aarch64_macos() {
# MacOS aarch64.
#***TODO*** https://stackoverflow.com/questions/67712376/after-updating-gcc-clang-cant-find-libstdc-anymore
@ -195,6 +209,95 @@ function install_x86_dos() {
}
function use_toolchain() {
local ARCH=$1
local PLAT=$2
case "${PLAT}" in
linux)
case "${ARCH}" in
x86)
TRIPLE="i686-linux-gnu"
;;
x86_64)
TRIPLE="x86_64-linux-gnu"
;;
esac
CROSS_OS="linux"
CC="${TRIPLE}-gcc"
CXX="${TRIPLE}-g++"
RANLIB="${TRIPLE}-ranlib"
;;
macos)
case "${ARCH}" in
aarch64)
TRIPLE="aarch64-apple-darwin22.4"
OSXCROSS_LOCATION=${G_BUILDROOT}/x-tools/aarch64-macos-apple
;;
x86)
TRIPLE="i386-apple-darwin17"
OSXCROSS_LOCATION=${G_BUILDROOT}/x-tools/x86_64-macos-apple
;;
x86_64)
TRIPLE="x86_64-apple-darwin17"
OSXCROSS_LOCATION=${G_BUILDROOT}/x-tools/x86_64-macos-apple
;;
esac
CROSS_OS="darwin"
CC="${OSXCROSS_LOCATION}/bin/${TRIPLE}-clang"
CXX="${OSXCROSS_LOCATION}/bin/${TRIPLE}-clang++"
RANLIB="${OSXCROSS_LOCATION}/bin/${TRIPLE}-ranlib"
"${OSXCROSS_LOCATION}/bin/osxcross-conf" 2>/dev/null
echo "export OSXCROSS_LOCATION=\"${OSXCROSS_LOCATION}\""
echo "export LDFLAGS=\"-fuse-ld=${OSXCROSS_LOCATION}/bin/${TRIPLE}-ld\""
echo "export PATH=\"${OSXCROSS_LOCATION}/bin:${PATH}\""
echo "export OSXCROSS_PKG_CONFIG_USE_NATIVE_VARIABLES=1"
;;
pi)
case "${ARCH}" in
aarch64)
TRIPLE="aarch64-rpi3-linux-gnu"
;;
armv6)
TRIPLE="armv6-rpi-linux-gnueabihf"
;;
armv8)
TRIPLE="armv8-rpi3-linux-gnueabihf"
;;
esac
;;
windows)
case "${ARCH}" in
x86)
TRIPLE="i686-w64-mingw32"
;;
x86_64)
TRIPLE="x86_64-w64-mingw32"
;;
esac
CC="${TRIPLE}-gcc-posix"
CXX="${TRIPLE}-g++-posix"
RANLIB="${TRIPLE}-ranlib"
SUFFIX=".exe"
CROSS_OS="mingw32"
;;
esac
echo "export TOOLCHAIN_FILE=\"${G_BUILDROOT}/cmake/${TRIPLE}.cmake\""
echo "export CC=\"${CC}\""
echo "export CXX=\"${CXX}\""
echo "export RANLIB=\"${RANLIB}\""
echo "export SUFFIX=\"${SUFFIX}\""
echo "export CROSS_OS=\"${CROSS_OS}\""
echo "export TRIPLE=\"${TRIPLE}\""
}
MODE=$1
ARCH=$2
PLAT=$3
@ -202,18 +305,20 @@ PLAT=$3
HELP=1
COLS=2
ROWS=9
ROWS=11
row=0
declare -A PLATFORMS=()
PLATFORMS[0]="x86_64"; PLATFORMS[1]="linux"
PLATFORMS[2]="x86"; PLATFORMS[3]="linux"
PLATFORMS[4]="x86_64"; PLATFORMS[5]="windows"
PLATFORMS[6]="aarch64"; PLATFORMS[7]="pi"
PLATFORMS[8]="armv6"; PLATFORMS[9]="pi"
PLATFORMS[10]="armv8"; PLATFORMS[11]="pi"
PLATFORMS[12]="x86_64"; PLATFORMS[13]="macos"
PLATFORMS[14]="aarch64"; PLATFORMS[15]="macos"
PLATFORMS[16]="x86"; PLATFORMS[17]="dos"
PLATFORMS[6]="x86"; PLATFORMS[7]="windows"
PLATFORMS[8]="aarch64"; PLATFORMS[9]="pi"
PLATFORMS[10]="armv6"; PLATFORMS[11]="pi"
PLATFORMS[12]="armv8"; PLATFORMS[13]="pi"
PLATFORMS[14]="x86_64"; PLATFORMS[15]="macos"
PLATFORMS[16]="x86"; PLATFORMS[17]="macos"
PLATFORMS[18]="aarch64"; PLATFORMS[19]="macos"
PLATFORMS[20]="x86"; PLATFORMS[21]="dos"
if [[ "${MODE}" == "install" ]]; then
# Install all toolchains.
@ -255,9 +360,7 @@ if [[ "${MODE}" == "use" ]]; then
for (( row=0; row<ROWS; row++ )); do
if [[ "${ARCH}" == "${PLATFORMS[$((${COLS}*${row}))]}" && "${PLAT}" == "${PLATFORMS[$((${COLS}*${row}+1))]}" ]]; then
HELP=0
set -x
#use_${ARCH}_${PLAT}
set +x
use_toolchain ${ARCH} ${PLAT}
fi
done
fi
@ -269,7 +372,7 @@ if [[ ${HELP} -eq 1 ]]; then
Kangaroo Punch Toolchain Installer
http://skunkworks.kangaroopunch.com
Usage: $0 install [architecture] [platform]
Usage: ${G_SCRIPT} [install|use] [architecture] [platform]
Where [architecture] and [platform] are one of:
@ -279,16 +382,24 @@ if [[ ${HELP} -eq 1 ]]; then
done
cat <<-HELP
If [architecture] and [platform] are both "all",
everything will be installed.
For "install" mode:
if [architecture] is "all", then all available
architectures for the specified [platform] will
be installed.
If [architecture] and [platform] are both "all",
everything will be installed.
NOTE: You should always install x86_64 linux
before attempting to install other
toolchains.
if [architecture] is "all", then all available
architectures for the specified [platform] will
be installed.
NOTE: You should always install x86_64 linux
before attempting to install other
toolchains.
For "use" mode:
Souce the output of this script to set the environment
to use the appropriate toolchain for [architecture] and
[platform].
HELP
fi