diff --git a/toolchains.sh b/toolchains.sh index 6b73103..4472a3f 100755 --- a/toolchains.sh +++ b/toolchains.sh @@ -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