Pārlūkot izejas kodu

Merge pull request #46374 from m4gr3d/add_godot_engine_version_master

Record the version of the Godot engine for the Android platform
Rémi Verschelde 4 gadi atpakaļ
vecāks
revīzija
037e7d8777

+ 1 - 0
platform/android/export/export.cpp

@@ -2553,6 +2553,7 @@ public:
 			cmdline.push_back("-Pplugins_maven_repos=" + custom_maven_repos); // argument to specify the list of custom maven repos for the plugins dependencies.
 			cmdline.push_back("-Pplugins_maven_repos=" + custom_maven_repos); // argument to specify the list of custom maven repos for the plugins dependencies.
 			cmdline.push_back("-Pperform_zipalign=" + zipalign_flag); // argument to specify whether the build should be zipaligned.
 			cmdline.push_back("-Pperform_zipalign=" + zipalign_flag); // argument to specify whether the build should be zipaligned.
 			cmdline.push_back("-Pperform_signing=" + sign_flag); // argument to specify whether the build should be signed.
 			cmdline.push_back("-Pperform_signing=" + sign_flag); // argument to specify whether the build should be signed.
+			cmdline.push_back("-Pgodot_editor_version=" + String(VERSION_FULL_CONFIG));
 
 
 			// NOTE: The release keystore is not included in the verbose logging
 			// NOTE: The release keystore is not included in the verbose logging
 			// to avoid accidentally leaking sensitive information when sharing verbose logs for troubleshooting.
 			// to avoid accidentally leaking sensitive information when sharing verbose logs for troubleshooting.

+ 5 - 0
platform/android/java/app/AndroidManifest.xml

@@ -22,6 +22,11 @@
         tools:ignore="GoogleAppIndexingWarning"
         tools:ignore="GoogleAppIndexingWarning"
         android:icon="@mipmap/icon" >
         android:icon="@mipmap/icon" >
 
 
+        <!-- Records the version of the Godot editor used for building -->
+        <meta-data
+            android:name="org.godotengine.editor.version"
+            android:value="${godotEditorVersion}" />
+
         <!-- The following metadata values are replaced when Godot exports, modifying them here has no effect. -->
         <!-- The following metadata values are replaced when Godot exports, modifying them here has no effect. -->
         <!-- Do these changes in the export preset. Adding new ones is fine. -->
         <!-- Do these changes in the export preset. Adding new ones is fine. -->
 
 

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

@@ -85,6 +85,8 @@ android {
             abiFilters export_abi_list
             abiFilters export_abi_list
         }
         }
 
 
+        manifestPlaceholders = [godotEditorVersion: getGodotEditorVersion()]
+
         // Feel free to modify the application id to your own.
         // Feel free to modify the application id to your own.
         applicationId getExportPackageName()
         applicationId getExportPackageName()
         versionCode getExportVersionCode()
         versionCode getExportVersionCode()

+ 49 - 0
platform/android/java/app/config.gradle

@@ -50,6 +50,55 @@ ext.getExportVersionName = { ->
     return versionName
     return versionName
 }
 }
 
 
+ext.getGodotEditorVersion = { ->
+    String editorVersion = project.hasProperty("godot_editor_version") ? project.property("godot_editor_version") : ""
+    if (editorVersion == null || editorVersion.isEmpty()) {
+        // Try the library version first
+        editorVersion = getGodotLibraryVersion()
+
+        if (editorVersion.isEmpty()) {
+            // Fallback value.
+            editorVersion = "custom_build"
+        }
+    }
+    return editorVersion
+}
+
+ext.getGodotLibraryVersion = { ->
+    // Attempt to read the version from the `version.py` file.
+    String libraryVersion = ""
+
+    File versionFile = new File("../../../version.py")
+    if (versionFile.isFile()) {
+        List<String> requiredKeys = ["major", "minor", "patch", "status", "module_config"]
+        def map = [:]
+
+        List<String> lines = versionFile.readLines()
+        for (String line in lines) {
+            String[] keyValue = line.split("=")
+            String key = keyValue[0].trim()
+            String value = keyValue[1].trim().replaceAll("\"", "")
+
+            if (requiredKeys.contains(key)) {
+                if (!value.isEmpty()) {
+                    map[key] = value
+                }
+                requiredKeys.remove(key)
+            }
+        }
+
+        if (requiredKeys.empty) {
+            libraryVersion = map.values().join(".")
+        }
+    }
+
+    if (libraryVersion.isEmpty()) {
+        // Fallback value in case we're unable to read the file.
+        libraryVersion = "custom_build"
+    }
+    return libraryVersion
+}
+
 final String PLUGIN_VALUE_SEPARATOR_REGEX = "\\|"
 final String PLUGIN_VALUE_SEPARATOR_REGEX = "\\|"
 
 
 // get the list of ABIs the project should be exported to
 // get the list of ABIs the project should be exported to

+ 0 - 6
platform/android/java/build.gradle

@@ -165,12 +165,6 @@ task cleanGodotTemplates(type: Delete) {
     // Delete the library generated AAR files
     // Delete the library generated AAR files
     delete("lib/build/outputs/aar")
     delete("lib/build/outputs/aar")
 
 
-    // Delete the godotpayment libs directory contents
-    delete("plugins/godotpayment/libs")
-
-    // Delete the generated godotpayment aar
-    delete("plugins/godotpayment/build/outputs/aar")
-
     // Delete the app libs directory contents
     // Delete the app libs directory contents
     delete("app/libs")
     delete("app/libs")
 
 

+ 5 - 0
platform/android/java/lib/AndroidManifest.xml

@@ -6,6 +6,11 @@
 
 
     <application>
     <application>
 
 
+        <!-- Records the version of the Godot library -->
+        <meta-data
+            android:name="org.godotengine.library.version"
+            android:value="${godotLibraryVersion}" />
+
         <service android:name=".GodotDownloaderService" />
         <service android:name=".GodotDownloaderService" />
 
 
     </application>
     </application>

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

@@ -18,6 +18,8 @@ android {
     defaultConfig {
     defaultConfig {
         minSdkVersion versions.minSdk
         minSdkVersion versions.minSdk
         targetSdkVersion versions.targetSdk
         targetSdkVersion versions.targetSdk
+
+        manifestPlaceholders = [godotLibraryVersion: getGodotLibraryVersion()]
     }
     }
 
 
     compileOptions {
     compileOptions {