From ccb46f492034c0e45805a64370df17695989c3f8 Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Tue, 10 Jan 2023 20:27:17 -0600 Subject: [PATCH] JoeyDev metadata now being served over HTTP. Support for application building started. --- joeybuild.sh | 188 +++++++++++++++++++++++++++++++++++++++-- targets/IIgs.target | 152 ++++++++++++++++++++++++++++++--- targets/Linux.target | 34 +++++++- targets/MacOS.target | 36 +++++++- targets/Windows.target | 35 +++++++- 5 files changed, 416 insertions(+), 29 deletions(-) diff --git a/joeybuild.sh b/joeybuild.sh index e3af126..b38c054 100755 --- a/joeybuild.sh +++ b/joeybuild.sh @@ -33,6 +33,9 @@ G_TEMP="${G_EHOME}/temp" # Directory to store tempo G_TITLE="JoeyBuild" # Title of application. G_ORIGINAL_PATH=${PATH} # Original system path. G_TARGET= # Current target. +G_BUILD_PROJECT= +G_BUILD_PLATFORMS= +G_BUILD_RESULTS= function addBuildUser() { @@ -90,7 +93,88 @@ function delBuildUser() { function doBuild() { - true + local SOURCE=$1 + local LINE= + local FILE= + local EXTENSION= + local AFILES=() + local CFILES=() + local OFILES=() + local DATA=() + local TEMP= + local TARGET= + local RESULT= + local LOG= + local PASS= + + pushd "${SOURCE}" + + # Are there old results to clean up? + if [[ -f build.finished ]]; then + rm build.finished + fi + if [[ -d results ]]; then + rm -rf results + fi + mkdir -p results + G_BUILD_RESULTS=${SOURCE}/results + + # Read project information. + G_BUILD_PLATFORMS="[" + G_BUILD_PROJECT= + while IFS= read -r LINE; do + # If we don't have a project name, grab it from the first line of the project file and set things up. + if [[ -z ${G_BUILD_PROJECT} ]]; then + G_BUILD_PROJECT=${LINE} + # Generate a list of non-source files. + for FILE in $(ls -1B); do + if [[ -f "${FILE}" ]]; then + if [[ "${FILE}" != "build.start" && "${FILE}" != "build.temp" && "${FILE}" != "build.tar.bz2" ]]; then + EXTENSION="${FILE##*.}" + if [[ "${EXTENSION}" != "c" && "${EXTENSION}" != "h" && "${EXTENSION}" != "asm" && "${EXTENSION}" != "macro" && "${EXTENSION}" != "inc" ]]; then + DATA+=(${FILE}) + fi + fi + fi + done + # Generate a list of C files to compile. + CFILES=($(ls -1 *.c)) + # Generate a list of ASM files to assemble. + AFILES=($(ls -1 *.asm)) + else + # This is for the 2nd and later lines of the project that list which targets to build. + TARGET= + for TEMP in ${LINE}; do + if [[ -z ${TARGET} ]]; then + TARGET=${TEMP} + else + for PASS in "debug" "release"; do + tBoldBox tPURPLE "Building \"${G_BUILD_PROJECT}\" ${TARGET} ${TEMP} (${PASS})..." + G_DIST=dist/${TARGET}-${TEMP}/${PASS} + # We at least tried to build this target. + G_BUILD_PLATFORMS="${G_BUILD_PLATFORMS}${TARGET}.${TEMP}.${PASS} " + # Make sure we have the official JoeyLib header. + cp -f "${G_HOME}/dist/joey.h" . + # Log file. + LOG="${G_BUILD_RESULTS}/build.${TARGET}.${TEMP}.${PASS}" + # Compile C files and generate object list. + call RESULT ${TARGET} ${TEMP} compile CFILES ${PASS} ${LOG} + OFILES=(${RESULT}) + # Assemble ASM files and generate object list. + call RESULT ${TARGET} ${TEMP} assemble AFILES ${PASS} ${LOG} + OFILES+=(${RESULT}) + # Link with JoeyLib. + call RESULT ${TARGET} ${TEMP} link OFILES ${PASS} ${LOG} + # Process game data files. + call RESULT ${TARGET} ${TEMP} package DATA ${PASS} ${LOG} + done + fi + done + fi + done + + tTrim TEMP "${G_BUILD_PLATFORMS}" + G_BUILD_PLATFORMS="${TEMP}]" } @@ -108,7 +192,8 @@ function doInstall() { # Start build server on reboot. if [[ ! -f /etc/rc.local ]]; then echo "#!/bin/bash" | tSudo tee /etc/rc.local > /dev/null - echo "${BASH_SOURCE[0]} server ${G_EHOME}/dist ${G_EHOME}/builds.log &> /dev/null &" | tSudo tee -a /etc/rc.local > /dev/null + echo "cd ${G_HOME}" | 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 "exit 0" | tSudo tee -a /etc/rc.local > /dev/null fi } @@ -177,7 +262,7 @@ function startup() { ;; build) - doBuild "${2}" "${3}" + doBuild "${2}" ;; del) @@ -185,7 +270,7 @@ function startup() { ;; install) - doInstall "${2}" "${3}" + doInstall ;; rebuild) @@ -193,18 +278,18 @@ function startup() { ;; server) - startBuildServer "${2}" "${3}" + startBuildServer ;; *) #set +x tBoldBox tGREEN "${G_TITLE} Options" echo "${NAME} add USER PASS" - echo "${NAME} build DIST SRC" + echo "${NAME} build SRC" echo "${NAME} del USER" echo "${NAME} install" echo "${NAME} rebuild" - echo "${NAME} server DIST LOG" + echo "${NAME} server" #set -x ;; esac @@ -212,7 +297,94 @@ function startup() { function startBuildServer() { - true + local TARGET= + local RESULT= + local NAME= + local ARCHS= + local DESCRIPTION= + local USERNAME= + local FILE= + + cd ${G_HOME} + + # Log startup. + echo "$(date) - Startup ${0}" >> "${LOG}" + + mkdir -p http + + # Build supported project types and target details for JoeyDev. + echo "1.0" > http/joeydev.info + echo "------------------------------------------------------------------------------" >> http/joeydev.info + echo "=build.application \"JoeyLib Application\"" >> http/joeydev.info + echo "=build.joeylib \"JoeyLib Itself\"" >> http/joeydev.info + 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 + call DESCRIPTION ${NAME} friendlyName + echo "+${NAME} \"${DESCRIPTION}\" ${ARCHS}" >> http/joeydev.info + fi + done + + # Start the PHP web server if it's not already running. + php -S 0.0.0.0:6502 -t http >> joeybuild.log 2>&1 & + + # Start the actual build server. + cd /home + while true; do + + # Find users with a "build.start" file. + for USERNAME in $(ls -1); do + + mkdir -p "${USERNAME}/build" + chown -R ${USERNAME}:${USERNAME} "${USERNAME}/build" + chmod u+rwX "${USERNAME}/build" + chmod go-rwx "${USERNAME}/build" + + # Handle building JoeyLib Applications. + if [[ -f "${USERNAME}/build/build.application" ]]; then + + # Are there old reults to clean up? + if [[ -f build.tar.bz2 ]]; then + rm build.tar.bz2 + fi + + doBuild /home/"${USERNAME}/build" + + pushd "${USERNAME}/build" + + # Compress the results. + tar cJf build.temp results + chown ${USERNAME}:${USERNAME} build.temp + + # Erase everything except the temp file. + rm -rf "${G_BUILD_RESULTS}" + for FILE in $(ls -1); do + if [[ -f "${FILE}" ]]; then + if [[ "${FILE}" != "build.temp" ]]; then + rm "${FILE}" + fi + else + if [[ -d "${FILE}" ]]; then + rm -r "${FILE}" + fi + fi + done + + # Signal JoeyDev we're done. + mv build.temp build.tar.bz2 + + # Log it. + echo "$(date) - Compiled ${G_BUILD_PROJECT} for ${USERNAME} on ${G_BUILD_PLATFORMS}" >> joeybuild.log + + popd + fi + done + + sleep 1 + + done } diff --git a/targets/IIgs.target b/targets/IIgs.target index 3b0d3ad..ca77394 100644 --- a/targets/IIgs.target +++ b/targets/IIgs.target @@ -22,8 +22,10 @@ # -M_IIGS=${G_EHOME}/cross/gsos-wdc-orca -M_CADIUS=${M_IIGS}/cadius/cadius +M_IIGS="${G_EHOME}/cross/gsos-wdc-orca" +M_CADIUS="${M_IIGS}/cadius/cadius" +M_TARGET="${M_IIGS}/ORCA/out/build" # Target directory as seen by Linux +M_GSTARGET="31:/out/build" # Target directory as seen by Golden Gate export GOLDEN_GATE=${M_IIGS}/ORCA @@ -34,11 +36,26 @@ function architectures() { } -function buildApplication() { - local ARCH=$1 +function assemble() { + local -n AFILES=$1 local PASS=$2 + local LOG=$3 + local OFILES="" + local FILE= + local O= - true + setCompiler + + # Assemble ASM files and generate object list. + for FILE in "${AFILES[@]}"; do + O=${FILE%.*} + OFILES="${OFILES} ${M_GSTARGET}/${O}" + iix assemble ${FILE} keep=${M_GSTARGET}/${O} >> ${LOG} 2>&1 + done + + unSetCompiler + + echo ${OFILES} } @@ -51,8 +68,7 @@ function buildJoeyLib() { mkdir -p ${G_DIST} pushd ${G_DIST} - export PATH=${G_ORIGINAL_PATH}:${M_IIGS} - "${M_IIGS}/mountORCA.sh" + setCompiler rm -rf ${OUT} || true mkdir -p ${OUT} @@ -82,15 +98,45 @@ function buildJoeyLib() { cp -f "${OUT}/joey.a" "joey.a#b10000" cp -f "${M_IIGS}/Tool222#ba0000" . - "${M_IIGS}/unmountORCA.sh" - export PATH=${G_ORIGINAL_PATH} + unSetCompiler popd } +function compile() { + local -n CFILES=$1 + local PASS=$2 + local LOG=$3 + local OFILES="" + local FILE= + local O= + + [[ -d "${M_TARGET}" ]] && rm -rf "${M_TARGET}" + mkdir -p "${M_TARGET}" + + setCompiler + + # Compile C files and generate object list. + for FILE in "${CFILES[@]}"; do + O=${FILE%.*} + OFILES="${OFILES} ${M_GSTARGET}/${O}" + iix compile ${FILE} keep=${M_GSTARGET}/${O} >> ${LOG} 2>&1 + done + + unSetCompiler + + echo ${OFILES} +} + + function enabled() { - echo 0 + echo 1 +} + + +function friendlyName() { + echo "Apple IIgs" } @@ -233,3 +279,89 @@ function install() { tar cjf "${M_IIGS}/jfsDrive.img.backup.tar.bz2" "${M_IIGS}/jfsDrive.img" fi } + + +function link() { + local -n OFILES=$1 + local PASS=$2 + local LOG=$3 + local LIB="${G_HOME}/dist/IIgs-65816/${PASS}" + + setCompiler + + # We need a local copy of JoeyLib to link. + cp -f "${LIB}/jIIgsc.a#b10000" "${M_TARGET}/jIIgsc.a" + cp -f "${LIB}/jIIgsc.root#b10000" "${M_TARGET}/jIIgsc.root" + cp -f "${LIB}/jIIgsasm.a#b10000" "${M_TARGET}/jIIgsasm.a" + cp -f "${LIB}/jIIgsasm.root#b10000" "${M_TARGET}/jIIgsasm.root" + cp -f "${LIB}/joey.a#b10000" "${M_TARGET}/joey.a" + iix chtyp -t obj ${M_GSTARGET}/jIIgsc.a + iix chtyp -t obj ${M_GSTARGET}/jIIgsc.root + iix chtyp -t obj ${M_GSTARGET}/jIIgsasm.a + iix chtyp -t obj ${M_GSTARGET}/jIIgsasm.root + iix chtyp -t obj ${M_GSTARGET}/joey.a + + # Add our library files to OFILES + OFILES+=("${M_GSTARGET}/jIIgsc ${M_GSTARGET}/joey ${M_GSTARGET}/jIIgsasm") + + # Link. + iix -DKeepType=S16 link ${OFILES[@]} keep=${M_GSTARGET}/${G_BUILD_PROJECT}#b3db03 >> ${LOG} 2>&1 + + rm -f *.sym || true + + unSetCompiler +} + + +function package() { + local -n DFILES=$1 + local PASS=$2 + local LOG=$3 + local DIR=${G_BUILD_RESULTS}/IIgs-65816/${PASS} + local DISK=${DIR}/${G_BUILD_PROJECT}.po + local LIB="${G_HOME}/dist/IIgs-65816/${PASS}" + local FILE= + local O= + local EXTENSION= + + mkdir -p ${DIR} + + # Create disk image, setting known file types + ${M_CADIUS} createvolume ${DISK} ${G_BUILD_PROJECT} 32MB + ${M_CADIUS} createfolder ${DISK} ${G_BUILD_PROJECT}/data + ${M_CADIUS} addfile ${DISK} ${G_BUILD_PROJECT} ${M_TARGET}/${G_BUILD_PROJECT}#b3db03 + ${M_CADIUS} addfile ${DISK} ${G_BUILD_PROJECT}/data ${LIB}/Tool222#ba0000 + # Copy game data. + for FILE in "${DFILES[@]}"; do + # Data conversion. + EXTENSION="${FILE##*.}" + case ${EXTENSION,,} in + mod) + php "${M_IIGS}/ntpconverter/ntpconverter.php" "${FILE}" + O=`basename -s .mod ${FILE}`.ntp#060000 + mv -f ${FILE} ${O} + ${M_CADIUS} addfile ${DISK} ${G_BUILD_PROJECT}/data ${O} + rm ${O} + ;; + + *) + O=`basename ${FILE}`#060000 + cp -f ${FILE} ${O} + ${M_CADIUS} addfile ${DISK} ${G_BUILD_PROJECT}/data ${O} + rm ${O} + ;; + esac + done +} + + +function setCompiler() { + export PATH=${G_ORIGINAL_PATH}:${M_IIGS} + "${M_IIGS}/mountORCA.sh" +} + + +function unSetCompiler() { + "${M_IIGS}/unmountORCA.sh" + export PATH=${G_ORIGINAL_PATH} +} diff --git a/targets/Linux.target b/targets/Linux.target index 319b5db..b1052ca 100644 --- a/targets/Linux.target +++ b/targets/Linux.target @@ -34,11 +34,11 @@ function architectures() { } -function buildApplication() { - local ARCH=$1 +function assemble() { + local -n AFILES=$1 local PASS=$2 + local LOG=$3 - true } @@ -63,11 +63,23 @@ function buildJoeyLib() { } +function compile() { + local -n CFILES=$1 + local PASS=$2 + local LOG=$3 + +} + function enabled() { echo 1 } +function friendlyName() { + echo "Linux" +} + + function install() { local ARCH=$1 local PASS=$2 @@ -81,6 +93,22 @@ function install() { } +function link() { + local -n OFILES=$1 + local PASS=$2 + local LOG=$3 + +} + + +function package() { + local -n DFILES=$1 + local PASS=$2 + local LOG=$3 + +} + + function setCompiler() { local ARCH=$1 local PASS=$2 diff --git a/targets/MacOS.target b/targets/MacOS.target index 0cf9beb..8391726 100644 --- a/targets/MacOS.target +++ b/targets/MacOS.target @@ -33,11 +33,11 @@ function architectures() { } -function buildApplication() { - local ARCH=$1 +function assemble() { + local -n AFILES=$1 local PASS=$2 + local LOG=$3 - true } @@ -87,8 +87,20 @@ function buildMacOSXToolchain() { } +function compile() { + local -n CFILES=$1 + local PASS=$2 + local LOG=$3 + +} + function enabled() { - echo 0 + echo 1 +} + + +function friendlyName() { + echo "Modern MacOS" } @@ -110,6 +122,22 @@ function install() { } +function link() { + local -n OFILES=$1 + local PASS=$2 + local LOG=$3 + +} + + +function package() { + local -n DFILES=$1 + local PASS=$2 + local LOG=$3 + +} + + function setCompiler() { local ARCH=$1 local PASS=$2 diff --git a/targets/Windows.target b/targets/Windows.target index 877ed02..1ceb1f9 100644 --- a/targets/Windows.target +++ b/targets/Windows.target @@ -34,12 +34,11 @@ function architectures() { } -function buildApplication() { - local ARCH=$1 +function assemble() { + local -n AFILES=$1 local PASS=$2 + local LOG=$3 - # LDFIRST="-lmingw32" - true } @@ -60,11 +59,23 @@ function buildJoeyLib() { } +function compile() { + local -n CFILES=$1 + local PASS=$2 + local LOG=$3 + +} + function enabled() { echo 1 } +function friendlyName() { + echo "Windows XP+" +} + + function install() { local ARCH=$1 local PASS=$2 @@ -74,6 +85,22 @@ function install() { } +function link() { + local -n OFILES=$1 + local PASS=$2 + local LOG=$3 + +} + + +function package() { + local -n DFILES=$1 + local PASS=$2 + local LOG=$3 + +} + + function setCompiler() { local ARCH=$1 local PASS=$2