Windows, Mac, Linux, and GS targets are installing and generating JoeyLib binaries.

This commit is contained in:
Scott Duensing 2022-12-31 19:54:13 -06:00
parent 418d561995
commit f288e87b37
8 changed files with 397 additions and 83 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
.idea/
packages/
stuff/
towel/

View file

@ -1,3 +1,8 @@
#!/bin/bash
# All paths in this file must be relative to
# the home directory of the build user.
# Required for All.
AUTOMATED_SUDO=

73
helpers/SDL2.helper Normal file
View file

@ -0,0 +1,73 @@
#!/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.
#
function buildJoeyLibSDL2() {
rm -rf ${G_DIST}
mkdir -p ${G_DIST}
pushd ${G_DIST}
${CC} ${CFLAGS} -o jPixBuf.o ${G_SRC}/jPixBuf.c
${CC} ${CFLAGS} -o jSDL2.o ${G_SRC}/jSDL2.c
${CC} ${CFLAGS} -o joey.o ${G_SRC}/joey.c
${AR} x ${G_INSTALLED}/lib/libSDL2.a
${AR} x ${G_INSTALLED}/lib/libSDL2main.a
${AR} rcs libjoeylib.a *.o
rm *.o
[[ -f __.SYMDEF ]] && rm __.SYMDEF*
popd
}
function buildSDL2() {
local TAG=$1
local TRIPLE=$2
if [[ ! -d SDL ]]; then
git clone https://skunkworks.kangaroopunch.com/mirrors/SDL.git
fi
pushd SDL
git checkout ${TAG}
popd
rm -rf build || true
mkdir -p build
pushd build
../SDL/configure \
--target=${TRIPLE} \
--host=${TRIPLE} \
--build=x86_64-linux \
--enable-static \
--disable-shared \
--disable-video-wayland \
--disable-render-metal \
--disable-video-metal \
--prefix=${G_INSTALLED} 1>&2
make 1>&2
make install 1>&2
popd
}

View file

