From bbea7b77b335b103f865cedbf7c492256ef1cad0 Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Wed, 18 Jan 2023 15:16:51 -0600 Subject: [PATCH] Installer and all builds working! User management, rebuild, and build commands working. Server startup is having issues. --- .gitignore | 2 +- automated.install.sample | 23 ---------- buildTest.sh | 4 +- helpers/GCC.helper | 11 ++--- helpers/SDL2.helper | 7 ++- joeybuild.config.sample | 23 ++++++++++ joeybuild.sh | 33 +++++++------- targets/IIgs.target | 12 +++--- targets/Linux.target | 6 +-- targets/MacOS.target | 93 +++++++++++++++++++++++++++------------- targets/Windows.target | 30 ++++++++++--- 11 files changed, 148 insertions(+), 96 deletions(-) delete mode 100644 automated.install.sample create mode 100644 joeybuild.config.sample diff --git a/.gitignore b/.gitignore index 232dd4e..1847749 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,5 @@ temp/ old/ *~ -automated.install +joeybuild.config updateVM.sh diff --git a/automated.install.sample b/automated.install.sample deleted file mode 100644 index 8dfc769..0000000 --- a/automated.install.sample +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -# All paths in this file must be relative to -# the home directory of the build user. - -# Required for All. -AUTOMATED_SUDO= - -# Required for IIgs. -AUTOMATED_OPUS_SOFTWARE_ISO="Opus ][ The Software.iso" -AUTOMATED_GOLDEN_GATE_MSI="Golden Gate.msi" -AUTOMATED_GOLDEN_GATE_PRIVATE_KEY=id_rsa -AUTOMATED_GOLDEN_GATE_PUBLIC_KEY=id_rsa.pub -AUTOMATED_GOLDEN_GATE_USER_NAME= -AUTOMATED_GOLDEN_GATE_PASSWORD= - -# Required for MacOS. Fill in either the SDK or XCODE entries. -# Using SDK archives takes much longer. -# (But will generate XCODE archives for you for next time!) -AUTOMATED_MACOS_SDK_10_13=MacOSX10.13.sdk.tar.xz -AUTOMATED_MACOS_SDK_11_3=MacOSX11.3.sdk.tar.xz -AUTOMATED_XCODE_9_4_1_XIP=Xcode_9.4.1.xip -AUTOMATED_XCODE_12_5_1_XIP=Xcode_12.5.1.xip diff --git a/buildTest.sh b/buildTest.sh index 0133a4a..a525c36 100644 --- a/buildTest.sh +++ b/buildTest.sh @@ -1,9 +1,9 @@ #!/bin/bash -source automated.install +source joeybuild.config source towel/towel.sh -tSudoSetPassword "${AUTOMATED_SUDO}" +tSudoSetPassword "${CONFIG_SUDO}" tArgsHandler $@ [[ -d /home/test/build ]] && tSudo rm -rf /home/test/build diff --git a/helpers/GCC.helper b/helpers/GCC.helper index a27257d..e512e90 100644 --- a/helpers/GCC.helper +++ b/helpers/GCC.helper @@ -36,7 +36,7 @@ function assembleGCC() { O=${G_TEMP}/${FILE%.*} OFILES="${OFILES} ${O}" # as - #gcc -static -nostdlib -nostartfiles ${FILE} -o ${O} + #gcc -v -static -nostdlib -nostartfiles ${FILE} -o ${O} >> ${LOG} 2>&1 done echo ${OFILES} @@ -59,7 +59,7 @@ function compileGCC() { for FILE in "${CFILES[@]}"; do O=${G_TEMP}/$(basename ${FILE%.*}).o OFILES="${OFILES} ${O}" - ${CC} ${CFLAGS} -c ${FILE} -o ${O} + ${CC} -v ${CFLAGS} -c ${FILE} -o ${O} >> ${LOG} 2>&1 done echo ${OFILES} @@ -71,14 +71,15 @@ function linkGCC() { local ARCH=$2 local PASS=$3 local EXT=$4 - local LOG=$5 - local OFILES=(${*:6}) + local LINKFIRST=$5 + local LOG=$6 + local OFILES=(${*:7}) local LIB="${G_EHOME}/dist/${OS}-${ARCH}/${PASS}" local DIR=${G_BUILD_RESULTS}/${OS}-${ARCH}/${PASS} mkdir -p ${DIR} - ${LD} ${CFLAGS} -o ${DIR}/${G_BUILD_PROJECT}${EXT} ${OFILES[@]} ${LIB}/libjoeylib.a ${LDFLAGS} + ${LD} -v ${CFLAGS} -o ${DIR}/${G_BUILD_PROJECT}${EXT} ${LINKFIRST} ${OFILES[@]} ${LIB}/libjoeylib.a ${LDFLAGS} >> ${LOG} 2>&1 } diff --git a/helpers/SDL2.helper b/helpers/SDL2.helper index 9c6a28f..87917cc 100644 --- a/helpers/SDL2.helper +++ b/helpers/SDL2.helper @@ -50,10 +50,13 @@ function buildSDL2() { local TAG=$1 local TRIPLE=$2 - if [[ ! -d SDL ]]; then - git clone https://skunkworks.kangaroopunch.com/mirrors/SDL.git + if [[ ! -d SDL_Clean ]]; then + git clone https://skunkworks.kangaroopunch.com/mirrors/SDL.git SDL_Clean fi + rm -rf SDL || true + cp -R SDL_Clean SDL + pushd SDL git checkout ${TAG} popd diff --git a/joeybuild.config.sample b/joeybuild.config.sample new file mode 100644 index 0000000..ac73409 --- /dev/null +++ b/joeybuild.config.sample @@ -0,0 +1,23 @@ +#!/bin/bash + +# All paths in this file must be relative to +# the home directory of the build user. + +# Required for All. +CONFIG_SUDO= + +# Required for IIgs. +CONFIG_OPUS_SOFTWARE_ISO="Opus ][ The Software.iso" +CONFIG_GOLDEN_GATE_MSI="Golden Gate.msi" +CONFIG_GOLDEN_GATE_PRIVATE_KEY=id_rsa +CONFIG_GOLDEN_GATE_PUBLIC_KEY=id_rsa.pub +CONFIG_GOLDEN_GATE_USER_NAME= +CONFIG_GOLDEN_GATE_PASSWORD= + +# Required for MacOS. Fill in either the SDK or XCODE entries. +# Using SDK archives takes much longer. +# (But will generate XCODE archives for you for next time!) +CONFIG_MACOS_SDK_10_13=MacOSX10.13.sdk.tar.xz +CONFIG_MACOS_SDK_11_3=MacOSX11.3.sdk.tar.xz +CONFIG_XCODE_9_4_1_XIP=Xcode_9.4.1.xip +CONFIG_XCODE_12_5_1_XIP=Xcode_12.5.1.xip diff --git a/joeybuild.sh b/joeybuild.sh index 4881e97..3e17a07 100755 --- a/joeybuild.sh +++ b/joeybuild.sh @@ -1,4 +1,4 @@ -#!/bin/bash -e +#!/bin/bash -ex # # JoeyBuild @@ -206,6 +206,7 @@ function doBuild() { done < build.start # Compress the results. + tBoldBox tPURPLE "Packaging \"${G_BUILD_PROJECT}\"..." tar cJf build.temp results tSudo chown ${USERNAME}:${USERNAME} build.temp @@ -250,8 +251,7 @@ function doInstall() { # Start build server on reboot. if [[ ! -f /etc/rc.local ]]; then echo "#!/bin/bash" | tSudo tee /etc/rc.local > /dev/null - echo "cd ${G_EHOME}" | tSudo tee -a /etc/rc.local > /dev/null - echo "sudo -u $(logname) ${BASH_SOURCE[0]} server &> /dev/null &" | tSudo tee -a /etc/rc.local > /dev/null + echo "sudo -i -u $(logname) ${BASH_SOURCE[0]} server &> /dev/null &" | tSudo tee -a /etc/rc.local > /dev/null echo "exit 0" | tSudo tee -a /etc/rc.local > /dev/null fi } @@ -303,13 +303,13 @@ 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!" + # Do we have a config file? + if [[ ! -f "${G_EHOME}/joeybuild.config" ]]; then + tBoldBox tRED "Cannot find joeybuild.config file!" exit 1 fi - source "${G_EHOME}/automated.install" - tSudoSetPassword "${AUTOMATED_SUDO}" + source "${G_EHOME}/joeybuild.config" + tSudoSetPassword "${CONFIG_SUDO}" # Be sure we can silently sudo. (for mountORCA) tSudo @@ -361,19 +361,16 @@ function startBuildServer() { local ARCHS= local DESCRIPTION= local USERNAME= - local FILE= cd ${G_EHOME} # Log startup. - echo "$(date) - Startup ${0}" >> "${LOG}" - - mkdir -p http + echo "$(date) - Startup ${0}" >> joeybuild.log # Build supported project types and target details for JoeyDev. - echo "1.0" > http/joeydev.info - echo "------------------------------------------------------------------------------" >> http/joeydev.info - echo "project application \"JoeyLib Application\"" >> http/joeydev.info + echo "1.0" > dist/joeydev.info + echo "------------------------------------------------------------------------------" >> dist/joeydev.info + echo "project application \"JoeyLib Application\"" >> dist/joeydev.info # echo "project joeylib \"JoeyLib Itself\"" >> http/joeydev.info for TARGET in ${G_EHOME}/targets/*.target; do NAME=$(basename -s .target ${TARGET}) @@ -381,12 +378,12 @@ function startBuildServer() { if [[ ${RESULT} -eq 1 ]]; then call ARCHS ${NAME} architectures call DESCRIPTION ${NAME} friendlyName - echo "target ${NAME} \"${DESCRIPTION}\" ${ARCHS}" >> http/joeydev.info + echo "target ${NAME} \"${DESCRIPTION}\" ${ARCHS}" >> dist/joeydev.info fi done # Start the PHP web server if it's not already running. - php -S 0.0.0.0:${G_HTTP_PORT} -t http >> joeybuild.log 2>&1 & + php -S 0.0.0.0:${G_HTTP_PORT} -t dist >> joeybuild.log 2>&1 & # Start the actual build server. cd /home @@ -512,4 +509,4 @@ function withTargets() { # At the very end so we can stream this script from a web server. -startup $@ # 2>&1 | tee lastrun.log +startup $@ 2>&1 | tee lastrun.log diff --git a/targets/IIgs.target b/targets/IIgs.target index 91507f8..3f36bbb 100644 --- a/targets/IIgs.target +++ b/targets/IIgs.target @@ -133,7 +133,7 @@ function compile() { function enabled() { - echo 0 + echo 1 } @@ -157,8 +157,8 @@ function install() { chmod 777 "${M_IIGS}/ORCA" mkdir -p ${G_EHOME}/.ssh - cp -f "${AUTOMATED_GOLDEN_GATE_PUBLIC_KEY}" ${G_EHOME}/.ssh/id_rsa.pub - cp -f "${AUTOMATED_GOLDEN_GATE_PRIVATE_KEY}" ${G_EHOME}/.ssh/id_rsa + cp -f "${CONFIG_GOLDEN_GATE_PUBLIC_KEY}" ${G_EHOME}/.ssh/id_rsa.pub + cp -f "${CONFIG_GOLDEN_GATE_PRIVATE_KEY}" ${G_EHOME}/.ssh/id_rsa touch ${G_EHOME}/.ssh/authorized_keys touch ${G_EHOME}/.ssh/known_hosts touch ${G_EHOME}/.ssh/config @@ -199,7 +199,7 @@ function install() { if [[ ! -d GoldenGate ]]; then ssh-keygen -F gitlab.com || ssh-keyscan gitlab.com > ${G_EHOME}/.ssh/known_hosts git config --global credential.helper cache - git clone https://${AUTOMATED_GOLDEN_GATE_USER_NAME}:${AUTOMATED_GOLDEN_GATE_PASSWORD}@gitlab.com/GoldenGate/GoldenGate.git + git clone https://${CONFIG_GOLDEN_GATE_USER_NAME}:${CONFIG_GOLDEN_GATE_PASSWORD}@gitlab.com/GoldenGate/GoldenGate.git fi if [[ ! -f "${M_IIGS}/iix" ]]; then @@ -214,13 +214,13 @@ function install() { mkdir -p ${M_IIGS} cp -f bin/{iix,dumpobj,opus-extractor} "${M_IIGS}/." cd installed - msiextract "${G_EHOME}/${AUTOMATED_GOLDEN_GATE_MSI}" + msiextract "${G_EHOME}/${CONFIG_GOLDEN_GATE_MSI}" find -name ".*" -delete cp -rf GoldenGate/* "${M_IIGS}/ORCA/." popd fi - isoinfo -i "${AUTOMATED_OPUS_SOFTWARE_ISO}" -x /FOR_EMUL/BYTEWORK.S\;1 > BYTEWORKS + isoinfo -i "${CONFIG_OPUS_SOFTWARE_ISO}" -x /FOR_EMUL/BYTEWORK.S\;1 > BYTEWORKS "${M_IIGS}/opus-extractor" -v BYTEWORKS "${M_IIGS}/ORCA" rm BYTEWORKS diff --git a/targets/Linux.target b/targets/Linux.target index ff9aabc..4d787a9 100644 --- a/targets/Linux.target +++ b/targets/Linux.target @@ -74,8 +74,6 @@ function compile() { local LOG=$3 local CFILES=(${*:4}) - setCompiler ${ARCH} ${PASS} - if [[ "${ARCH}" == "i386" ]]; then export CFLAGS="-m32 -Wall -D_REENTRANT_" else @@ -85,8 +83,6 @@ function compile() { setCompiler ${ARCH} ${PASS} compileGCC ${ARCH} ${PASS} ${LOG} "${CFILES[@]}" unSetCompiler - - unSetCompiler } @@ -128,7 +124,7 @@ function link() { export LDFLAGS="-lm -ldl -lpthread" setCompiler ${ARCH} ${PASS} - linkGCC Linux ${ARCH} ${PASS} "" ${LOG} "${OFILES[@]}" + linkGCC Linux ${ARCH} ${PASS} "" "" ${LOG} "${OFILES[@]}" unSetCompiler } diff --git a/targets/MacOS.target b/targets/MacOS.target index ac832f5..181313f 100644 --- a/targets/MacOS.target +++ b/targets/MacOS.target @@ -26,6 +26,7 @@ M_TRIPLE= source ${G_EHOME}/helpers/SDL2.helper +source ${G_EHOME}/helpers/GCC.helper function architectures() { @@ -34,10 +35,14 @@ function architectures() { function assemble() { - local -n AFILES=$1 + local ARCH=$1 local PASS=$2 local LOG=$3 + local AFILES=(${*:4}) + setCompiler ${ARCH} ${PASS} + assembleGCC ${ARCH} ${PASS} ${LOG} "${AFILES[@]}" + unSetCompiler } @@ -67,35 +72,50 @@ function buildMacOSXToolchain() { 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* ../. + if [[ ! -f cross/${PLATFORM}/toolchain.cmake ]]; then + 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* "../${SDK}" + fi + # Put tarball in place. + cp -f "../${SDK}" tarballs/. + # Build SDK. + UNATTENDED=1 ./build.sh + # Build compiler runtime. + if [[ -d /usr/lib/llvm-10/lib/clang/10.0.0/lib/darwin ]]; then + tSudo rm -rf /usr/lib/llvm-10/lib/clang/10.0.0/lib/darwin + fi + tSudo ENABLE_COMPILER_RT_INSTALL=1 ./build_compiler_rt.sh + # Move results into cross compiler location. + 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}/. + # Tidy up for next build. + ./cleanup.sh + rm -f tarballs/* + popd 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 compile() { - local -n CFILES=$1 + local ARCH=$1 local PASS=$2 local LOG=$3 + local CFILES=(${*:4}) + export CFLAGS="-Wall -D_THREAD_SAFE" + + setCompiler ${ARCH} ${PASS} + compileGCC ${ARCH} ${PASS} ${LOG} "${CFILES[@]}" + unSetCompiler } function enabled() { - echo 0 + echo 1 } @@ -108,12 +128,15 @@ 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 + # Debug is the first pass, so build our toolchains then. + if [[ "${PASS}" == "debug" ]]; then + if [[ "${ARCH}" == "aarch64" ]]; then + buildMacOSXToolchain "${CONFIG_MACOS_SDK_11_3}" "${CONFIG_XCODE_12_5_1_XIP}" macos-apple + SDL2_TAG=97a5e744497ff7cc93edc5119d67cad3ee86dd57 + else + buildMacOSXToolchain "${CONFIG_MACOS_SDK_10_13}" "${CONFIG_XCODE_9_4_1_XIP}" macos-intel + SDL2_TAG=25f9ed87ff6947d9576fc9d79dee0784e638ac58 + fi fi setCompiler ${ARCH} ${PASS} @@ -123,18 +146,31 @@ function install() { function link() { - local -n OFILES=$1 + local ARCH=$1 local PASS=$2 local LOG=$3 + local OFILES=(${*:4}) + export CFLAGS="-Wall -D_THREAD_SAFE" + if [[ "${ARCH}" == "aarch64" ]]; then + export LDFLAGS="-lm -liconv -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-weak_framework,CoreHaptics -Wl,-weak_framework,GameController -Wl,-framework,ForceFeedback -lobjc -Wl,-framework,CoreVideo -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,IOKit -Wl,-weak_framework,QuartzCore -Wl,-weak_framework,Metal" + else + export LDFLAGS="-lm -liconv -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,ForceFeedback -lobjc -Wl,-framework,CoreVideo -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,IOKit -Wl,-weak_framework,QuartzCore -Wl,-weak_framework,Metal" + fi + + setCompiler ${ARCH} ${PASS} + linkGCC MacOS ${ARCH} ${PASS} "" "" ${LOG} "${OFILES[@]}" + unSetCompiler } function package() { - local -n DFILES=$1 + local ARCH=$1 local PASS=$2 local LOG=$3 + local DFILES=(${*:4}) + packageGCC MacOS ${ARCH} ${PASS} ${LOG} "${DFILES[@]}" } @@ -154,8 +190,7 @@ function setCompiler() { 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/. + tSudo ln -sf ${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++ diff --git a/targets/Windows.target b/targets/Windows.target index a2bf92f..1234655 100644 --- a/targets/Windows.target +++ b/targets/Windows.target @@ -27,6 +27,7 @@ M_TRIPLE= source ${G_EHOME}/helpers/SDL2.helper +source ${G_EHOME}/helpers/GCC.helper function architectures() { @@ -35,10 +36,14 @@ function architectures() { function assemble() { - local -n AFILES=$1 + local ARCH=$1 local PASS=$2 local LOG=$3 + local AFILES=(${*:4}) + setCompiler ${ARCH} ${PASS} + assembleGCC ${ARCH} ${PASS} ${LOG} "${AFILES[@]}" + unSetCompiler } @@ -60,14 +65,20 @@ function buildJoeyLib() { function compile() { - local -n CFILES=$1 + local ARCH=$1 local PASS=$2 local LOG=$3 + local CFILES=(${*:4}) + export CFLAGS="-Dmain=SDL_main -Wall -static-libgcc" + + setCompiler ${ARCH} ${PASS} + compileGCC ${ARCH} ${PASS} ${LOG} "${CFILES[@]}" + unSetCompiler } function enabled() { - echo 0 + echo 1 } @@ -86,18 +97,27 @@ function install() { function link() { - local -n OFILES=$1 + local ARCH=$1 local PASS=$2 local LOG=$3 + local OFILES=(${*:4}) + export CFLAGS="-Dmain=SDL_main -Wall -static-libgcc" + export LDFLAGS="-mwindows -Wl,--dynamicbase -Wl,--nxcompat -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid" + + setCompiler ${ARCH} ${PASS} + linkGCC Windows ${ARCH} ${PASS} ".exe" "-lmingw32" ${LOG} "${OFILES[@]}" + unSetCompiler } function package() { - local -n DFILES=$1 + local ARCH=$1 local PASS=$2 local LOG=$3 + local DFILES=(${*:4}) + packageGCC Windows ${ARCH} ${PASS} ${LOG} "${DFILES[@]}" }