Skip to content

Commit

Permalink
[godot] More C# build work.
Browse files Browse the repository at this point in the history
  • Loading branch information
badlogic committed Jul 21, 2023
1 parent e59b15c commit b405686
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -189,3 +189,4 @@ spine-flutter/ios/Classes/spine-cpp
spine-flutter/macos/Classes/spine-cpp
spine-flutter/src/spine-cpp
spine-godot/godot-nuget
spine-godot/godot-spine-csharp
74 changes: 48 additions & 26 deletions spine-godot/build/build-templates-v4.sh
Expand Up @@ -4,8 +4,8 @@ set -e
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
pushd "$dir" > /dev/null

if [ ! "$#" -eq 1 ]; then
echo "Usage: ./build-templates.sh <platform>"
if [ "$#" -lt 1 ]; then
echo "Usage: ./build-templates.sh <platform> <mono:true|false>?"
echo
echo "e.g.:"
echo " ./build-templates.sh windows"
Expand All @@ -14,7 +14,7 @@ if [ ! "$#" -eq 1 ]; then
echo " ./build-templates.sh ios"
echo " ./build-templates.sh android"
echo " ./build-templates.sh web"
echo
echo
exit 1
fi

Expand All @@ -24,6 +24,28 @@ if [ ! -d ../godot ]; then
fi

platform=${1%/}
mono=false

