Skip to content

Commit 8a943c3

Browse files
akien-mgaraulsntos
andauthored
Add support for experimental .NET builds (GDExtension) (#136)
This is eventually meant to be unified with the "classical" builds, but for the initial testing we start with a dedicated "dotnet" build. Co-authored-by: Raul Santos <raulsntos@gmail.com>
1 parent 7126657 commit 8a943c3

File tree

10 files changed

+486
-15
lines changed

10 files changed

+486
-15
lines changed

build-android/build.sh

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ set -e
44

55
# Config
66

7-
# Debug symbols are enabled for the Android builds so we can generate a separate debug symbols file.
7+
# Debug symbols are enabled for the Android builds so we can generate a separate debug symbols file.
88
# Gradle will strip them out of the final artifacts.
99
export SCONS="scons -j${NUM_CORES} verbose=yes warnings=no progress=no redirect_build_objects=no"
1010
export OPTIONS="production=yes debug_symbols=yes"
1111
export OPTIONS_MONO="module_mono_enabled=yes"
12+
export OPTIONS_DOTNET="module_dotnet_enabled=yes"
1213
export TERM=xterm
1314

1415
prepare_source() {
@@ -143,4 +144,34 @@ if [ "${MONO}" == "1" ]; then
143144
cp bin/godot-lib.template_release.aar /root/out/templates-mono/
144145
fi
145146

147+
# .NET
148+
149+
if [ "${DOTNET}" == "1" ]; then
150+
echo "Starting .NET build for Android..."
151+
152+
prepare_source
153+
154+
$SCONS platform=android arch=arm32 $OPTIONS $OPTIONS_DOTNET target=template_debug
155+
$SCONS platform=android arch=arm32 $OPTIONS $OPTIONS_DOTNET target=template_release
156+
157+
$SCONS platform=android arch=arm64 $OPTIONS $OPTIONS_DOTNET target=template_debug
158+
$SCONS platform=android arch=arm64 $OPTIONS $OPTIONS_DOTNET target=template_release
159+
160+
$SCONS platform=android arch=x86_32 $OPTIONS $OPTIONS_DOTNET target=template_debug
161+
$SCONS platform=android arch=x86_32 $OPTIONS $OPTIONS_DOTNET target=template_release
162+
163+
$SCONS platform=android arch=x86_64 $OPTIONS $OPTIONS_DOTNET target=template_debug
164+
$SCONS platform=android arch=x86_64 $OPTIONS $OPTIONS_DOTNET target=template_release
165+
166+
pushd platform/android/java
167+
./gradlew generateGodotMonoTemplates
168+
popd
169+
170+
mkdir -p /root/out/templates-dotnet
171+
cp bin/android_source.zip /root/out/templates-dotnet/
172+
cp bin/android_monoDebug.apk /root/out/templates-dotnet/android_debug.apk
173+
cp bin/android_monoRelease.apk /root/out/templates-dotnet/android_release.apk
174+
cp bin/godot-lib.template_release.aar /root/out/templates-dotnet/
175+
fi
176+
146177
echo "Android build successful"

build-dotnet/build.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if [ "${DOTNET}" != "1" ]; then
6+
exit 0
7+
fi
8+
9+
dnf install -y clang python-unversioned-command
10+
11+
git clone https://github.com/raulsntos/godot-dotnet
12+
cd godot-dotnet
13+
git checkout upgrade-assistant-plus-source-code-plugin-wip
14+
15+
echo "Building and generating .NET extension..."
16+
17+
# TODO: Get rid of this when we fix all these trimming warnings in godot-dotnet.
18+
cat << EOF >> .editorconfig
19+
# Disable trimming warnings because it spams the output too much.
20+
dotnet_diagnostics.IL2111.severity = none
21+
EOF
22+
23+
prerelease_label="${GODOT_VERSION#*-}"
24+
version_prefix="${GODOT_VERSION%-*}"
25+
26+
if [[ "${prerelease_label}" == "${GODOT_VERSION}" ]]; then
27+
prerelease_label=""
28+
fi
29+
30+
# TODO: Ensure we don't accidentally make stable releases. We can remove this when we're ready for a stable release.
31+
if [[ -z "$prerelease_label" ]]; then
32+
echo "YOU ARE NOT SUPPOSED TO MAKE A STABLE RELEASE WITH THIS"
33+
exit -1
34+
fi
35+
36+
version_component_count=$(grep -o "\." <<< "$version_prefix" | wc -l)
37+
38+
if [ "$version_component_count" -eq 0 ]; then
39+
version_prefix="${version_prefix}.0.0"
40+
elif [ "$version_component_count" -eq 1 ]; then
41+
version_prefix="${version_prefix}.0"
42+
fi
43+
44+
if [[ -n "$prerelease_label" ]]; then
45+
if [[ "$prerelease_label" =~ ^dev ]]; then
46+
prerelease_label="${prerelease_label/dev/alpha}"
47+
fi
48+
49+
prerelease_label=$(echo "$prerelease_label" | sed -E 's/([^0-9])([0-9])/\1.\2/g')
50+
fi
51+
52+
echo "Building Godot .NET version ${version_prefix} (prerelease: '${prerelease_label}')"
53+
54+
dotnet --info
55+
56+
build_id="$(date +%Y%m%d).1"
57+
final_version_kind="release"
58+
if [[ -n "$prerelease_label" ]]; then
59+
final_version_kind="prerelease"
60+
fi
61+
62+
./build.sh --productBuild --ci --warnAsError false \
63+
/p:GenerateGodotBindings=true \
64+
/p:VersionPrefix=${version_prefix} \
65+
/p:OfficialBuildId=${build_id} \
66+
/p:FinalVersionKind=${final_version_kind} \
67+
/p:PreReleaseVersionLabel=${prerelease_label}
68+
69+
cp -r artifacts/packages/Release/Shipping/* /root/out/
70+
71+
echo ".NET bindings generated successfully"

build-ios/build.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export SCONS="scons -j${NUM_CORES} verbose=yes warnings=no progress=no redirect_
99
# which is seen as a regression in the current workflow.
1010
export OPTIONS="production=yes use_lto=no SWIFT_FRONTEND=/root/.local/share/swiftly/toolchains/6.2.0/usr/bin/swift-frontend"
1111
export OPTIONS_MONO="module_mono_enabled=yes"
12+
export OPTIONS_DOTNET="module_dotnet_enabled=yes"
1213
export TERM=xterm
1314

1415
export IOS_SDK="26.0"
@@ -76,4 +77,30 @@ if [ "${MONO}" == "1" ]; then
7677
cp bin/libgodot.ios.template_debug.x86_64.simulator.a /root/out/templates-mono/libgodot.ios.debug.simulator.a
7778
fi
7879

80+
# .NET
81+
82+
if [ "${DOTNET}" == "1" ]; then
83+
echo "Starting .NET build for iOS..."
84+
85+
# arm64 device
86+
$SCONS platform=ios $OPTIONS $OPTIONS_DOTNET arch=arm64 target=template_debug $IOS_DEVICE $APPLE_TARGET_ARM64
87+
$SCONS platform=ios $OPTIONS $OPTIONS_DOTNET arch=arm64 target=template_release $IOS_DEVICE $APPLE_TARGET_ARM64
88+
89+
# arm64 simulator
90+
# Disabled for now as it doesn't work with cctools-port and current LLVM.
91+
# See https://github.com/godotengine/build-containers/pull/85.
92+
#$SCONS platform=ios $OPTIONS $OPTIONS_DOTNET arch=arm64 target=template_debug $IOS_SIMULATOR $APPLE_TARGET_ARM64
93+
#$SCONS platform=ios $OPTIONS $OPTIONS_DOTNET arch=arm64 target=template_release $IOS_SIMULATOR $APPLE_TARGET_ARM64
94+
95+
# x86_64 simulator
96+
$SCONS platform=ios $OPTIONS $OPTIONS_DOTNET arch=x86_64 target=template_debug $IOS_SIMULATOR $APPLE_TARGET_X86_64
97+
$SCONS platform=ios $OPTIONS $OPTIONS_DOTNET arch=x86_64 target=template_release $IOS_SIMULATOR $APPLE_TARGET_X86_64
98+
99+
mkdir -p /root/out/templates-dotnet
100+
cp bin/libgodot.ios.template_release.arm64.a /root/out/templates-dotnet/libgodot.ios.a
101+
cp bin/libgodot.ios.template_debug.arm64.a /root/out/templates-dotnet/libgodot.ios.debug.a
102+
cp bin/libgodot.ios.template_release.x86_64.simulator.a /root/out/templates-dotnet/libgodot.ios.simulator.a
103+
cp bin/libgodot.ios.template_debug.x86_64.simulator.a /root/out/templates-dotnet/libgodot.ios.debug.simulator.a
104+
fi
105+
79106
echo "iOS build successful"

build-linux/build.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set -e
77
export SCONS="scons -j${NUM_CORES} verbose=yes warnings=no progress=no redirect_build_objects=no"
88
export OPTIONS="production=yes accesskit_sdk_path=/root/accesskit/accesskit-c"
99
export OPTIONS_MONO="module_mono_enabled=yes"
10+
export OPTIONS_DOTNET="module_dotnet_enabled=yes"
1011
export TERM=xterm
1112

1213
rm -rf godot
@@ -137,4 +138,62 @@ if [ "${MONO}" == "1" ]; then
137138
rm -rf bin
138139
fi
139140

141+
# .NET
142+
143+
if [ "${DOTNET}" == "1" ]; then
144+
echo "Starting .NET build for Linux..."
145+
146+
export PATH="${GODOT_SDK_LINUX_X86_64}/bin:${BASE_PATH}"
147+
148+
$SCONS platform=linuxbsd arch=x86_64 $OPTIONS $OPTIONS_DOTNET target=editor
149+
mkdir -p /root/out/x86_64/tools-dotnet
150+
cp -rvp bin/* /root/out/x86_64/tools-dotnet
151+
rm -rf bin
152+
153+
$SCONS platform=linuxbsd arch=x86_64 $OPTIONS $OPTIONS_DOTNET target=template_debug
154+
$SCONS platform=linuxbsd arch=x86_64 $OPTIONS $OPTIONS_DOTNET target=template_release
155+
mkdir -p /root/out/x86_64/templates-dotnet
156+
cp -rvp bin/* /root/out/x86_64/templates-dotnet
157+
rm -rf bin
158+
159+
export PATH="${GODOT_SDK_LINUX_X86_32}/bin:${BASE_PATH}"
160+
161+
$SCONS platform=linuxbsd arch=x86_32 $OPTIONS $OPTIONS_DOTNET target=editor
162+
mkdir -p /root/out/x86_32/tools-dotnet
163+
cp -rvp bin/* /root/out/x86_32/tools-dotnet
164+
rm -rf bin
165+
166+
$SCONS platform=linuxbsd arch=x86_32 $OPTIONS $OPTIONS_DOTNET target=template_debug
167+
$SCONS platform=linuxbsd arch=x86_32 $OPTIONS $OPTIONS_DOTNET target=template_release
168+
mkdir -p /root/out/x86_32/templates-dotnet
169+
cp -rvp bin/* /root/out/x86_32/templates-dotnet
170+
rm -rf bin
171+
172+
export PATH="${GODOT_SDK_LINUX_ARM64}/bin:${BASE_PATH}"
173+
174+
$SCONS platform=linuxbsd arch=arm64 $OPTIONS $OPTIONS_DOTNET target=editor
175+
mkdir -p /root/out/arm64/tools-dotnet
176+
cp -rvp bin/* /root/out/arm64/tools-dotnet
177+
rm -rf bin
178+
179+
$SCONS platform=linuxbsd arch=arm64 $OPTIONS $OPTIONS_DOTNET target=template_debug
180+
$SCONS platform=linuxbsd arch=arm64 $OPTIONS $OPTIONS_DOTNET target=template_release
181+
mkdir -p /root/out/arm64/templates-dotnet
182+
cp -rvp bin/* /root/out/arm64/templates-dotnet
183+
rm -rf bin
184+
185+
export PATH="${GODOT_SDK_LINUX_ARM32}/bin:${BASE_PATH}"
186+
187+
$SCONS platform=linuxbsd arch=arm32 $OPTIONS $OPTIONS_DOTNET target=editor
188+
mkdir -p /root/out/arm32/tools-dotnet
189+
cp -rvp bin/* /root/out/arm32/tools-dotnet
190+
rm -rf bin
191+
192+
$SCONS platform=linuxbsd arch=arm32 $OPTIONS $OPTIONS_DOTNET target=template_debug
193+
$SCONS platform=linuxbsd arch=arm32 $OPTIONS $OPTIONS_DOTNET target=template_release
194+
mkdir -p /root/out/arm32/templates-dotnet
195+
cp -rvp bin/* /root/out/arm32/templates-dotnet
196+
rm -rf bin
197+
fi
198+
140199
echo "Linux build successful"

build-macos/build.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set -e
77
export SCONS="scons -j${NUM_CORES} verbose=yes warnings=no progress=no redirect_build_objects=no"
88
export OPTIONS="osxcross_sdk=darwin25 production=yes use_volk=no vulkan_sdk_path=/root/moltenvk angle_libs=/root/angle accesskit_sdk_path=/root/accesskit/accesskit-c SWIFT_FRONTEND=/root/.local/share/swiftly/toolchains/6.2.0/usr/bin/swift-frontend"
99
export OPTIONS_MONO="module_mono_enabled=yes"
10+
export OPTIONS_DOTNET="module_dotnet_enabled=yes"
1011
export TERM=xterm
1112

1213
rm -rf godot
@@ -68,4 +69,29 @@ if [ "${MONO}" == "1" ]; then
6869
rm -rf bin
6970
fi
7071

72+
# .NET
73+
74+
if [ "${DOTNET}" == "1" ]; then
75+
echo "Starting .NET build for macOS..."
76+
77+
$SCONS platform=macos $OPTIONS $OPTIONS_DOTNET arch=x86_64 target=editor
78+
$SCONS platform=macos $OPTIONS $OPTIONS_DOTNET arch=arm64 target=editor
79+
lipo -create bin/godot.macos.editor.x86_64.dotnet bin/godot.macos.editor.arm64.dotnet -output bin/godot.macos.editor.universal.dotnet
80+
81+
mkdir -p /root/out/tools-dotnet
82+
cp -rvp bin/* /root/out/tools-dotnet
83+
rm -rf bin
84+
85+
$SCONS platform=macos $OPTIONS $OPTIONS_DOTNET arch=x86_64 target=template_debug
86+
$SCONS platform=macos $OPTIONS $OPTIONS_DOTNET arch=arm64 target=template_debug
87+
lipo -create bin/godot.macos.template_debug.x86_64.dotnet bin/godot.macos.template_debug.arm64.dotnet -output bin/godot.macos.template_debug.universal.dotnet
88+
$SCONS platform=macos $OPTIONS $OPTIONS_DOTNET arch=x86_64 target=template_release
89+
$SCONS platform=macos $OPTIONS $OPTIONS_DOTNET arch=arm64 target=template_release
90+
lipo -create bin/godot.macos.template_release.x86_64.dotnet bin/godot.macos.template_release.arm64.dotnet -output bin/godot.macos.template_release.universal.dotnet
91+
92+
mkdir -p /root/out/templates-dotnet
93+
cp -rvp bin/* /root/out/templates-dotnet
94+
rm -rf bin
95+
fi
96+
7197
echo "macOS build successful"

0 commit comments

Comments
 (0)