Skip to content

Commit

Permalink
[godot] Rework v4 build scripts to support optionally support C#.
Browse files Browse the repository at this point in the history
  • Loading branch information
badlogic committed Jul 19, 2023
1 parent bdb9e13 commit e525c77
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -187,4 +187,5 @@ spine-godot/build/compile_commands.json

spine-flutter/ios/Classes/spine-cpp
spine-flutter/macos/Classes/spine-cpp
spine-flutter/src/spine-cpp
spine-flutter/src/spine-cpp
spine-godot/godot-nuget
25 changes: 25 additions & 0 deletions spine-godot/.vscode/launch.json
Expand Up @@ -54,6 +54,31 @@
"program": "${workspaceFolder}/godot/bin/godot.macos.editor.dev.arm64",
},
},
{
"type": "cppvsdbg",
"request": "launch",
"name": "debug editor v4 c#",
"program": "godot/bin/godot.windows.editor.dev.x86_64.mono.exe",
"args": [
"-e",
"--path",
"example-v4",
],
"cwd": "${workspaceFolder}",
"preLaunchTask": "build-v4",
"linux": {
"type": "lldb",
"request": "launch",
"name": "debug editor v4",
"program": "${workspaceFolder}/godot/bin/godot.linux.editor.dev.x86_64",
},
"osx": {
"type": "lldb",
"request": "launch",
"name": "debug editor v4",
"program": "${workspaceFolder}/godot/bin/godot.macos.editor.dev.arm64.mono",
},
},
{
"type": "cppvsdbg",
"request": "launch",
Expand Down
55 changes: 39 additions & 16 deletions spine-godot/build/build-v4.sh
Expand Up @@ -35,46 +35,69 @@ if [ -f "../godot/custom.py" ]; then
dev="true"
fi

mono_module=""
mono_extension=""
if [ $mono = "true" ]; then
mono_module="module_mono_enabled=yes"
mono_extension=".mono"
fi

dev_extension=""
if [ $dev = "true" ]; then
dev_extension=".dev"
target="$target dev_build=true"
fi

cpus=2
if [ "$OSTYPE" = "msys" ]; then
os="windows"
cpus=$NUMBER_OF_PROCESSORS
target="vsproj=yes livepp=$LIVEPP"
godot_exe="godot.windows.editor$dev_extension.x86_64$mono_extension.exe"
godot_exe_host=$godot_exe
elif [[ "$OSTYPE" = "darwin"* ]]; then
os="macos"
cpus=$(sysctl -n hw.logicalcpu)
godot_exe="godot.macos.editor$dev_extension.x86_64$mono_extension"
godot_exe_arm="godot.macos.editor$dev_extension.arm64$mono_extension"
godot_exe_host=$godot_exe
if [ `uname -m` == "arm64" ]; then
godot_exe_host=$godot_exe_arm
fi
else
os="linux"
cpus=$(grep -c ^processor /proc/cpuinfo)
godot_exe="godot.linux.editor$dev_extension.x86_64$mono_extension"
godot_exe_host=$godot_exe
fi

echo "CPUS: $cpus"

mono_module=""
mono_extension=""
if [ $mono = "true" ]; then
mono_module="module_mono_enabled=yes"
mono_extension=".mono"
fi

pushd ../godot
if [ `uname` == 'Darwin' ] && [ $dev = "false" ]; then
if [ "$os" = "macos" ] && [ $dev = "false" ]; then
scons $target $mono_module arch=x86_64 compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus
scons $target $mono_module arch=arm64 compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus

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
fi
pushd bin
cp -r ../misc/dist/macos_tools.app .
mv macos_tools.app Godot.app
mkdir -p Godot.app/Contents/MacOS
lipo -create godot.macos.editor.arm64$mono_extension godot.macos.editor.x86_64$mono_extension -output Godot
lipo -create $godot_exe_arm $godot_exe -output Godot
strip -S -x Godot
cp Godot Godot.app/Contents/MacOS/Godot
chmod +x Godot.app/Contents/MacOS/Godot
popd
else
if [ "$OSTYPE" = "msys" ]; then
target="vsproj=yes livepp=$LIVEPP"
fi
if [ "$dev" = "true" ]; then
target="$target dev_build=true"
fi
scons $target $mono_module compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus
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
fi
cp compile_commands.json ../build
if [ -f "bin/godot.linuxbsd.editor.x86_64$mono_extension" ]; then
strip bin/godot.linuxbsd.editor.x86_64$mono_extension
Expand Down
1 change: 1 addition & 0 deletions spine-godot/build/setup.sh
Expand Up @@ -42,6 +42,7 @@ if [ $dev = "true" ]; then
cp -r .idea godot
cp build/custom.py godot
if [ "$mono" = "true" ]; then
echo "" >> godot/custom.py
echo "module_mono_enabled=\"yes\"" >> godot/custom.py
fi
cp ../formatters/.clang-format .
Expand Down

0 comments on commit e525c77

Please sign in to comment.