Преглед изворни кода

Add a separate `nativeSrcsConfigs` module to handle Android Studio constraints for native code editor support.

Fredia Huya-Kouadio пре 4 година
родитељ
комит
edf762fba6

+ 1 - 0
.gitignore

@@ -24,6 +24,7 @@ platform/android/java/lib/.cxx/
 platform/android/java/libs/*
 platform/android/java/app/libs/*
 platform/android/java/lib/.cxx/*
+platform/android/java/nativeSrcsConfigs/.cxx/
 
 # General c++ generated files
 *.lib

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

@@ -70,8 +70,8 @@ android {
     buildToolsVersion versions.buildTools
 
     compileOptions {
-        sourceCompatibility 1.8
-        targetCompatibility 1.8
+        sourceCompatibility versions.javaVersion
+        targetCompatibility versions.javaVersion
     }
 
     defaultConfig {

+ 2 - 1
platform/android/java/app/config.gradle

@@ -6,7 +6,8 @@ ext.versions = [
     buildTools         : '30.0.1',
     supportCoreUtils   : '1.0.0',
     kotlinVersion      : '1.4.10',
-    v4Support          : '1.0.0'
+    v4Support          : '1.0.0',
+    javaVersion        : 1.8
 
 ]
 

+ 5 - 15
platform/android/java/lib/build.gradle

@@ -18,6 +18,11 @@ android {
         targetSdkVersion versions.targetSdk
     }
 
+    compileOptions {
+        sourceCompatibility versions.javaVersion
+        targetCompatibility versions.javaVersion
+    }
+
     lintOptions {
         abortOnError false
         disable 'MissingTranslation', 'UnusedResources'
@@ -50,15 +55,6 @@ android {
 
         def buildType = variant.buildType.name.capitalize()
 
-        def taskPrefix = ""
-        if (project.path != ":") {
-            taskPrefix = project.path + ":"
-        }
-
-        // Disable the externalNativeBuild* task as it would cause build failures since the cmake build
-        // files is only setup for editing support.
-        gradle.startParameter.excludedTaskNames += taskPrefix + "externalNativeBuild" + buildType
-
         def releaseTarget = buildType.toLowerCase()
         if (releaseTarget == null || releaseTarget == "") {
             throw new GradleException("Invalid build type: " + buildType)
@@ -78,10 +74,4 @@ android {
         // Schedule the tasks so the generated libs are present before the aar file is packaged.
         tasks["merge${buildType}JniLibFolders"].dependsOn taskName
     }
-
-    externalNativeBuild {
-        cmake {
-            path "CMakeLists.txt"
-        }
-    }
 }

+ 2 - 0
platform/android/java/nativeSrcsConfigs/AndroidManifest.xml

@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest package="org.godotengine.godot" />

+ 1 - 0
platform/android/java/lib/CMakeLists.txt → platform/android/java/nativeSrcsConfigs/CMakeLists.txt

@@ -1,3 +1,4 @@
+# Non functional cmake build file used to provide Android Studio editor support to the project.
 cmake_minimum_required(VERSION 3.6)
 project(godot)
 

+ 4 - 0
platform/android/java/nativeSrcsConfigs/README.md

@@ -0,0 +1,4 @@
+## Native sources configs
+
+This is a non functional Android library used to provide Android Studio editor support to the Godot project native files.
+Nothing else should be added to this library.

+ 54 - 0
platform/android/java/nativeSrcsConfigs/build.gradle

@@ -0,0 +1,54 @@
+// Non functional android library used to provide Android Studio editor support to the project.
+plugins {
+    id 'com.android.library'
+}
+
+android {
+    compileSdkVersion versions.compileSdk
+    buildToolsVersion versions.buildTools
+
+    defaultConfig {
+        minSdkVersion versions.minSdk
+        targetSdkVersion versions.targetSdk
+    }
+
+    compileOptions {
+        sourceCompatibility versions.javaVersion
+        targetCompatibility versions.javaVersion
+    }
+
+    packagingOptions {
+        exclude 'META-INF/LICENSE'
+        exclude 'META-INF/NOTICE'
+
+        // Should be uncommented for development purpose within Android Studio
+        // doNotStrip '**/*.so'
+    }
+
+    sourceSets {
+        main {
+            manifest.srcFile 'AndroidManifest.xml'
+        }
+    }
+
+    externalNativeBuild {
+        cmake {
+            path "CMakeLists.txt"
+        }
+    }
+
+    libraryVariants.all { variant ->
+        def buildType = variant.buildType.name.capitalize()
+
+        def taskPrefix = ""
+        if (project.path != ":") {
+            taskPrefix = project.path + ":"
+        }
+
+        // Disable the externalNativeBuild* task as it would cause build failures since the cmake build
+        // files is only setup for editing support.
+        gradle.startParameter.excludedTaskNames += taskPrefix + "externalNativeBuild" + buildType
+    }
+}
+
+dependencies {}

+ 1 - 0
platform/android/java/settings.gradle

@@ -3,3 +3,4 @@ rootProject.name = "Godot"
 
 include ':app'
 include ':lib'
+include ':nativeSrcsConfigs'