#!/bin/bash

# Eventially provide a build_profile file to reduce file size.
TEMPLATE="disable_3d=yes svg=no"
LTO="lto=none"   # Use "lto=full" for releases.

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.
if [[ ! -f compile_commands.json ]]; then
	scons compiledb=yes
fi

# Build Templates.
scons platform=linuxbsd target=template_release arch=x86_64 ${TEMPLATE} ${LTO}
scons platform=windows  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