if [[ $# -eq 2 ]]; then
mono=${2%/}
if [ "$platform" != "windows" ] && [ "$platform" != "linux" ] && [ "$platform" != "macos" ]; then
echo "C# is only supported for Windows, Linux, and macOS"
exit 1
fi
echo "Building Godot template with C# support"
else
echo "Building Godot template without C# support"
fi

mono_module=""
mono_extension=""
if [ $mono == "true" ]; then
mono_module="module_mono_enabled=yes"
mono_extension=".mono"
echo "Building Godot with C# support"
else
echo "Building Godot without C# support"
fi

cpus=2
if [ "$OSTYPE" = "msys" ]; then
Expand All @@ -38,10 +60,10 @@ pushd ../godot
if [ "$platform" = "windows" ]; then
# --- Windows ---
#generates windows_64_debug.exe and windows_64_release.exe
scons platform=windows tools=no target=template_release custom_modules="../spine_godot" --jobs=$cpus
scons platform=windows tools=no target=template_debug custom_modules="../spine_godot" --jobs=$cpus
cp bin/godot.windows.template_release.x86_64.exe bin/windows_release_x86_64.exe
cp bin/godot.windows.template_debug.x86_64.exe bin/windows_debug_x86_64.exe
scons platform=windows tools=no target=template_release custom_modules="../spine_godot" $mono_module --jobs=$cpus
scons platform=windows tools=no target=template_debug custom_modules="../spine_godot" $mono_module --jobs=$cpus
cp bin/godot.windows.template_release.x86_64$mono_extension.exe bin/windows_release_x86_64.exe
cp bin/godot.windows.template_debug.x86_64$mono_extension.exe bin/windows_debug_x86_64.exe

elif [ "$platform" = "macos" ]; then
# --- macOS ---
Expand All @@ -51,19 +73,30 @@ elif [ "$platform" = "macos" ]; then
scons platform=macos tools=no target=template_debug arch=x86_64 custom_modules="../spine_godot" --jobs=$cpus
scons platform=macos tools=no target=template_release arch=arm64 custom_modules="../spine_godot" --jobs=$cpus
scons platform=macos tools=no target=template_debug arch=arm64 custom_modules="../spine_godot" --jobs=$cpus
lipo -create bin/godot.macos.template_release.x86_64 bin/godot.macos.template_release.arm64 -output bin/godot.macos.universal
lipo -create bin/godot.macos.template_debug.x86_64 bin/godot.macos.template_debug.arm64 -output bin/godot.macos.debug.universal
lipo -create "bin/godot.macos.template_release.x86_64$mono_extension" "bin/godot.macos.template_release.arm64$mono_extension" -output bin/godot.macos.universal
lipo -create "bin/godot.macos.template_debug.x86_64$mono_extension" "bin/godot.macos.template_debug.arm64$mono_extension" -output bin/godot.macos.debug.universal
strip -S -x bin/godot.macos.universal

pushd bin
cp -r ../misc/dist/macos_template.app .
mkdir -p macos_template.app/Contents/MacOS
cp godot.macos.universal macos_template.app/Contents/MacOS/godot_macos_release.universal
cp godot.macos.debug.universal macos_template.app/Contents/MacOS/godot_macos_debug.universal
chmod +x macos_template.app/Contents/MacOS/godot_macos*
chmod +x macos_template.app/Contents/MacOS/godot_macos*
rm -rf macos.zip
zip -q -9 -r macos.zip macos_template.app
popd
elif [ "$platform" = "linux" ]; then
# --- Linux ---
# generates linux_x11_64_release, linux_x11_64_debug
scons platform=linuxbsd tools=no target=template_release bits=64 custom_modules="../spine_godot" --jobs=$cpus
scons platform=linuxbsd tools=no target=template_debug bits=64 custom_modules="../spine_godot" --jobs=$cpus
strip bin/godot.linuxbsd.template_release.x86_64$mono_extension
strip bin/godot.linuxbsd.template_debug.x86_64$mono_extension
chmod a+x bin/godot.linuxbsd.template_release.x86_64$mono_extension
chmod a+x bin/godot.linuxbsd.template_debug.x86_64$mono_extension
cp bin/godot.linuxbsd.template_release.x86_64$mono_extension bin/linux_release.x86_64
cp bin/godot.linuxbsd.template_debug.x86_64$mono_extension bin/linux_debug.x86_64
elif [ "$platform" = "ios" ]; then
# --- iOS --
# generates ios.zip
Expand All @@ -77,19 +110,19 @@ elif [ "$platform" = "ios" ]; then
lipo -create bin/libgodot.ios.template_release.arm64.simulator.a bin/libgodot.ios.template_release.x86_64.simulator.a -output bin/libgodot.ios.template_release.simulator.a
lipo -create bin/libgodot.ios.template_debug.arm64.simulator.a bin/libgodot.ios.template_debug.x86_64.simulator.a -output bin/libgodot.ios.template_debug.simulator.a
strip -S -x bin/libgodot.ios.template_release.arm64.a
strip -S -x bin/libgodot.ios.template_release.simulator.a
strip -S -x bin/libgodot.ios.template_release.simulator.a

pushd bin
cp -r ../misc/dist/ios_xcode .
cp -r ../misc/dist/ios_xcode .
cp libgodot.ios.template_release.arm64.a ios_xcode/libgodot.ios.release.xcframework/ios-arm64/libgodot.a
cp libgodot.ios.template_release.simulator.a ios_xcode/libgodot.ios.release.xcframework/ios-arm64_x86_64-simulator/libgodot.a
cp libgodot.ios.template_release.simulator.a ios_xcode/libgodot.ios.release.xcframework/ios-arm64_x86_64-simulator/libgodot.a
cp libgodot.ios.template_debug.arm64.a ios_xcode/libgodot.ios.debug.xcframework/ios-arm64/libgodot.a
cp libgodot.ios.template_debug.simulator.a ios_xcode/libgodot.ios.debug.xcframework/ios-arm64_x86_64-simulator/libgodot.a
cp libgodot.ios.template_debug.simulator.a ios_xcode/libgodot.ios.debug.xcframework/ios-arm64_x86_64-simulator/libgodot.a
rm -rf ios.zip
pushd ios_xcode
zip -q -9 -r ../ios.zip *
popd
popd
popd
elif [ "$platform" = "web" ]; then
# --- WEB ---
# generates webassembly_debug.zip, webassembly_release.zip
Expand All @@ -109,17 +142,6 @@ elif [ "$platform" = "android" ]; then
chmod a+x gradlew
./gradlew generateGodotTemplates
popd
elif [ "$platform" = "linux" ]; then
# --- Linux ---
# generates linux_x11_64_release, linux_x11_64_debug
scons platform=linuxbsd tools=no target=template_release bits=64 custom_modules="../spine_godot" --jobs=$cpus
scons platform=linuxbsd tools=no target=template_debug bits=64 custom_modules="../spine_godot" --jobs=$cpus
strip bin/godot.linuxbsd.template_release.x86_64
strip bin/godot.linuxbsd.template_debug.x86_64
chmod a+x bin/godot.linuxbsd.template_release.x86_64
chmod a+x bin/godot.linuxbsd.template_debug.x86_64
cp bin/godot.linuxbsd.template_release.x86_64 bin/linux_x11_64_release
cp bin/godot.linuxbsd.template_debug.x86_64 bin/linux_x11_64_debug
else
echo "Unknown platform: $platform"
exit 1
Expand Down
4 changes: 2 additions & 2 deletions spine-godot/build/build-v4.sh
Expand Up @@ -15,7 +15,7 @@ mono="false"

if [ $# -gt 0 ]; then
if [ $# -gt 1 ]; then
echo "Usage: $0 [mono:true|false]"
echo "Usage: $0 <mono:true|false>"
exit 1
else
if [ "$1" == "true" ] || [ "$1" == "false" ]; then
Expand Down Expand Up @@ -83,7 +83,7 @@ if [ "$os" == "macos" ] && [ $dev == "false" ]; then
if [ $mono == "true" ]; then
echo "Building C# glue and assemblies."
"./bin/$godot_exe_host" --generate-mono-glue modules/mono/glue
./modules/mono/build_scripts/build_assemblies.py --godot-output-dir ./bin --push-nupkgs-local ../godot-nuget
./modules/mono/build_scripts/build_assemblies.py --godot-output-dir ./bin --push-nupkgs-local ../godot-spine-csharp
fi
pushd bin
cp -r ../misc/dist/macos_tools.app .
Expand Down
2 changes: 1 addition & 1 deletion spine-godot/build/setup.sh
Expand Up @@ -5,7 +5,7 @@ dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
pushd "$dir" > /dev/null

if [ $# -lt 2 ] || [ $# -gt 3 ]; then
echo "Usage: ./setup.sh <Godot branch or tag> <dev:true|false> [mono:true|false]?"
echo "Usage: ./setup.sh <Godot branch or tag> <dev:true|false> <mono:true|false>?"
echo
echo "e.g.:"
echo " ./setup.sh 3.5.2-stable true"
Expand Down

0 comments on commit b405686

Please sign in to comment.