From f72b47c9ae53095ccc75d8b0a47188782c2bee01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Owodzin=CC=81?= Date: Tue, 16 Feb 2021 00:17:38 +0000 Subject: [PATCH 1/3] build config changes * updated iosMain/c_interop to nativeInterop/cinterop (fixes #139) * hierarchical project structure (#137) * gradle cleanup & enabled parallel builds --- .gitignore | 14 ++-- build.gradle.kts | 16 ++-- firebase-app/build.gradle.kts | 61 +++++++++----- .../cinterop}/Cartfile | 0 .../cinterop}/FirebaseCore.def | 1 + firebase-auth/build.gradle.kts | 70 +++++++++------- .../cinterop}/Cartfile | 0 .../cinterop}/FirebaseAuth.def | 1 + firebase-common/build.gradle.kts | 47 ++++++----- firebase-database/build.gradle.kts | 80 +++++++++++------- .../dev/gitlive/firebase/database/database.kt | 1 - .../cinterop}/Cartfile | 0 .../cinterop}/FirebaseDatabase.def | 1 + firebase-firestore/build.gradle.kts | 81 +++++++++++-------- .../cinterop}/Cartfile | 0 .../cinterop}/FirebaseFirestore.def | 1 + firebase-functions/build.gradle.kts | 79 +++++++++++------- .../cinterop}/Cartfile | 0 .../cinterop}/FirebaseFunctions.def | 1 + gradle.properties | 16 +++- 20 files changed, 287 insertions(+), 183 deletions(-) rename firebase-app/src/{iosMain/c_interop => nativeInterop/cinterop}/Cartfile (100%) rename firebase-app/src/{iosMain/c_interop => nativeInterop/cinterop}/FirebaseCore.def (92%) rename firebase-auth/src/{iosMain/c_interop => nativeInterop/cinterop}/Cartfile (100%) rename firebase-auth/src/{iosMain/c_interop => nativeInterop/cinterop}/FirebaseAuth.def (82%) rename firebase-database/src/{iosMain/c_interop => nativeInterop/cinterop}/Cartfile (100%) rename firebase-database/src/{iosMain/c_interop => nativeInterop/cinterop}/FirebaseDatabase.def (81%) rename firebase-firestore/src/{iosMain/c_interop => nativeInterop/cinterop}/Cartfile (100%) rename firebase-firestore/src/{iosMain/c_interop => nativeInterop/cinterop}/FirebaseFirestore.def (89%) rename firebase-functions/src/{iosMain/c_interop => nativeInterop/cinterop}/Cartfile (100%) rename firebase-functions/src/{iosMain/c_interop => nativeInterop/cinterop}/FirebaseFunctions.def (81%) diff --git a/.gitignore b/.gitignore index 3d9baca2b..8ff5d1266 100644 --- a/.gitignore +++ b/.gitignore @@ -5,16 +5,16 @@ local.properties /**/*.iml *.iml -firebase-app/src/iosMain/c_interop/modules/ -firebase-functions/src/iosMain/c_interop/modules/ -firebase-auth/src/iosMain/c_interop/modules/ -firebase-firestore/src/iosMain/c_interop/modules/ -firebase-database/src/iosMain/c_interop/modules/ +firebase-app/src/nativeInterop/cinterop/modules/ +firebase-functions/src/nativeInterop/cinterop/modules/ +firebase-auth/src/nativeInterop/cinterop/modules/ +firebase-firestore/src/nativeInterop/cinterop/modules/ +firebase-database/src/nativeInterop/cinterop/modules/ Firebase*.zip /Firebase /.DS_Store *.log -/**/Cartfile.resolved -/**/c_interop/Carthage/ +/**/nativeInterop/cinterop/Cartfile.resolved +/**/nativeInterop/cinterop/Carthage/ diff --git a/build.gradle.kts b/build.gradle.kts index 2441b6cfd..9c4f48816 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,11 +1,10 @@ -import de.undercouch.gradle.tasks.download.Download +import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties import org.apache.tools.ant.taskdefs.condition.Os import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.api.tasks.testing.logging.TestLogEvent plugins { kotlin("multiplatform") version "1.4.21" apply false - id("de.undercouch.download").version("4.1.1") id("base") } @@ -20,7 +19,6 @@ buildscript { } dependencies { classpath("com.android.tools.build:gradle:4.1.1") - classpath("de.undercouch:gradle-download-task:4.1.1") classpath("com.adarshr:gradle-test-logger-plugin:2.0.0") } } @@ -43,6 +41,10 @@ tasks { subprojects { + // temp fix for https://youtrack.jetbrains.com/issue/KT-35011 + // add ideaActive=true for local development + val ideaActive by extra { gradleLocalProperties(rootDir)["idea.active"] == "true" } + group = "dev.gitlive" apply(plugin="com.adarshr.test-logger") @@ -155,7 +157,7 @@ subprojects { executable = "carthage" args( it, - "--project-directory", "src/iosMain/c_interop", + "--project-directory", projectDir.resolve("src/nativeInterop/cinterop"), "--platform", "iOS", "--cache-builds" ) @@ -170,8 +172,10 @@ subprojects { create("carthageClean", Delete::class.java) { group = "carthage" - delete(File("$projectDir/src/iosMain/c_interop/Carthage")) - delete(File("$projectDir/src/iosMain/c_interop/Cartfile.resolved")) + delete( + projectDir.resolve("src/nativeInterop/cinterop/Carthage"), + projectDir.resolve("src/nativeInterop/cinterop/Cartfile.resolved") + ) } } diff --git a/firebase-app/build.gradle.kts b/firebase-app/build.gradle.kts index 478d245e1..0608f88d1 100644 --- a/firebase-app/build.gradle.kts +++ b/firebase-app/build.gradle.kts @@ -1,6 +1,9 @@ /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ + +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget + version = project.property("firebase-app.version") as String plugins { @@ -41,47 +44,67 @@ android { } kotlin { - js { - useCommonJs() - nodejs() - browser() - } + android { - publishLibraryVariants("release", "debug") + publishAllLibraryVariants() } - val iosArm64 = iosArm64() - val iosX64 = iosX64("ios") { + fun nativeTargetConfig(): KotlinNativeTarget.() -> Unit = { + val nativeFrameworkPaths = listOf( + projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/iOS") + ) + binaries { getTest("DEBUG").apply { - linkerOpts("-F$projectDir/src/iosMain/c_interop/Carthage/Build/iOS/") + linkerOpts(nativeFrameworkPaths.map { "-F$it" }) linkerOpts("-ObjC") } } + + compilations.getByName("main") { + cinterops.create("FirebaseCore") { + compilerOpts(nativeFrameworkPaths.map { "-F$it" }) + extraOpts("-verbose") + } + } + } + + if (project.extra["ideaActive"] as Boolean) { + iosX64("ios", nativeTargetConfig()) + } else { + ios(configure = nativeTargetConfig()) + } + + js { + useCommonJs() + nodejs() + browser() } sourceSets { + all { + languageSettings.apply { + apiVersion = "1.4" + languageVersion = "1.4" + progressiveMode = true + } + } + val commonMain by getting { dependencies { implementation(project(":firebase-common")) } } + val androidMain by getting { dependencies { api("com.google.firebase:firebase-common:19.5.0") } } - configure(listOf(iosArm64, iosX64)) { - compilations.getByName("main") { - source(sourceSets.get("iosMain")) - val firebasecore by cinterops.creating { - packageName("cocoapods.FirebaseCore") - defFile(file("$projectDir/src/iosMain/c_interop/FirebaseCore.def")) - compilerOpts("-F$projectDir/src/iosMain/c_interop/Carthage/Build/iOS/") - } - } - } + val iosMain by getting + + val jsMain by getting } } diff --git a/firebase-app/src/iosMain/c_interop/Cartfile b/firebase-app/src/nativeInterop/cinterop/Cartfile similarity index 100% rename from firebase-app/src/iosMain/c_interop/Cartfile rename to firebase-app/src/nativeInterop/cinterop/Cartfile diff --git a/firebase-app/src/iosMain/c_interop/FirebaseCore.def b/firebase-app/src/nativeInterop/cinterop/FirebaseCore.def similarity index 92% rename from firebase-app/src/iosMain/c_interop/FirebaseCore.def rename to firebase-app/src/nativeInterop/cinterop/FirebaseCore.def index d99f9484a..929f70092 100644 --- a/firebase-app/src/iosMain/c_interop/FirebaseCore.def +++ b/firebase-app/src/nativeInterop/cinterop/FirebaseCore.def @@ -1,4 +1,5 @@ language = Objective-C +package = cocoapods.FirebaseCore modules = FirebaseCore compilerOpts = -framework FirebaseCore linkerOpts = -framework FirebaseCore -framework FirebaseCoreDiagnostics -framework FirebaseAnalytics -framework FIRAnalyticsConnector -framework GoogleAppMeasurement -framework FirebaseInstallations -framework GoogleDataTransport -framework GoogleUtilities -framework PromisesObjC -framework nanopb -framework StoreKit -lsqlite3 diff --git a/firebase-auth/build.gradle.kts b/firebase-auth/build.gradle.kts index 0de4b4231..e14f44b09 100644 --- a/firebase-auth/build.gradle.kts +++ b/firebase-auth/build.gradle.kts @@ -1,6 +1,9 @@ /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ + +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget + version = project.property("firebase-auth.version") as String plugins { @@ -65,34 +68,54 @@ android { //} kotlin { - js { - useCommonJs() - nodejs() - browser() - } + android { - publishLibraryVariants("release", "debug") + publishAllLibraryVariants() } - val iosArm64 = iosArm64() - val iosX64 = iosX64("ios") { + + fun nativeTargetConfig(): KotlinNativeTarget.() -> Unit = { + val nativeFrameworkPaths = listOf( + rootProject.project("firebase-app").projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/iOS"), + projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/iOS") + ) + binaries { getTest("DEBUG").apply { - linkerOpts( - "-F${rootProject.projectDir}/firebase-app/src/iosMain/c_interop/Carthage/Build/iOS/", - "-F$projectDir/src/iosMain/c_interop/Carthage/Build/iOS/") + linkerOpts(nativeFrameworkPaths.map { "-F$it" }) linkerOpts("-ObjC") } } + + compilations.getByName("main") { + cinterops.create("FirebaseAuth") { + compilerOpts(nativeFrameworkPaths.map { "-F$it" }) + extraOpts("-verbose") + } + } } - tasks.withType> { - kotlinOptions.freeCompilerArgs += listOf( - "-Xuse-experimental=kotlin.Experimental", - "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi" - ) + if (project.extra["ideaActive"] as Boolean) { + iosX64("ios", nativeTargetConfig()) + } else { + ios(configure = nativeTargetConfig()) + } + + js { + useCommonJs() + nodejs() + browser() } sourceSets { + all { + languageSettings.apply { + apiVersion = "1.4" + languageVersion = "1.4" + progressiveMode = true + useExperimentalAnnotation("kotlinx.coroutines.ExperimentalCoroutinesApi") + } + } + val commonMain by getting { dependencies { api(project(":firebase-app")) @@ -106,18 +129,9 @@ kotlin { } } - configure(listOf(iosArm64, iosX64)) { - compilations.getByName("main") { - source(sourceSets.get("iosMain")) - val firebaseAuth by cinterops.creating { - packageName("cocoapods.FirebaseAuth") - defFile(file("$projectDir/src/iosMain/c_interop/FirebaseAuth.def")) - compilerOpts( - "-F$projectDir/src/iosMain/c_interop/Carthage/Build/iOS/" - ) - } - } - } + val iosMain by getting + + val jsMain by getting } } diff --git a/firebase-auth/src/iosMain/c_interop/Cartfile b/firebase-auth/src/nativeInterop/cinterop/Cartfile similarity index 100% rename from firebase-auth/src/iosMain/c_interop/Cartfile rename to firebase-auth/src/nativeInterop/cinterop/Cartfile diff --git a/firebase-auth/src/iosMain/c_interop/FirebaseAuth.def b/firebase-auth/src/nativeInterop/cinterop/FirebaseAuth.def similarity index 82% rename from firebase-auth/src/iosMain/c_interop/FirebaseAuth.def rename to firebase-auth/src/nativeInterop/cinterop/FirebaseAuth.def index 7a8049da5..0cba7b3c3 100644 --- a/firebase-auth/src/iosMain/c_interop/FirebaseAuth.def +++ b/firebase-auth/src/nativeInterop/cinterop/FirebaseAuth.def @@ -1,4 +1,5 @@ language = Objective-C +package = cocoapods.FirebaseAuth modules = FirebaseAuth compilerOpts = -framework FirebaseAuth linkerOpts = -framework FirebaseAuth -framework GTMSessionFetcher diff --git a/firebase-common/build.gradle.kts b/firebase-common/build.gradle.kts index b08a31760..fa40d4144 100644 --- a/firebase-common/build.gradle.kts +++ b/firebase-common/build.gradle.kts @@ -39,52 +39,51 @@ android { } kotlin { - js { - useCommonJs() - nodejs() - browser() - } + android { - publishLibraryVariants("release", "debug") + publishAllLibraryVariants() } - val iosArm64 = iosArm64() - val iosX64 = iosX64("ios") + ios() - tasks.withType> { - kotlinOptions.freeCompilerArgs += listOf( - "-Xuse-experimental=kotlin.Experimental", - "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", - "-Xuse-experimental=kotlinx.serialization.ExperimentalSerializationApi", - "-Xuse-experimental=kotlinx.serialization.InternalSerializationApi" - ) + js { + useCommonJs() + nodejs() + browser() } sourceSets { + all { + languageSettings.apply { + apiVersion = "1.4" + languageVersion = "1.4" + progressiveMode = true + useExperimentalAnnotation("kotlin.Experimental") + useExperimentalAnnotation("kotlinx.coroutines.ExperimentalCoroutinesApi") + useExperimentalAnnotation("kotlinx.serialization.ExperimentalSerializationApi") + useExperimentalAnnotation("kotlinx.serialization.InternalSerializationApi") + } + } + val commonMain by getting { dependencies { api("org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.1") } } + val androidMain by getting { dependencies { api("com.google.firebase:firebase-common:19.5.0") } } + + val iosMain by getting + val jsMain by getting { dependencies { api(npm("firebase", "8.2.0")) } } - val iosMain by getting { - dependencies { - } - } - configure(listOf(iosArm64, iosX64)) { - compilations.getByName("main") { - source(sourceSets.get("iosMain")) - } - } } } diff --git a/firebase-database/build.gradle.kts b/firebase-database/build.gradle.kts index 9996457ce..a482f5fca 100644 --- a/firebase-database/build.gradle.kts +++ b/firebase-database/build.gradle.kts @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. + */ + +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget + version = project.property("firebase-database.version") as String plugins { @@ -38,60 +44,72 @@ android { } kotlin { - js { - useCommonJs() - nodejs() - browser() - } + android { - publishLibraryVariants("release", "debug") + publishAllLibraryVariants() } - val iosArm64 = iosArm64() - val iosX64 = iosX64("ios") { + + fun nativeTargetConfig(): KotlinNativeTarget.() -> Unit = { + val nativeFrameworkPaths = listOf( + rootProject.project("firebase-app").projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/iOS"), + projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/iOS") + ) + binaries { getTest("DEBUG").apply { - linkerOpts( - "-F${rootProject.projectDir}/firebase-app/src/iosMain/c_interop/Carthage/Build/iOS/", - "-F$projectDir/src/iosMain/c_interop/Carthage/Build/iOS/" - ) + linkerOpts(nativeFrameworkPaths.map { "-F$it" }) linkerOpts("-ObjC") } } + + compilations.getByName("main") { + cinterops.create("FirebaseDatabase") { + compilerOpts(nativeFrameworkPaths.map { "-F$it" }) + extraOpts("-verbose") + } + } } - tasks.withType> { - kotlinOptions.freeCompilerArgs += listOf( - "-Xuse-experimental=kotlin.Experimental", - "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", - "-Xuse-experimental=kotlinx.serialization.InternalSerializationApi" - ) + if (project.extra["ideaActive"] as Boolean) { + iosX64("ios", nativeTargetConfig()) + } else { + ios(configure = nativeTargetConfig()) + } + + js { + useCommonJs() + nodejs() + browser() } sourceSets { + all { + languageSettings.apply { + apiVersion = "1.4" + languageVersion = "1.4" + progressiveMode = true + useExperimentalAnnotation("kotlinx.coroutines.ExperimentalCoroutinesApi") + useExperimentalAnnotation("kotlinx.coroutines.FlowPreview") + useExperimentalAnnotation("kotlinx.serialization.InternalSerializationApi") + } + } + val commonMain by getting { dependencies { api(project(":firebase-app")) implementation(project(":firebase-common")) } } + val androidMain by getting { dependencies { api("com.google.firebase:firebase-database:19.6.0") } } - val jsMain by getting {} - val iosMain by getting {} - - configure(listOf(iosArm64, iosX64)) { - compilations.getByName("main") { - source(sourceSets.get("iosMain")) - val firebaseDatabase by cinterops.creating { - packageName("cocoapods.FirebaseDatabase") - defFile(file("$projectDir/src/iosMain/c_interop/FirebaseDatabase.def")) - compilerOpts("-F$projectDir/src/iosMain/c_interop/Carthage/Build/iOS/") - } - } - } + + val iosMain by getting + + val jsMain by getting } } diff --git a/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt index d25021de4..f3dce059a 100644 --- a/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt @@ -34,7 +34,6 @@ internal inline fun encode(value: T, shouldEncodeElementDefault: Boo internal fun encode(strategy: SerializationStrategy , value: T, shouldEncodeElementDefault: Boolean): Any? = dev.gitlive.firebase.encode(strategy, value, shouldEncodeElementDefault, ServerValue.TIMESTAMP) -@OptIn(FlowPreview::class) suspend fun Task.awaitWhileOnline(): T = coroutineScope { val notConnected = Firebase.database diff --git a/firebase-database/src/iosMain/c_interop/Cartfile b/firebase-database/src/nativeInterop/cinterop/Cartfile similarity index 100% rename from firebase-database/src/iosMain/c_interop/Cartfile rename to firebase-database/src/nativeInterop/cinterop/Cartfile diff --git a/firebase-database/src/iosMain/c_interop/FirebaseDatabase.def b/firebase-database/src/nativeInterop/cinterop/FirebaseDatabase.def similarity index 81% rename from firebase-database/src/iosMain/c_interop/FirebaseDatabase.def rename to firebase-database/src/nativeInterop/cinterop/FirebaseDatabase.def index 51e38d32b..c183b9287 100644 --- a/firebase-database/src/iosMain/c_interop/FirebaseDatabase.def +++ b/firebase-database/src/nativeInterop/cinterop/FirebaseDatabase.def @@ -1,4 +1,5 @@ language = Objective-C +package = cocoapods.FirebaseDatabase modules = FirebaseDatabase compilerOpts = -framework FirebaseDatabase linkerOpts = -framework FirebaseDatabase -framework leveldb-library diff --git a/firebase-firestore/build.gradle.kts b/firebase-firestore/build.gradle.kts index 6432bab98..614565544 100644 --- a/firebase-firestore/build.gradle.kts +++ b/firebase-firestore/build.gradle.kts @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. + */ + +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget + version = project.property("firebase-firestore.version") as String plugins { @@ -40,62 +46,71 @@ android { } kotlin { - js { - useCommonJs() - nodejs() - browser() - } + android { - publishLibraryVariants("release", "debug") + publishAllLibraryVariants() } - val iosArm64 = iosArm64() - val iosX64 = iosX64("ios") { + + fun nativeTargetConfig(): KotlinNativeTarget.() -> Unit = { + val nativeFrameworkPaths = listOf( + rootProject.project("firebase-app").projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/iOS"), + projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/iOS") + ) + binaries { getTest("DEBUG").apply { - linkerOpts( - "-F${rootProject.projectDir}/firebase-app/src/iosMain/c_interop/Carthage/Build/iOS/", - "-F$projectDir/src/iosMain/c_interop/Carthage/Build/iOS/" - ) + linkerOpts(nativeFrameworkPaths.map { "-F$it" }) linkerOpts("-ObjC") } } + + compilations.getByName("main") { + cinterops.create("FirebaseFirestore") { + compilerOpts(nativeFrameworkPaths.map { "-F$it" }) + extraOpts("-verbose") + } + } } - tasks.withType> { - kotlinOptions.freeCompilerArgs += listOf( - "-Xuse-experimental=kotlin.Experimental", - "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", - "-Xuse-experimental=kotlinx.serialization.InternalSerializationApi" - ) + if (project.extra["ideaActive"] as Boolean) { + iosX64("ios", nativeTargetConfig()) + } else { + ios(configure = nativeTargetConfig()) + } + + js { + useCommonJs() + nodejs() + browser() } sourceSets { + all { + languageSettings.apply { + apiVersion = "1.4" + languageVersion = "1.4" + progressiveMode = true + useExperimentalAnnotation("kotlinx.coroutines.ExperimentalCoroutinesApi") + useExperimentalAnnotation("kotlinx.serialization.InternalSerializationApi") + } + } + val commonMain by getting { dependencies { api(project(":firebase-app")) implementation(project(":firebase-common")) } } + val androidMain by getting { dependencies { - api("com.google.firebase:firebase-firestore:22.0.1") - implementation("com.android.support:multidex:1.0.3") + api("com.google.firebase:firebase-firestore:22.1.0") } } - val jsMain by getting {} - val iosMain by getting {} - - configure(listOf(iosArm64, iosX64)) { - compilations.getByName("main") { - source(sourceSets.get("iosMain")) - val firebasefirestore by cinterops.creating { - packageName("cocoapods.FirebaseFirestore") - defFile(file("$projectDir/src/iosMain/c_interop/FirebaseFirestore.def")) - compilerOpts("-F$projectDir/src/iosMain/c_interop/Carthage/Build/iOS/") - } - } - } + val iosMain by getting + + val jsMain by getting } } signing { diff --git a/firebase-firestore/src/iosMain/c_interop/Cartfile b/firebase-firestore/src/nativeInterop/cinterop/Cartfile similarity index 100% rename from firebase-firestore/src/iosMain/c_interop/Cartfile rename to firebase-firestore/src/nativeInterop/cinterop/Cartfile diff --git a/firebase-firestore/src/iosMain/c_interop/FirebaseFirestore.def b/firebase-firestore/src/nativeInterop/cinterop/FirebaseFirestore.def similarity index 89% rename from firebase-firestore/src/iosMain/c_interop/FirebaseFirestore.def rename to firebase-firestore/src/nativeInterop/cinterop/FirebaseFirestore.def index 3bfe7405c..e12e08820 100644 --- a/firebase-firestore/src/iosMain/c_interop/FirebaseFirestore.def +++ b/firebase-firestore/src/nativeInterop/cinterop/FirebaseFirestore.def @@ -1,4 +1,5 @@ language = Objective-C +package = cocoapods.FirebaseFirestore modules = FirebaseFirestore compilerOpts = -framework FirebaseFirestore linkerOpts = -framework FirebaseFirestore -framework abseil -framework gRPC-Core -framework gRPC-C++ -framework BoringSSL-GRPC -framework leveldb-library -framework SystemConfiguration -framework MobileCoreServices diff --git a/firebase-functions/build.gradle.kts b/firebase-functions/build.gradle.kts index 2e6032981..a6b4caeda 100644 --- a/firebase-functions/build.gradle.kts +++ b/firebase-functions/build.gradle.kts @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. + */ + +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget + version = project.property("firebase-functions.version") as String plugins { @@ -32,60 +38,71 @@ android { } kotlin { - js { - useCommonJs() - nodejs() - browser() - } + android { - publishLibraryVariants("release", "debug") + publishAllLibraryVariants() } - val iosArm64 = iosArm64() - val iosX64 = iosX64("ios") { + + fun nativeTargetConfig(): KotlinNativeTarget.() -> Unit = { + val nativeFrameworkPaths = listOf( + rootProject.project("firebase-app").projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/iOS"), + projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/iOS") + ) + binaries { getTest("DEBUG").apply { - linkerOpts( - "-F${rootProject.projectDir}/firebase-app/src/iosMain/c_interop/Carthage/Build/iOS/", - "-F$projectDir/src/iosMain/c_interop/Carthage/Build/iOS/" - ) + linkerOpts(nativeFrameworkPaths.map { "-F$it" }) linkerOpts("-ObjC") } } + + compilations.getByName("main") { + cinterops.create("FirebaseFunctions") { + compilerOpts(nativeFrameworkPaths.map { "-F$it" }) + extraOpts("-verbose") + } + } } - tasks.withType> { - kotlinOptions.freeCompilerArgs += listOf( - "-Xuse-experimental=kotlin.Experimental", - "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", - "-Xuse-experimental=kotlinx.serialization.InternalSerializationApi" - ) + if (project.extra["ideaActive"] as Boolean) { + iosX64("ios", nativeTargetConfig()) + } else { + ios(configure = nativeTargetConfig()) + } + + js { + useCommonJs() + nodejs() + browser() } sourceSets { + all { + languageSettings.apply { + apiVersion = "1.4" + languageVersion = "1.4" + progressiveMode = true + useExperimentalAnnotation("kotlinx.coroutines.ExperimentalCoroutinesApi") + useExperimentalAnnotation("kotlinx.serialization.InternalSerializationApi") + } + } + val commonMain by getting { dependencies { api(project(":firebase-app")) implementation(project(":firebase-common")) } } + val androidMain by getting { dependencies { api("com.google.firebase:firebase-functions:19.2.0") } } - val iosMain by getting {} - val jsMain by getting {} - - configure(listOf(iosArm64, iosX64)) { - compilations.getByName("main") { - source(sourceSets.get("iosMain")) - val firebasefunctions by cinterops.creating { - packageName("cocoapods.FirebaseFunctions") - defFile(file("$projectDir/src/iosMain/c_interop/FirebaseFunctions.def")) - compilerOpts("-F$projectDir/src/iosMain/c_interop/Carthage/Build/iOS/") - } - } - } + + val iosMain by getting + + val jsMain by getting } } diff --git a/firebase-functions/src/iosMain/c_interop/Cartfile b/firebase-functions/src/nativeInterop/cinterop/Cartfile similarity index 100% rename from firebase-functions/src/iosMain/c_interop/Cartfile rename to firebase-functions/src/nativeInterop/cinterop/Cartfile diff --git a/firebase-functions/src/iosMain/c_interop/FirebaseFunctions.def b/firebase-functions/src/nativeInterop/cinterop/FirebaseFunctions.def similarity index 81% rename from firebase-functions/src/iosMain/c_interop/FirebaseFunctions.def rename to firebase-functions/src/nativeInterop/cinterop/FirebaseFunctions.def index be86d1e56..bae0fcbdc 100644 --- a/firebase-functions/src/iosMain/c_interop/FirebaseFunctions.def +++ b/firebase-functions/src/nativeInterop/cinterop/FirebaseFunctions.def @@ -1,4 +1,5 @@ language = Objective-C +package = cocoapods.FirebaseFunctions modules = FirebaseFunctions compilerOpts = -framework FirebaseFunctions linkerOpts = -framework FirebaseFunctions -framework GTMSessionFetcher diff --git a/gradle.properties b/gradle.properties index c940b965c..58675adda 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,19 @@ +android.enableJetifier=true +android.useAndroidX=true +kapt.use.worker.api=true kotlin.code.style=official +kotlin.incremental.multiplatform=true kotlin.js.experimental.generateKotlinExternals=false +#kotlin.mpp.enableCompatibilityMetadataVariant=true +#kotlin.mpp.enableGranularSourceSetsMetadata=true kotlin.mpp.stability.nowarn=true -org.gradle.daemon=true -org.gradle.jvmargs=-Xmx2560m -android.useAndroidX=true +#kotlin.native.cacheKind=none +#kotlin.native.enableDependencyPropagation=false +kotlin.native.enableParallelExecutionCheck=false +kotlin.parallel.tasks.in.project=true +kotlin.setJvmTargetFromAndroidCompileOptions=true +org.gradle.jvmargs=-Xmx2048m +org.gradle.parallel=true testOptions.unitTests.isIncludeAndroidResources = true # Versions: From 730df0f54c55dc07fd3585f7ee5e6a66e31cbeba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Owodzin=CC=81?= Date: Wed, 17 Feb 2021 23:00:13 +0000 Subject: [PATCH 2/3] fixes --- build.gradle.kts | 19 ++++++++++--------- firebase-common/build.gradle.kts | 12 +++++++++++- gradle.properties | 2 ++ settings.gradle.kts | 11 +++++++++-- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 9c4f48816..e017fb697 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,6 +26,15 @@ buildscript { val targetSdkVersion by extra(28) val minSdkVersion by extra(16) +// TODO: Hierarchical project structures are not fully supported in IDEA, enable only for a regular built (https://youtrack.jetbrains.com/issue/KT-35011) +// add idea.active=true for local development +val _ideaActive = gradleLocalProperties(rootDir)["idea.active"] == "true" + +//if (!_ideaActive) { +// ext["kotlin.mpp.enableGranularSourceSetsMetadata"] = "true" +// ext["kotlin.native.enableDependencyPropagation"] = "false" +//} + tasks { val updateVersions by registering { dependsOn( @@ -41,9 +50,7 @@ tasks { subprojects { - // temp fix for https://youtrack.jetbrains.com/issue/KT-35011 - // add ideaActive=true for local development - val ideaActive by extra { gradleLocalProperties(rootDir)["idea.active"] == "true" } + val ideaActive by extra(_ideaActive) group = "dev.gitlive" @@ -56,11 +63,9 @@ subprojects { jcenter() } - tasks.withType().configureEach { onlyIf { !project.gradle.startParameter.taskNames.contains("publishToMavenLocal") } } - tasks { @@ -258,11 +263,7 @@ subprojects { comments.set("A business-friendly OSS license") } } - } } - } - } - diff --git a/firebase-common/build.gradle.kts b/firebase-common/build.gradle.kts index fa40d4144..6073fd7ee 100644 --- a/firebase-common/build.gradle.kts +++ b/firebase-common/build.gradle.kts @@ -2,6 +2,8 @@ * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget + version = project.property("firebase-common.version") as String plugins { @@ -44,7 +46,15 @@ kotlin { publishAllLibraryVariants() } - ios() + fun nativeTargetConfig(): KotlinNativeTarget.() -> Unit = { + + } + + if (project.extra["ideaActive"] as Boolean) { + iosX64("ios", nativeTargetConfig()) + } else { + ios(configure = nativeTargetConfig()) + } js { useCommonJs() diff --git a/gradle.properties b/gradle.properties index 58675adda..6044dffa7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,8 +3,10 @@ android.useAndroidX=true kapt.use.worker.api=true kotlin.code.style=official kotlin.incremental.multiplatform=true +kotlin.js.compiler=legacy kotlin.js.experimental.generateKotlinExternals=false #kotlin.mpp.enableCompatibilityMetadataVariant=true +# TODO: This is commented out, and the property is set conditionally in build.gradle, because IDEA doesn't work with it. #kotlin.mpp.enableGranularSourceSetsMetadata=true kotlin.mpp.stability.nowarn=true #kotlin.native.cacheKind=none diff --git a/settings.gradle.kts b/settings.gradle.kts index 45967cd7e..f3225d9c2 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,4 +1,11 @@ -include("firebase-common", "firebase-app", "firebase-firestore", "firebase-database", "firebase-auth", "firebase-functions") +include( + "firebase-common", + "firebase-app", + "firebase-firestore", + "firebase-database", + "firebase-auth", + "firebase-functions" +) -enableFeaturePreview("GRADLE_METADATA") +//enableFeaturePreview("GRADLE_METADATA") From 4e6b0f0243720957b54fd378eef4761dc2750498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Owodzin=CC=81?= Date: Wed, 17 Feb 2021 23:33:12 +0000 Subject: [PATCH 3/3] cleanup --- gradle.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 6044dffa7..3375f0d18 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,6 @@ kotlin.incremental.multiplatform=true kotlin.js.compiler=legacy kotlin.js.experimental.generateKotlinExternals=false #kotlin.mpp.enableCompatibilityMetadataVariant=true -# TODO: This is commented out, and the property is set conditionally in build.gradle, because IDEA doesn't work with it. #kotlin.mpp.enableGranularSourceSetsMetadata=true kotlin.mpp.stability.nowarn=true #kotlin.native.cacheKind=none