Browse Source

Merge pull request #105605 from m4gr3d/setup_debug_symbols

Android: Enable native debug symbols generation
Thaddeus Crews 3 months ago
parent
commit
34cb8999b0

+ 6 - 4
platform/android/SCsub

@@ -86,7 +86,7 @@ if lib_arch_dir != "":
     )
     env_android.CommandNoCache(out_dir + "/libc++_shared.so", stl_lib_path, Copy("$TARGET", "$SOURCE"))
 
-    def generate_apk(target, source, env):
+    def generate_android_binaries(target, source, env):
         gradle_process = []
 
         if sys.platform.startswith("win"):
@@ -103,7 +103,7 @@ if lib_arch_dir != "":
             "--quiet",
         ]
 
-        if env["debug_symbols"]:
+        if env["gradle_do_not_strip"]:
             gradle_process += ["-PdoNotStrip=true"]
 
         subprocess.run(
@@ -111,5 +111,7 @@ if lib_arch_dir != "":
             cwd="platform/android/java",
         )
 
-    if env["generate_apk"]:
-        env_android.AlwaysBuild(env_android.CommandNoCache("generate_apk", lib, env.Run(generate_apk)))
+    if env["generate_android_binaries"]:
+        env_android.AlwaysBuild(
+            env_android.CommandNoCache("generate_android_binaries", lib, env.Run(generate_android_binaries))
+        )

+ 6 - 1
platform/android/detect.py

@@ -34,8 +34,13 @@ def get_opts():
             "android-" + str(get_min_target_api()),
         ),
         BoolVariable("store_release", "Editor build for Google Play Store (for official builds only)", False),
-        BoolVariable("generate_apk", "Generate an APK/AAB after building Android library by calling Gradle", False),
+        BoolVariable(
+            "generate_android_binaries",
+            "Generate APK, AAB & AAR binaries after building Android library by calling Gradle",
+            False,
+        ),
         BoolVariable("swappy", "Use Swappy Frame Pacing library", False),
+        BoolVariable("gradle_do_not_strip", "Whether Gradle should strip the Android *.so libraries or not", False),
     ]
 
 

+ 1 - 0
platform/android/java/app/build.gradle

@@ -101,6 +101,7 @@ android {
         }
 
         ndk {
+            debugSymbolLevel 'FULL'
             String[] export_abi_list = getExportEnabledABIs()
             abiFilters export_abi_list
         }

+ 20 - 17
platform/android/java/build.gradle

@@ -173,9 +173,14 @@ def generateBuildTasks(String flavor = "template", String edition = "standard",
                     buildTasks += tasks.create(name: copyBinaryTaskName, type: Copy) {
                         String filenameSuffix = edition == "mono" ? "${edition}${capitalizedTarget}" : target
                         dependsOn ":app:assemble${capitalizedEdition}${capitalizedTarget}"
-                        from("app/build/outputs/apk/${edition}/${target}")
+                        from("app/build/outputs/apk/${edition}/${target}") {
+                            include("android_${filenameSuffix}.apk")
+                        }
+                        from("app/build/outputs/native-debug-symbols/${edition}${capitalizedTarget}") {
+                            include("native-debug-symbols.zip")
+                            rename ("native-debug-symbols.zip", "android-template-${edition}-${target}-native-debug-symbols.zip")
+                        }
                         into(binDir)
-                        include("android_${filenameSuffix}.apk")
                     }
                 }
             } else {
@@ -186,9 +191,14 @@ def generateBuildTasks(String flavor = "template", String edition = "standard",
                 } else {
                     buildTasks += tasks.create(name: copyEditorApkTaskName, type: Copy) {
                         dependsOn ":editor:assemble${capitalizedAndroidDistro}${capitalizedTarget}"
-                        from("editor/build/outputs/apk/${androidDistro}/${target}")
+                        from("editor/build/outputs/apk/${androidDistro}/${target}") {
+                            include("android_editor-${androidDistro}-${target}*.apk")
+                        }
+                        from("editor/build/outputs/native-debug-symbols/${androidDistro}${capitalizedTarget}") {
+                            include("native-debug-symbols.zip")
+                            rename ("native-debug-symbols.zip", "android-editor-${androidDistro}-${target}-native-debug-symbols.zip")
+                        }
                         into(androidEditorBuildsDir)
-                        include("android_editor-${androidDistro}-${target}*.apk")
                     }
                 }
 
@@ -270,19 +280,6 @@ task generateGodotMonoTemplates {
     finalizedBy 'zipGradleBuild'
 }
 
-/**
- * Generates the same output as generateGodotTemplates but with dev symbols
- */
-task generateDevTemplate {
-    // add parameter to set symbols to true
-    project.ext.doNotStrip = "true"
-
-    gradle.startParameter.excludedTaskNames += templateExcludedBuildTask()
-    dependsOn = generateBuildTasks("template")
-
-    finalizedBy 'zipGradleBuild'
-}
-
 task clean(type: Delete) {
     dependsOn 'cleanGodotEditor'
     dependsOn 'cleanGodotTemplates'
@@ -326,11 +323,17 @@ task cleanGodotTemplates(type: Delete) {
 
     // Delete the Godot templates in the Godot bin directory
     delete("$binDir/android_debug.apk")
+    delete("$binDir/android-template-standard-debug-native-debug-symbols.zip")
     delete("$binDir/android_dev.apk")
+    delete("$binDir/android-template-standard-dev-native-debug-symbols.zip")
     delete("$binDir/android_release.apk")
+    delete("$binDir/android-template-standard-release-native-debug-symbols.zip")
     delete("$binDir/android_monoDebug.apk")
+    delete("$binDir/android-template-mono-debug-native-debug-symbols.zip")
     delete("$binDir/android_monoDev.apk")
+    delete("$binDir/android-template-mono-dev-native-debug-symbols.zip")
     delete("$binDir/android_monoRelease.apk")
+    delete("$binDir/android-template-mono-release-native-debug-symbols.zip")
     delete("$binDir/android_source.zip")
     delete("$binDir/godot-lib.template_debug.aar")
     delete("$binDir/godot-lib.template_debug.dev.aar")

+ 2 - 0
platform/android/java/editor/build.gradle

@@ -89,6 +89,8 @@ android {
             editorAppName: "Godot Engine 4",
             editorBuildSuffix: ""
         ]
+
+        ndk { debugSymbolLevel 'FULL' }
     }
 
     base {