2
0
Эх сурвалжийг харах

Android - only build Urho3DPlayer for STATIC lib type.

Yao Wei Tjong 姚伟忠 5 жил өмнө
parent
commit
c13dd61ec2

+ 3 - 3
android/launcher-app/build.gradle.kts

@@ -42,9 +42,9 @@ android {
                 arguments.apply {
                     System.getenv("ANDROID_CCACHE")?.let { add("-D ANDROID_CCACHE=$it") }
                     add("-D GRADLE_BUILD_DIR=${findProject(":android:urho3d-lib")?.buildDir}")
-                    // In order to get clean module segregation, only build player/samples here
-                    val includes = listOf("URHO3D_PLAYER", "URHO3D_SAMPLES")
-                    addAll(includes.map { "-D $it=1" })
+                    // Only enable 'URHO3D_PLAYER' build option for 'STATIC' lib type to reduce the spacetime requirement
+                    add("-D URHO3D_PLAYER=1")
+                    add("-D URHO3D_SAMPLES=${if (project.libraryType == "STATIC") "0" else "1"}")
                     // Pass along matching Gradle properties (higher precedence) or env-vars as CMake build options
                     val vars = project.file("../../script/.build-options").readLines()
                     addAll(vars

+ 1 - 4
android/urho3d-lib/build.gradle.kts

@@ -184,7 +184,7 @@ publishing {
     publications {
         register<MavenPublication>("Urho") {
             groupId = project.group.toString()
-            artifactId = "${project.name}-${project.libraryType}"
+            artifactId = "${project.name}-${project.libraryType.toLowerCase()}"
             if (project.hasProperty("ANDROID_ABI")) {
                 artifactId = "$artifactId-${(project.property("ANDROID_ABI") as String).replace(',', '-')}"
             }
@@ -235,6 +235,3 @@ publishing {
         }
     }
 }
-
-val Project.libraryType: String
-    get() = findProperty("URHO3D_LIB_TYPE") as String? ?: System.getenv("URHO3D_LIB_TYPE") ?: "static"

+ 7 - 2
buildSrc/src/main/kotlin/UrhoCommon.kt

@@ -20,6 +20,7 @@
 // THE SOFTWARE.
 //
 
+import org.gradle.api.Project
 import org.gradle.plugin.use.PluginDependenciesSpec
 import org.gradle.plugin.use.PluginDependencySpec
 import java.io.File
@@ -32,11 +33,15 @@ const val cmakeVersion = "3.17.3+"
  *
  * Current supported platforms: android.
  */
-@Suppress("unused")
 fun PluginDependenciesSpec.urho3d(platform: String): PluginDependencySpec = id("io.urho3d.$platform")
 
 /**
  * Naive implementation of "touch" command.
  */
-@Suppress("unused")
 fun File.touch() = createNewFile() || setLastModified(System.currentTimeMillis())
+
+/**
+ * Return the Urho3D library type. Default to 'STATIC' when it is not explicitly specified.
+ */
+val Project.libraryType: String
+    get() = findProperty("URHO3D_LIB_TYPE") as String? ?: System.getenv("URHO3D_LIB_TYPE") ?: "STATIC"