Skip to content

Commit 85b0061

Browse files
committed
Merge pull request #107998 from m4gr3d/update_build_logic
Android: Fix the build logic to generate the native debug symbols
2 parents aa035bc + c376348 commit 85b0061

File tree

6 files changed

+36
-24
lines changed

6 files changed

+36
-24
lines changed

platform/android/SCsub

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,21 @@ if lib_arch_dir != "" and host_subpath != "":
9797
else:
9898
lib_tools_dir = ""
9999

100-
out_dir = "#platform/android/java/lib/libs/" + lib_tools_dir + lib_type_dir + "/" + lib_arch_dir
100+
jni_libs_dir = "#platform/android/java/lib/libs/" + lib_tools_dir + lib_type_dir + "/"
101+
out_dir = jni_libs_dir + lib_arch_dir
101102
env_android.CommandNoCache(out_dir + "/libgodot_android.so", lib, Move("$TARGET", "$SOURCE"))
102103

103104
stl_lib_path = f"{env['ANDROID_NDK_ROOT']}/toolchains/llvm/prebuilt/{host_subpath}/sysroot/usr/lib/{triple_target_dir}/libc++_shared.so"
104105
env_android.CommandNoCache(out_dir + "/libc++_shared.so", stl_lib_path, Copy("$TARGET", "$SOURCE"))
105106

107+
if env["debug_symbols"] and env["separate_debug_symbols"]:
108+
debug_symbols_zip_file = (
109+
("#bin/android-editor-" if env.editor_build else "#bin/android-template-")
110+
+ lib_type_dir
111+
+ "-native-symbols.zip"
112+
)
113+
env_android.NoCache(Zip(debug_symbols_zip_file, jni_libs_dir, ZIPROOT=Dir(jni_libs_dir)))
114+
106115
if env["generate_android_binaries"]:
107116
env_android.AlwaysBuild(
108117
env_android.CommandNoCache(

platform/android/java/app/build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ android {
101101
}
102102

103103
ndk {
104-
debugSymbolLevel 'FULL'
104+
debugSymbolLevel 'NONE'
105105
String[] export_abi_list = getExportEnabledABIs()
106106
abiFilters export_abi_list
107107
}
@@ -127,9 +127,11 @@ android {
127127
exclude 'META-INF/LICENSE'
128128
exclude 'META-INF/NOTICE'
129129

130-
// 'doNotStrip' is enabled for development within Android Studio
130+
// Debug symbols are kept for development within Android Studio.
131131
if (shouldNotStrip()) {
132-
doNotStrip '**/*.so'
132+
jniLibs {
133+
keepDebugSymbols += '**/*.so'
134+
}
133135
}
134136

135137
// Always select Godot's version of libc++_shared.so in case deps have their own

platform/android/java/build.gradle

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,6 @@ def generateBuildTasks(String flavor = "template", String edition = "standard",
176176
from("app/build/outputs/apk/${edition}/${target}") {
177177
include("android_${filenameSuffix}.apk")
178178
}
179-
from("app/build/outputs/native-debug-symbols/${edition}${capitalizedTarget}") {
180-
include("native-debug-symbols.zip")
181-
rename ("native-debug-symbols.zip", "android-template-${edition}-${target}-native-debug-symbols.zip")
182-
}
183179
into(binDir)
184180
}
185181
}
@@ -194,10 +190,6 @@ def generateBuildTasks(String flavor = "template", String edition = "standard",
194190
from("editor/build/outputs/apk/${androidDistro}/${target}") {
195191
include("android_editor-${androidDistro}-${target}*.apk")
196192
}
197-
from("editor/build/outputs/native-debug-symbols/${androidDistro}${capitalizedTarget}") {
198-
include("native-debug-symbols.zip")
199-
rename ("native-debug-symbols.zip", "android-editor-${androidDistro}-${target}-native-debug-symbols.zip")
200-
}
201193
into(androidEditorBuildsDir)
202194
}
203195
}
@@ -323,17 +315,11 @@ task cleanGodotTemplates(type: Delete) {
323315

324316
// Delete the Godot templates in the Godot bin directory
325317
delete("$binDir/android_debug.apk")
326-
delete("$binDir/android-template-standard-debug-native-debug-symbols.zip")
327318
delete("$binDir/android_dev.apk")
328-
delete("$binDir/android-template-standard-dev-native-debug-symbols.zip")
329319
delete("$binDir/android_release.apk")
330-
delete("$binDir/android-template-standard-release-native-debug-symbols.zip")
331320
delete("$binDir/android_monoDebug.apk")
332-
delete("$binDir/android-template-mono-debug-native-debug-symbols.zip")
333321
delete("$binDir/android_monoDev.apk")
334-
delete("$binDir/android-template-mono-dev-native-debug-symbols.zip")
335322
delete("$binDir/android_monoRelease.apk")
336-
delete("$binDir/android-template-mono-release-native-debug-symbols.zip")
337323
delete("$binDir/android_source.zip")
338324
delete("$binDir/godot-lib.template_debug.aar")
339325
delete("$binDir/godot-lib.template_debug.dev.aar")
@@ -343,4 +329,12 @@ task cleanGodotTemplates(type: Delete) {
343329
delete("$binDir/godot-lib.debug.aar")
344330
delete("$binDir/godot-lib.dev.aar")
345331
delete("$binDir/godot-lib.release.aar")
332+
333+
// Delete the native debug symbols files.
334+
delete("$binDir/android-editor-debug-native-symbols.zip")
335+
delete("$binDir/android-editor-dev-native-symbols.zip")
336+
delete("$binDir/android-editor-release-native-symbols.zip")
337+
delete("$binDir/android-template-debug-native-symbols.zip")
338+
delete("$binDir/android-template-dev-native-symbols.zip")
339+
delete("$binDir/android-template-release-native-symbols.zip")
346340
}

platform/android/java/editor/build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ android {
9090
editorBuildSuffix: ""
9191
]
9292

93-
ndk { debugSymbolLevel 'FULL' }
93+
ndk { debugSymbolLevel 'NONE' }
9494
}
9595

9696
base {
@@ -141,9 +141,11 @@ android {
141141
}
142142

143143
packagingOptions {
144-
// 'doNotStrip' is enabled for development within Android Studio
144+
// Debug symbols are kept for development within Android Studio.
145145
if (shouldNotStrip()) {
146-
doNotStrip '**/*.so'
146+
jniLibs {
147+
keepDebugSymbols += '**/*.so'
148+
}
147149
}
148150
}
149151

platform/android/java/lib/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ android {
6767
exclude 'META-INF/LICENSE'
6868
exclude 'META-INF/NOTICE'
6969

70-
// 'doNotStrip' is enabled for development within Android Studio
70+
// Debug symbols are kept for development within Android Studio.
7171
if (shouldNotStrip()) {
72-
doNotStrip '**/*.so'
72+
jniLibs {
73+
keepDebugSymbols += '**/*.so'
74+
}
7375
}
7476
}
7577

platform/android/platform_android_builders.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ def generate_android_binaries(target, source, env):
1919
if env["target"] == "editor":
2020
gradle_process += ["generateGodotEditor", "generateGodotHorizonOSEditor", "generateGodotPicoOSEditor"]
2121
else:
22-
gradle_process += ["generateGodotTemplates"]
22+
if env["module_mono_enabled"]:
23+
gradle_process += ["generateGodotMonoTemplates"]
24+
else:
25+
gradle_process += ["generateGodotTemplates"]
2326
gradle_process += ["--quiet"]
2427

2528
if env["debug_symbols"] and not env["separate_debug_symbols"]:

0 commit comments

Comments
 (0)