@ -32,6 +32,7 @@ G_SRC="${G_EHOME}/joeylib/joeylib/src" # Location of JoeyLib sour
G_TEMP="${G_EHOME}/temp" # Directory to store temporary data.
G_TITLE="JoeyBuild" # Title of application.
G_ORIGINAL_PATH=${PATH} # Original system path.
G_TARGET= # Current target.
function addBuildUser() {
@ -40,7 +41,7 @@ function addBuildUser() {
local SALT=$(LC_ALL=C tr -cd "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" < /dev/urandom | head -c 8)
local CRYPT=$(perl -e 'print crypt($ARGV[0], $ARGV[1])' ${PASS} ${SALT})
tSudo useradd -m -G sftponly -s /sbin/false -p "${CRYPT}" "${USER}"e
tSudo useradd -m -G sftponly -s /sbin/false -p "${CRYPT}" "${USER}"
tSudo chown root:root /home/${USER}
tSudo chmod 755 /home/${USER}
tSudo mkdir -p /home/${USER}/build
@ -57,7 +58,9 @@ function call() {
local _ARGS=${*:4}
local _VALUE=
G_TARGET=${_MODULE}
_VALUE="$( source ${G_EHOME}/targets/${_MODULE}.target && ${_FUNCTION} ${_ARGS} )"
G_TARGET=
eval $_RESULT=\${_VALUE}
}
@ -92,21 +95,13 @@ function doBuild() {
function doInstall() {
# Do we have an automation file?
if [[ ! -f "${G_EHOME}/automated.install" ]]; then
tBoldBox tRED "Cannot find automated.install file!"
exit 1
fi
source "${G_EHOME}/automated.install"
tSudoSetPassword "${AUTOMATED_SUDO}"
git config --global user.email "no-reply@kangaroopunch.com"
git config --global user.name "JoeyBuild VM Installer"
updateSystem
configureSFTP
withTargets install
withTargets install "Installing SDK"
rebuildJoeyLib
@ -120,12 +115,6 @@ function doInstall() {
function rebuildJoeyLib() {
local TARGET=
local RESULT=
local NAME=
local ARCHS=
local ARCH=
local PASS=
# Do we have JoeyLib yet?
if [[ ! -f ${G_EHOME}/joeylib/LICENSE ]]; then
@ -133,30 +122,7 @@ function rebuildJoeyLib() {
git clone https://skunkworks.kangaroopunch.com/skunkworks/joeylib.git ${G_EHOME}/joeylib &> /dev/null
fi
for TARGET in ${G_EHOME}/targets/*.target; do
NAME=$(basename -s .target ${TARGET})
call RESULT ${NAME} enabled
if [[ ${RESULT} -eq 1 ]]; then
call ARCHS ${NAME} architectures
for ARCH in ${ARCHS}; do
rm -rf dist/${NAME}-${ARCH} || true
for PASS in "debug" "release"; do
tBoldBox tPURPLE "Building JoeyLib ${NAME} ${ARCH} (${PASS})..."
mkdir -p dist/${NAME}-${ARCH}/${PASS}
pushd dist/${NAME}-${ARCH}/${PASS}
call RESULT ${NAME} buildJoeyLib ${ARCH} ${PASS}
popd
done
done
fi
done
withTargets buildJoeyLib "Building JoeyLib"
cp -f ${G_SRC}/joey.h dist/.
mkdir -p dist/3rdparty/memwatch
@ -193,6 +159,14 @@ function startup() {
exit 1
fi
# Do we have an automation file?
if [[ ! -f "${G_EHOME}/automated.install" ]]; then
tBoldBox tRED "Cannot find automated.install file!"
exit 1
fi
source "${G_EHOME}/automated.install"
tSudoSetPassword "${AUTOMATED_SUDO}"
# Be sure we can silently sudo. (for mountORCA)
tSudo
@ -250,6 +224,9 @@ function updateSystem() {
tSudo apt -y upgrade
tSudo apt -y dist-upgrade
# Shut Canonical up.
tSudo pro config set apt_news=false
#***TODO*** Split this into target modules.
tSudo dpkg --add-architecture i386
@ -296,7 +273,9 @@ function updateSystem() {
function withTargets() {
local FUNCTION=$1
local ARGS=${*:2}
local ACTION="$2"
local ARGS=${*:3}
local PASS=
local TARGET=
local RESULT=
local NAME=
@ -309,7 +288,16 @@ function withTargets() {
if [[ ${RESULT} -eq 1 ]]; then
call ARCHS ${NAME} architectures
for ARCH in ${ARCHS}; do
call RESULT ${NAME} ${FUNCTION} ${ARCH} ${ARGS}
for PASS in "debug" "release"; do
tBoldBox tPURPLE "${ACTION} ${NAME} ${ARCH} (${PASS})..."
G_TARGET=${NAME}
G_INSTALLED=${G_EHOME}/installed/${NAME}-${ARCH}/${PASS}
G_DIST=dist/${G_TARGET}-${ARCH}/${PASS}
call RESULT ${NAME} ${FUNCTION} ${ARCH} ${PASS} ${ARGS}
G_DIST=
G_INSTALLED=
G_TARGET=
done
done
fi
done

View file

@ -1,3 +1,5 @@
#!/bin/bash
#
# JoeyBuild
# Copyright (C) 2018-2023 Scott Duensing <scott@kangaroopunch.com>
@ -33,6 +35,9 @@ function architectures() {
function buildApplication() {
local ARCH=$1
local PASS=$2
true
}
@ -42,53 +47,63 @@ function buildJoeyLib() {
local PASS=$2
local OUT=${GOLDEN_GATE}/out/joey
export PATH=${G_ORIGINAL_PATH}:${M_IIGS}
"${M_IIGS}/mountORCA.sh"
rm -rf ${G_DIST}
mkdir -p ${G_DIST}
pushd ${G_DIST}
rm -rf ${OUT} || true
mkdir -p ${OUT}
export PATH=${G_ORIGINAL_PATH}:${M_IIGS}
"${M_IIGS}/mountORCA.sh"
pushd ${G_SRC}
if [[ "${PASS}" == "debug" ]]; then
# Add JOEY_DEBUG flag.
cp joey.h joey.h.original
sed -i "1i #define JOEY_DEBUG" joey.h
fi
rm -rf ${OUT} || true
mkdir -p ${OUT}
iix assemble jIIgs.asm keep=31:/out/joey/jIIgsasm
iix compile jIIgs.c keep=31:/out/joey/jIIgsc
iix compile joey.c keep=31:/out/joey/joey
pushd ${G_SRC}
if [[ "${PASS}" == "debug" ]]; then
# Add JOEY_DEBUG flag.
cp joey.h joey.h.original
sed -i "1i #define JOEY_DEBUG" joey.h
fi
iix assemble jIIgs.asm keep=31:/out/joey/jIIgsasm 1>&2
iix compile jIIgs.c keep=31:/out/joey/jIIgsc 1>&2
iix compile joey.c keep=31:/out/joey/joey 1>&2
if [[ "${PASS}" == "debug" ]]; then
# Remove JOEY_DEBUG.
rm joey.h
mv joey.h.original joey.h
fi
popd
cp -f "${OUT}/jIIgsc.root" "jIIgsc.root#b10000"
cp -f "${OUT}/jIIgsc.a" "jIIgsc.a#b10000"
cp -f "${OUT}/jIIgsasm.root" "jIIgsasm.root#b10000"
cp -f "${OUT}/jIIgsasm.a" "jIIgsasm.a#b10000"
cp -f "${OUT}/joey.a" "joey.a#b10000"
cp -f "${M_IIGS}/Tool222#ba0000" .
"${M_IIGS}/unmountORCA.sh"
export PATH=${G_ORIGINAL_PATH}
if [[ "${PASS}" == "debug" ]]; then
# Remove JOEY_DEBUG.
rm joey.h
mv joey.h.original joey.h
fi
popd
cp -f "${OUT}/jIIgsc.root" "jIIgsc.root#b10000"
cp -f "${OUT}/jIIgsc.a" "jIIgsc.a#b10000"
cp -f "${OUT}/jIIgsasm.root" "jIIgsasm.root#b10000"
cp -f "${OUT}/jIIgsasm.a" "jIIgsasm.a#b10000"
cp -f "${OUT}/joey.a" "joey.a#b10000"
cp -f "${M_IIGS}/Tool222#ba0000" .
"${M_IIGS}/unmountORCA.sh"
export PATH=${G_ORIGINAL_PATH}
}
function enabled() {
echo 1
echo 0
}
function install() {
local ARCH=$1
local PASS=$2
local RESULT=
local O=
tBoldBox tPURPLE "Installing IIgs ${ARCH}"
# We only need to do this once, so we ignore the debug pass.
if [[ "${PASS}" == "debug" ]]; then
return
fi
mkdir -p "${M_IIGS}/ORCA"
chmod 777 "${M_IIGS}/ORCA"
@ -145,9 +160,9 @@ function install() {
git submodule update
mkdir -p build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$(pwd)/installed ..
make
make install
cmake -DCMAKE_INSTALL_PREFIX=$(pwd)/installed .. 1>&2
make 1>&2
make install 1>&2
mkdir -p ${M_IIGS}
cp -f bin/{iix,dumpobj,opus-extractor} "${M_IIGS}/."
cd installed
@ -193,7 +208,7 @@ function install() {
if [[ ! -d cadius ]]; then
git clone https://skunkworks.kangaroopunch.com/mirrors/cadius.git
pushd cadius
make
make 1>&2
mkdir -p "${M_IIGS}/cadius"
cp -f bin/release/cadius "${M_IIGS}/cadius/."
popd

83
targets/Linux.target Normal file
View file

@ -0,0 +1,83 @@
#!/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_SDL2_TAG=97a5e744497ff7cc93edc5119d67cad3ee86dd57
M_TRIPLE="x86_64-linux-gnu"
function architectures() {
echo "i386 x86_64"
}
function buildApplication() {
local ARCH=$1
local PASS=$2
true
}
function buildJoeyLib() {
local ARCH=$1
local PASS=$2
export CFLAGS="-Wall -static-libgcc -D_REENTRANT_ -I${G_INSTALLED}/include -c"
export LDFLAGS="-lm -ldl -lpthread"
if [[ "${ARCH}" == "i386" ]]; then
export CFLAGS="-m32 ${CFLAGS}"
fi
if [[ "${PASS}" == "debug" ]]; then
export CFLAGS="-DJOEY_DEBUG ${CFLAGS}"
fi
source helpers/SDL2.helper
buildJoeyLibSDL2
export LDFLAGS=
export CFLAGS=
}
function enabled() {
echo 0
}
function install() {
local ARCH=$1
local PASS=$2
if [[ "${ARCH}" == "i386" ]]; then
export CFLAGS="-m32"
fi
source helpers/SDL2.helper
buildSDL2 ${M_SDL2_TAG} ${M_TRIPLE}
export CFLAGS=
}

View file

@ -1,3 +1,5 @@
#!/bin/bash
#
# JoeyBuild
# Copyright (C) 2018-2023 Scott Duensing <scott@kangaroopunch.com>
@ -20,18 +22,66 @@
#
M_TRIPLE=
function architectures() {
echo "x86 x86_64 M1"
echo "i386 x86_64 aarch64"
}
function buildApplication() {
local ARCH=$1
local PASS=$2
true
}
function buildJoeyLib() {
true
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}
source helpers/SDL2.helper
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
}
@ -42,6 +92,53 @@ function enabled() {
function install() {
local ARCH=$1
local PASS=$2
tBoldBox tPURPLE "Installing MacOS ${ARCH}"
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}
source helpers/SDL2.helper
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}
}

View file

@ -1,3 +1,5 @@
#!/bin/bash
#
# JoeyBuild
# Copyright (C) 2018-2023 Scott Duensing <scott@kangaroopunch.com>
@ -20,28 +22,78 @@
#
M_SDL2_TAG=97a5e744497ff7cc93edc5119d67cad3ee86dd57
M_TRIPLE=
function architectures() {
echo "x86 x86_64"
echo "i686 x86_64"
}
function buildApplication() {
local ARCH=$1
local PASS=$2
# LDFIRST="-lmingw32"
true
}
function buildJoeyLib() {
true
local ARCH=$1
local PASS=$2
export CFLAGS="-Dmain=SDL_main -Wall -static-libgcc -I${G_SRC} -I${G_INSTALLED}/include -c"
export LDFLAGS="-mwindows -Wl,--dynamicbase -Wl,--nxcompat -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid"
if [[ "${PASS}" == "debug" ]]; then
export CFLAGS="-DJOEY_DEBUG ${CFLAGS}"
fi
setCompiler ${ARCH} ${PASS}
source helpers/SDL2.helper
buildJoeyLibSDL2 ${M_TRIPLE}
unSetCompiler
}
function enabled() {
echo 1
echo 0
}
function install() {
local ARCH=$1
local PASS=$2
tBoldBox tPURPLE "Installing Windows ${ARCH}"
setCompiler ${ARCH} ${PASS}
source helpers/SDL2.helper
buildSDL2 ${M_SDL2_TAG} ${M_TRIPLE}
unSetCompiler
}
function setCompiler() {
local ARCH=$1
local PASS=$2
M_TRIPLE="${ARCH}-w64-mingw32"
export CC=${M_TRIPLE}-gcc
export LD=${M_TRIPLE}-gcc
export AR=${M_TRIPLE}-ar
}
function unSetCompiler() {
export CC=
export LD=
export AR=
export LDFLAGS=
export CFLAGS=
export LD_LIBRARY_PATH=
export PATH=${G_ORIGINAL_PATH}
}