hamncheese/build-godot.sh

121 lines
4 KiB
Bash
Executable file

#!/bin/bash
function createEmbeddedBinary() {
local BINFILE=$1
local SOURCEFILE=$2
local BLOCKER=$3
outputLicense > ${SOURCEFILE}
outputHeader ${BLOCKER} >> ${SOURCEFILE}
printf "\n#ifdef EMBED_HERE\n\n" >> ${SOURCEFILE}
xxd -i ${BINFILE} >> ${SOURCEFILE}
printf "\n#else // EMBED_HERE\n\n" >> ${SOURCEFILE}
printf "extern unsigned char ${BINFILE/\./_}[];\n" >> ${SOURCEFILE}
printf "extern unsigned int ${BINFILE/\./_}_len;\n" >> ${SOURCEFILE}
printf "\n#endif // EMBED_HERE\n\n" >> ${SOURCEFILE}
outputFooter ${BLOCKER} >> ${SOURCEFILE}
}
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
/*
*
* Ham'n'Cheese
* Copyright (C) 2006-2020 Scott Duensing <scott@kangaroopunch.com>
*
* 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
}
# Eventually provide a build_profile file to reduce file size.
TEMPLATE="disable_3d=yes svg=no"
LTO="lto=none" # Use "lto=full" for releases.
# Embed edge binaries.
pushd bin
mkdir -p ../modules/embedded/embeds
createEmbeddedBinary x86_64-linux-gnu-edge ../modules/embedded/embeds/linux_x86_64.h EDGE_H
popd
pushd godot
# Use Our Custom Settings.
ln -f -s ../custom.py .
# Clean Prior Builds.
#scons --clean
# Build Editor.
scons platform=linuxbsd target=editor arch=x86_64 ${LTO}
# Create JSON for IDE support.
scons compiledb=yes
# Build Templates.
scons platform=linuxbsd target=template_release arch=x86_64 ${TEMPLATE} ${LTO}
popd
:<<NOTES
#scons platform=list
# Linux
scons platform=linuxbsd target=template_release arch=x86_32 ${TEMPLATE}
scons platform=linuxbsd target=template_debug arch=x86_32 ${TEMPLATE}
scons platform=linuxbsd target=template_release arch=x86_64 ${TEMPLATE}
scons platform=linuxbsd target=template_debug arch=x86_64 ${TEMPLATE}
# Windows
scons platform=windows target=template_debug arch=x86_32 ${TEMPLATE}
scons platform=windows target=template_release arch=x86_32 ${TEMPLATE}
scons platform=windows target=template_debug arch=x86_64 ${TEMPLATE}
scons platform=windows target=template_release arch=x86_64 ${TEMPLATE}
# MacOS
scons platform=macos target=template_release osxcross_sdk=darwin15 arch=x86_64 ${TEMPLATE}
scons platform=macos target=template_debug osxcross_sdk=darwin15 arch=x86_64 ${TEMPLATE}
scons platform=macos target=template_release osxcross_sdk=darwin15 arch=arm64 ${TEMPLATE}
scons platform=macos target=template_debug osxcross_sdk=darwin15 arch=arm64 ${TEMPLATE}
#lipo -create bin/godot.macos.opt.x86_64 bin/godot.macos.opt.arm64 -output bin/godot.macos.opt.universal
#lipo -create bin/godot.macos.opt.debug.x86_64 bin/godot.macos.opt.debug.arm64 -output bin/godot.macos.opt.debug.universal
#cp -r misc/dist/macos_template.app .
#mkdir -p macos_template.app/Contents/MacOS
#cp bin/godot.macos.opt.universal macos_template.app/Contents/MacOS/godot_macos_release.64
#cp bin/godot.macos.opt.debug.universal macos_template.app/Contents/MacOS/godot_macos_debug.64
#chmod +x macos_template.app/Contents/MacOS/godot_macos*
NOTES