#!/bin/bash -xe # # Singe 2 # Copyright (C) 2006-2024 Scott Duensing # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public Licens # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # G_BUILDROOT=${PWD} G_BUILDDIR=.builddir G_TARGET= G_GENERATED= function buildAll() { local OS=$1 local ARCH=$2 local TRIPLE= local SUFFIX= local TOOLCHAIN= local COMMON= local CROSS_OS= local OSXCROSS_LOCATION= case "${OS}" in linux) case "${ARCH}" in x86) TRIPLE="i686-linux-gnu" ;; x86_64) TRIPLE="x86_64-linux-gnu" ;; esac CROSS_OS="linux" ;; macos) case "${ARCH}" in aarch64) TRIPLE="aarch64-apple-darwin22.4" OSXCROSS_LOCATION=${G_BUILDROOT}/../toolchains/x-tools/aarch64-macos-apple ;; x86) TRIPLE="i386-apple-darwin17" OSXCROSS_LOCATION=${G_BUILDROOT}/../toolchains/x-tools/x86_64-macos-apple ;; x86_64) TRIPLE="x86_64-apple-darwin17" OSXCROSS_LOCATION=${G_BUILDROOT}/../toolchains/x-tools/x86_64-macos-apple ;; esac CROSS_OS="darwin" source <("${OSXCROSS_LOCATION}/bin/osxcross-conf" 2>/dev/null) export OSXCROSS_LOCATION ;; windows) case "${ARCH}" in x86) TRIPLE="i686-w64-mingw32" ;; x86_64) TRIPLE="x86_64-w64-mingw32" ;; esac SUFFIX=".exe" CROSS_OS="mingw32" ;; esac G_TARGET=${G_BUILDROOT}/${G_BUILDDIR}/${OS}/${ARCH} G_GENERATED=${G_TARGET}/generated TOOLCHAIN=${G_BUILDROOT}/../toolchains/cmake/${TRIPLE}.cmake COMMON="-DCMAKE_INSTALL_PREFIX=${G_TARGET} -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}" # Add CMAKE_BUILD_TYPE to COMMON mkdir -p ${G_GENERATED} #export LD_FLAGS="-L ${G_TARGET}/lib" #export C_FLAGS="-I ${G_TARGET}/include" #export CXX_FLAGS=${C_FLAGS} export LD_LIBRARY_PATH=${G_TARGET} export PKG_CONFIG_LIBDIR=${G_TARGET}/lib/pkgconfig #:< ${G_GENERATED}/extensions.h # === Overlay Font === createEmbeddedImage font # === Window Icon === createEmbeddedImage icon # === Kangaroo Punch Logo === createEmbeddedImage kangarooPunchLogo # === Singe Logo === createEmbeddedImage singeLogo # === Laser Disc === createEmbeddedImage laserDisc # === Magnifying Glass === createEmbeddedImage magnifyingGlass # === "Indexing" Text === createEmbeddedImage indexing # === Singe Framework === createEmbeddedBinary assets/Framework.singe ${G_GENERATED}/Framework_singe.h FRAMEWORK_SINGE_H # === Default Config === createEmbeddedBinary assets/controls.cfg ${G_GENERATED}/controls_cfg.h CONTROLS_CFG_H # === Singe Menu App === createEmbeddedBinary assets/Menu.singe ${G_GENERATED}/Menu_singe.h MENU_SINGE_H # === Singe Menu Font === createEmbeddedBinary assets/FreeSansBold.ttf ${G_GENERATED}/FreeSansBold_ttf.h FREESANSBOLD_TTF_H # === Singe Menu Background Video === ffmpeg -i "assets/Singe Engine Intro.mpg" -filter:v 'crop=ih/3*4:ih' -vf scale=720:480 -c:v libx264 -c:a aac -f matroska ${G_TARGET}/temp1.mkv ffmpeg -i assets/180503_01_PurpleGrid.mp4 -filter:v 'crop=ih/3*4:ih' -vf scale=720:480 -c:v libx264 -c:a aac -f matroska ${G_TARGET}/temp2.mkv ffmpeg -f concat -safe 0 -i <(echo -e "file ${G_TARGET}/temp1.mkv\nfile ${G_TARGET}/temp2.mkv\n") -c copy ${G_TARGET}/menuBackground.mkv createEmbeddedBinary ${G_TARGET}/menuBackground.mkv ${G_GENERATED}/menuBackground_mkv.h MENUBACKGROUND_MKV_H rm ${G_TARGET}/temp1.mkv ${G_TARGET}/temp2.mkv ${G_TARGET}/menuBackground.mkv #SKIP :< ${SOURCEFILE} outputHeader ${BLOCKER} >> ${SOURCEFILE} printf "\n#ifdef EMBED_HERE\n\n" >> ${SOURCEFILE} pushd ${DIRNAME} xxd -i ${FILENAME} >> ${SOURCEFILE} popd printf "\n#else // EMBED_HERE\n\n" >> ${SOURCEFILE} printf "extern unsigned char ${FILENAME/\./_}[];\n" >> ${SOURCEFILE} printf "extern unsigned int ${FILENAME/\./_}_len;\n" >> ${SOURCEFILE} printf "\n#endif // EMBED_HERE\n\n" >> ${SOURCEFILE} outputFooter ${BLOCKER} >> ${SOURCEFILE} } function createEmbeddedImage() { local BASENAME=$1 pushd assets convert -flatten ${BASENAME}.xcf ${G_GENERATED}/${BASENAME}.png createEmbeddedBinary ${G_GENERATED}/${BASENAME}.png ${G_GENERATED}/${BASENAME}.h ${BASENAME^^}_H rm ${G_GENERATED}/${BASENAME}.png popd } function createExtensionHeader() { local FFMPEG=$1 local a= local c=0 outputLicense outputHeader FFMPEG_EXTENSIONS_H printf "static char *ffmpegExtensions[] = {\n" printf "\t" getExtensions "${FFMPEG}" | sort | uniq -u | while read a; do printf "\"${a}\", " c=$((c + 1)) if [[ ${c} -ge 10 ]]; then printf "\n\t" c=0 fi done printf "0\n};" outputFooter FFMPEG_EXTENSIONS_H } function getExtensions() { local FFMPEG=$1 local a= local b= local c= local d= local e= local f= local g= "${FFMPEG}" -demuxers 2> /dev/null | while read a b c; do if [[ "${a}x" == "Dx" ]]; then "${FFMPEG}" -h demuxer=${b} 2> /dev/null | grep "Common extensions" | while read d e f; do g=${f/./} echo -e "${g//,/\\n}" done fi done } function outputFooter() { local BLOCKER=$1 printf "\n#pragma GCC diagnostic pop\n\n\n#endif // ${BLOCKER}\n" } function outputHeader() { local BLOCKER=$1 printf "\n\n#ifndef ${BLOCKER}\n#define ${BLOCKER}\n\n\n" printf "// ===== THIS FILE IS AUTOMATICALLY GENERATED - DO NOT EDIT =====\n\n\n" printf "#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored \"-Wunused-variable\"\n" } function outputLicense() { cat <<- LICENSE /* * * Singe 2 * Copyright (C) 2006-2024 Scott Duensing * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ LICENSE } buildAll linux x86 buildAll linux x86_64 #buildAll macos aarch64 #buildAll macos x86 #***TODO*** Needs older SDL2 #buildAll macos x86_64 #***TODO*** Needs older SDL2 buildAll windows x86 buildAll windows x86_64