joeybuild/targets/MacOS.target

145 lines
3.4 KiB
Bash

#!/bin/bash
#
# JoeyBuild
# Copyright (C) 2018-2023 Scott Duensing <scott@kangaroopunch.com>
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
#
M_TRIPLE=
source helpers/SDL2.helper
function architectures() {
echo "i386 x86_64 aarch64"
}
function buildApplication() {
local ARCH=$1
local PASS=$2
true
}
function buildJoeyLib() {
local ARCH=$1
local PASS=$2
export CFLAGS="-Wall -D_REENTRANT_ -I${G_INSTALLED}/include -c"
export LDFLAGS="-lm -ldl -lpthread"
if [[ "${PASS}" == "debug" ]]; then
export CFLAGS="-DJOEY_DEBUG ${CFLAGS}"
fi
setCompiler ${ARCH} ${PASS}
buildJoeyLibSDL2
unSetCompiler
}
function buildMacOSXToolchain() {
local SDK=$1
local XCODE=$2
local PLATFORM=$3
if [[ ! -d osxcross ]]; then
git clone https://skunkworks.kangaroopunch.com/mirrors/osxcross.git
fi
pushd osxcross
# Do we have an existing SDK tarball?
if [[ ! -f "../${SDK}" ]]; then
# Nope. Build tarball and keep for later.
./tools/gen_sdk_package_pbzx.sh "../${XCODE}"
mv -f MacOSX* ../.
fi
cp -f "../${SDK}" tarballs/.
if [[ ! -f ../cross/${PLATFORM}/toolchain.cmake ]]; then
UNATTENDED=1 ./build.sh
tSudo ENABLE_COMPILER_RT_INSTALL=1 ./build_compiler_rt.sh
mkdir -p ../cross/${PLATFORM}
mv -f target/* ../cross/${PLATFORM}
tSudo mv -f /usr/lib/llvm-10/lib/clang/10.0.0/lib/darwin ../cross/${PLATFORM}/.
./cleanup.sh
fi
popd
}
function enabled() {
echo 0
}
function install() {
local ARCH=$1
local PASS=$2
if [[ "${ARCH}" == "aarch64" ]]; then
buildMacOSXToolchain "${AUTOMATED_MACOS_SDK_11_3}" "${AUTOMATED_XCODE_12_5_1_XIP}" macos-apple
SDL2_TAG=97a5e744497ff7cc93edc5119d67cad3ee86dd57
else
buildMacOSXToolchain "${AUTOMATED_MACOS_SDK_10_13}" "${AUTOMATED_XCODE_9_4_1_XIP}" macos-intel
SDL2_TAG=25f9ed87ff6947d9576fc9d79dee0784e638ac58
fi
setCompiler ${ARCH} ${PASS}
buildSDL2 ${SDL2_TAG} ${M_TRIPLE}
unSetCompiler
}
function setCompiler() {
local ARCH=$1
local PASS=$2
local CROSS=
if [[ "${ARCH}" == "aarch64" ]]; then
M_TRIPLE="${ARCH}-apple-darwin20.4"
CROSS=macos-apple
else
M_TRIPLE="${ARCH}-apple-darwin17"
CROSS=macos-intel
fi
export PATH=${G_EHOME}/cross/${CROSS}/bin:${G_ORIGINAL_PATH}
export LD_LIBRARY_PATH=${G_EHOME}/cross/${CROSS}/lib
sudo rm -f /usr/lib/llvm-10/lib/clang/10.0.0/lib/darwin || true
sudo ln -s ${G_EHOME}/cross/${CROSS}/darwin /usr/lib/llvm-10/lib/clang/10.0.0/lib/.
export CC=${M_TRIPLE}-clang
export LD=${M_TRIPLE}-c++
export AR=${M_TRIPLE}-ar
}
function unSetCompiler() {
export CC=
export LD=
export AR=
export LD_LIBRARY_PATH=
export PATH=${G_ORIGINAL_PATH}
}