From 6d9d2fa4d984bef63c8f1986d096e193c653a90d Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Wed, 28 Sep 2022 17:51:51 -0500 Subject: [PATCH] Build server now generates binary distribution of JoeyLib with debug and release versions. --- joeylib/joeylib.pro | 2 + joeylib/src/jSDL12.c | 1 + joeylib/src/jSDL2.c | 1 + joeylib/src/joey.h | 23 +++----- scripts/buildVm.sh | 129 +++++++++++++++++++++++++------------------ 5 files changed, 87 insertions(+), 69 deletions(-) diff --git a/joeylib/joeylib.pro b/joeylib/joeylib.pro index 047f60b..16a5209 100644 --- a/joeylib/joeylib.pro +++ b/joeylib/joeylib.pro @@ -11,6 +11,8 @@ CONFIG -= \ app_bundle \ qt +DEFINES += JOEY_DEBUG + # Determine which libraries to link against. defined(BREW,var) { # Use Homebrew libraries. diff --git a/joeylib/src/jSDL12.c b/joeylib/src/jSDL12.c index 05bc997..b2f2655 100644 --- a/joeylib/src/jSDL12.c +++ b/joeylib/src/jSDL12.c @@ -224,6 +224,7 @@ static void _jlAudioCallback(void *userdata, Uint8 *buffer, int bytes) { // Combine channels into a mono sample. work = (data[i] + data[i + 1]) * 0.5; // Determine channel. + // ***TODO*** These should be channel bits that can be ORed together! isRight = (sound->channel & 0x01); if (_jlSwapChannels) isRight = !isRight; if (isRight) { diff --git a/joeylib/src/jSDL2.c b/joeylib/src/jSDL2.c index 52bd27f..b7c3a50 100644 --- a/joeylib/src/jSDL2.c +++ b/joeylib/src/jSDL2.c @@ -227,6 +227,7 @@ static void _jlAudioCallback(void *userdata, Uint8 *buffer, int bytes) { // Combine channels into a mono sample. work = (data[i] + data[i + 1]) * 0.5; // Determine channel. + // ***TODO*** These should be channel bits that can be ORed together! isRight = (sound->channel & 0x01); if (_jlSwapChannels) isRight = !isRight; if (isRight) { diff --git a/joeylib/src/joey.h b/joeylib/src/joey.h index 049abe2..e56690a 100644 --- a/joeylib/src/joey.h +++ b/joeylib/src/joey.h @@ -28,11 +28,6 @@ extern "C" { #endif -#ifndef BUILD_SERVER -//#define JOEY_DEBUG -#endif - - #include #include @@ -302,14 +297,14 @@ extern jmp_buf _jlJumpBuffer; enum _jlSoundChannelE { - CHANNEL_FRONT_LEFT = 0, - CHANNEL_FRONT_RIGHT = 1, - CHANNEL_SURROUND_LEFT = 2, - CHANNEL_SURROUND_RIGHT = 3, - CHANNEL_FRONT_HIGH_LEFT = 4, - CHANNEL_FRONT_HIGH_RIGHT = 5, - CHANNEL_SURROUND_BACK_LEFT = 6, - CHANNEL_SURROUND_BACK_RIGHT = 7 + CHANNEL_FRONT_LEFT = 0, + CHANNEL_FRONT_RIGHT = 1, + CHANNEL_SURROUND_LEFT = 2, + CHANNEL_SURROUND_RIGHT = 4, + CHANNEL_FRONT_HIGH_LEFT = 8, + CHANNEL_FRONT_HIGH_RIGHT = 16, + CHANNEL_SURROUND_BACK_LEFT = 32, + CHANNEL_SURROUND_BACK_RIGHT = 64 }; typedef enum _jlSoundChannelE jlSoundChannelE; @@ -399,7 +394,7 @@ void *_jlRealloc(void *pointer, size_t size); #else -#define jlFree(p) free(p); p = 0 +#define jlFree(p) {free(p); p = 0;} #define jlMalloc malloc #define jlMallocEx(s, l, f) malloc(s) diff --git a/scripts/buildVm.sh b/scripts/buildVm.sh index 285854a..27f279b 100755 --- a/scripts/buildVm.sh +++ b/scripts/buildVm.sh @@ -1,4 +1,4 @@ -#!/bin/bash -e +#!/bin/bash -ex # # JoeyLib @@ -206,6 +206,7 @@ function buildIIgsSDK() { function buildJoeyLib() { local OUT= + local PASS= local OLD_CFLAGS=${CFLAGS} if [[ ! -d joeylib ]]; then @@ -213,51 +214,65 @@ function buildJoeyLib() { fi rm -rf dist/${NAME}-${ARCH} || true - mkdir -p dist/${NAME}-${ARCH} - pushd dist/${NAME}-${ARCH} - case ${BACKEND} in - orca) - OUT=${GOLDEN_GATE}/out/joey - rm -rf ${OUT} || true - mkdir -p ${OUT}/out/joey - pushd ${SRC} - # Add BUILD_SERVER flag. - cp joey.h joey.h.original - sed -i "1i #define BUILD_SERVER" joey.h - 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 - # Remove BUILD_SERVER. - rm joey.h - mv joey.h.original joey.h - 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 "${IIGS}/Tool222#ba0000" . - ;; - - SDL2) - export CFLAGS="${CFLAGS} -I${SRC} -I${INSTALLED}/include -c" - ${CC} ${CFLAGS} -o jPixBuf.o ${SRC}/jPixBuf.c - ${CC} ${CFLAGS} -o jSDL2.o ${SRC}/jSDL2.c - ${CC} ${CFLAGS} -o joey.o ${SRC}/joey.c - ${AR} x ${INSTALLED}/lib/libSDL2.a - ${AR} x ${INSTALLED}/lib/libSDL2main.a - ${AR} rcs libjoeylib.a *.o - rm *.o - rm __.SYMDEF* || true - ;; - - esac + for PASS in "debug" "release"; do + + mkdir -p dist/${NAME}-${ARCH}/${PASS} + + pushd dist/${NAME}-${ARCH}/${PASS} + case ${BACKEND} in + orca) + OUT=${GOLDEN_GATE}/out/joey + rm -rf ${OUT} || true + mkdir -p ${OUT}/out/joey + pushd ${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 + iix compile jIIgs.c keep=31:/out/joey/jIIgsc + iix compile joey.c keep=31:/out/joey/joey + 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 "${IIGS}/Tool222#ba0000" . + ;; + + SDL2) + export CFLAGS="${CFLAGS} -I${SRC} -I${INSTALLED}/include -c" + if [[ "${PASS}" == "debug" ]]; then + export CFLAGS="-DJOEY_DEBUG ${CFLAGS}" + fi + ${CC} ${CFLAGS} -o jPixBuf.o ${SRC}/jPixBuf.c + ${CC} ${CFLAGS} -o jSDL2.o ${SRC}/jSDL2.c + ${CC} ${CFLAGS} -o joey.o ${SRC}/joey.c + ${AR} x ${INSTALLED}/lib/libSDL2.a + ${AR} x ${INSTALLED}/lib/libSDL2main.a + ${AR} rcs libjoeylib.a *.o + rm *.o + rm __.SYMDEF* || true + ;; + + esac - cp -f ${SRC}/joey.h ../. - popd - - export CFLAGS=${OLD_CFLAGS} + cp -f ${SRC}/joey.h ../../. + mkdir -p ../../3rdparty/memwatch + cp -f ${SRC}/3rdparty/memwatch/* ../../3rdparty/memwatch/. + popd + + export CFLAGS=${OLD_CFLAGS} + + done } @@ -451,7 +466,7 @@ function doBuild() { BUILD_PLATFORMS="${BUILD_PLATFORMS}${LINE,,} " LOG="${BUILD_RESULTS}/build.${LINE,,}" - LIB="${DIST}/${NAME}-${ARCH}" + LIB="${DIST}/${NAME}-${ARCH}/release" [[ -d "${TARGET}" ]] && rm -rf "${TARGET}" mkdir -p "${TARGET}" @@ -463,8 +478,6 @@ function doBuild() { case ${BACKEND} in orca) - # Pass in -DBUILD_SERVER - sed -i "1i #define BUILD_SERVER" "${SOURCE}/joey.h" # Compile C files and generate object list. OFILES="" for FILE in "${CFILES[@]}"; do @@ -587,7 +600,7 @@ function doInstall() { if [[ ! -f /etc/rc.local ]]; then echo "#!/bin/bash" | sudo tee /etc/rc.local - echo "${EHOME}/buildVm.sh server ${EHOME}/dist &> /dev/null &" | sudo tee -a /etc/rc.local + echo "${EHOME}/buildVm.sh server ${EHOME}/dist ${EHOME}/builds.log &> /dev/null &" | sudo tee -a /etc/rc.local echo "exit 0" | sudo tee -a /etc/rc.local fi } @@ -651,6 +664,9 @@ function rebuildJoeyLib() { setCompiler windows x86_64 buildJoeyLib + + rm -f dist.tar.bz2 || true + tar cJf dist.tar.bz2 dist } @@ -678,7 +694,7 @@ function setCompiler() { NAME="linux-intel" ARCH=i386 TRIPLE="x86_64-linux-gnu" - export CFLAGS="-m32 -DBUILD_SERVER -Wall -D_REENTRANT_" + export CFLAGS="-m32 -Wall -D_REENTRANT_" export LDFLAGS="-lm -ldl -lpthread" ;; @@ -686,7 +702,7 @@ function setCompiler() { NAME="linux-intel" ARCH=x86_64 TRIPLE="${ARCH}-linux-gnu" - export CFLAGS="-DBUILD_SERVER -Wall -D_REENTRANT_" + export CFLAGS="-Wall -D_REENTRANT_" export LDFLAGS="-lm -ldl -lpthread" ;; @@ -725,7 +741,7 @@ function setCompiler() { esac BACKEND=SDL2 LDFIRST= - export CFLAGS="-DBUILD_SERVER -Wall -D_THREAD_SAFE" + export CFLAGS="-Wall -D_THREAD_SAFE" export PATH=${EHOME}/cross/${NAME}/bin:${OLD_PATH} export LD_LIBRARY_PATH=${EHOME}/cross/${NAME}/lib export CC=${TRIPLE}-clang @@ -753,7 +769,7 @@ function setCompiler() { LDFIRST="-lmingw32" export PATH=${OLD_PATH} export LD_LIBRARY_PATH= - export CFLAGS="-DBUILD_SERVER -Dmain=SDL_main -Wall -static-libgcc" + 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" export CC=${TRIPLE}-gcc export AR=${TRIPLE}-ar @@ -791,16 +807,19 @@ function scriptIsDownloaded() { ;; server) - startBuildServer "${2}" + startBuildServer "${2}" "${3}" ;; *) + set +x + echo "" echo "${0} add USER PASS" echo "${0} build DIST SRC" echo "${0} del USER" echo "${0} install GGUSER GGPASS" echo "${0} rebuild" - echo "${0} server DIST" + echo "${0} server DIST LOG" + set -x ;; esac } @@ -808,7 +827,7 @@ function scriptIsDownloaded() { function startBuildServer() { local DIST=$1 - local LOG=${0}.log + local LOG=$2 local USERNAME= local FILE=