Skip to content

Commit 6d339de

Browse files
authored
build config changes (#151)
* build config changes * updated iosMain/c_interop to nativeInterop/cinterop (fixes #139) * hierarchical project structure (#137) * gradle cleanup & enabled parallel builds * fixes * cleanup
1 parent 40ba027 commit 6d339de

File tree

21 files changed

+314
-191
lines changed

21 files changed

+314
-191
lines changed

.gitignore

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
local.properties
66
/**/*.iml
77
*.iml
8-
firebase-app/src/iosMain/c_interop/modules/
9-
firebase-functions/src/iosMain/c_interop/modules/
10-
firebase-auth/src/iosMain/c_interop/modules/
11-
firebase-firestore/src/iosMain/c_interop/modules/
12-
firebase-database/src/iosMain/c_interop/modules/
8+
firebase-app/src/nativeInterop/cinterop/modules/
9+
firebase-functions/src/nativeInterop/cinterop/modules/
10+
firebase-auth/src/nativeInterop/cinterop/modules/
11+
firebase-firestore/src/nativeInterop/cinterop/modules/
12+
firebase-database/src/nativeInterop/cinterop/modules/
1313
Firebase*.zip
1414
/Firebase
1515
/.DS_Store
1616
*.log
1717

1818

19-
/**/Cartfile.resolved
20-
/**/c_interop/Carthage/
19+
/**/nativeInterop/cinterop/Cartfile.resolved
20+
/**/nativeInterop/cinterop/Carthage/

build.gradle.kts

+17-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import de.undercouch.gradle.tasks.download.Download
1+
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties
22
import org.apache.tools.ant.taskdefs.condition.Os
33
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
44
import org.gradle.api.tasks.testing.logging.TestLogEvent
55

66
plugins {
77
kotlin("multiplatform") version "1.4.21" apply false
8-
id("de.undercouch.download").version("4.1.1")
98
id("base")
109
}
1110

@@ -20,14 +19,22 @@ buildscript {
2019
}
2120
dependencies {
2221
classpath("com.android.tools.build:gradle:4.1.1")
23-
classpath("de.undercouch:gradle-download-task:4.1.1")
2422
classpath("com.adarshr:gradle-test-logger-plugin:2.0.0")
2523
}
2624
}
2725

2826
val targetSdkVersion by extra(28)
2927
val minSdkVersion by extra(16)
3028

29+
// TODO: Hierarchical project structures are not fully supported in IDEA, enable only for a regular built (https://youtrack.jetbrains.com/issue/KT-35011)
30+
// add idea.active=true for local development
31+
val _ideaActive = gradleLocalProperties(rootDir)["idea.active"] == "true"
32+
33+
//if (!_ideaActive) {
34+
// ext["kotlin.mpp.enableGranularSourceSetsMetadata"] = "true"
35+
// ext["kotlin.native.enableDependencyPropagation"] = "false"
36+
//}
37+
3138
tasks {
3239
val updateVersions by registering {
3340
dependsOn(
@@ -43,6 +50,8 @@ tasks {
4350

4451
subprojects {
4552

53+
val ideaActive by extra(_ideaActive)
54+
4655
group = "dev.gitlive"
4756

4857
apply(plugin="com.adarshr.test-logger")
@@ -54,11 +63,9 @@ subprojects {
5463
jcenter()
5564
}
5665

57-
5866
tasks.withType<Sign>().configureEach {
5967
onlyIf { !project.gradle.startParameter.taskNames.contains("publishToMavenLocal") }
6068
}
61-
6269

6370
tasks {
6471

@@ -155,7 +162,7 @@ subprojects {
155162
executable = "carthage"
156163
args(
157164
it,
158-
"--project-directory", "src/iosMain/c_interop",
165+
"--project-directory", projectDir.resolve("src/nativeInterop/cinterop"),
159166
"--platform", "iOS",
160167
"--cache-builds"
161168
)
@@ -170,8 +177,10 @@ subprojects {
170177

171178
create("carthageClean", Delete::class.java) {
172179
group = "carthage"
173-
delete(File("$projectDir/src/iosMain/c_interop/Carthage"))
174-
delete(File("$projectDir/src/iosMain/c_interop/Cartfile.resolved"))
180+
delete(
181+
projectDir.resolve("src/nativeInterop/cinterop/Carthage"),
182+
projectDir.resolve("src/nativeInterop/cinterop/Cartfile.resolved")
183+
)
175184
}
176185
}
177186

@@ -254,11 +263,7 @@ subprojects {
254263
comments.set("A business-friendly OSS license")
255264
}
256265
}
257-
258266
}
259267
}
260-
261268
}
262-
263269
}
264-

firebase-app/build.gradle.kts

+42-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/*
22
* Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license.
33
*/
4+
5+
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
6+
47
version = project.property("firebase-app.version") as String
58

69
plugins {
@@ -41,47 +44,67 @@ android {
4144
}
4245

4346
kotlin {
44-
js {
45-
useCommonJs()
46-
nodejs()
47-
browser()
48-
}
47+
4948
android {
50-
publishLibraryVariants("release", "debug")
49+
publishAllLibraryVariants()
5150
}
5251

53-
val iosArm64 = iosArm64()
54-
val iosX64 = iosX64("ios") {
52+
fun nativeTargetConfig(): KotlinNativeTarget.() -> Unit = {
53+
val nativeFrameworkPaths = listOf(
54+
projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/iOS")
55+
)
56+
5557
binaries {
5658
getTest("DEBUG").apply {
57-
linkerOpts("-F$projectDir/src/iosMain/c_interop/Carthage/Build/iOS/")
59+
linkerOpts(nativeFrameworkPaths.map { "-F$it" })
5860
linkerOpts("-ObjC")
5961
}
6062
}
63+
64+
compilations.getByName("main") {
65+
cinterops.create("FirebaseCore") {
66+
compilerOpts(nativeFrameworkPaths.map { "-F$it" })
67+
extraOpts("-verbose")
68+
}
69+
}
70+
}
71+
72+
if (project.extra["ideaActive"] as Boolean) {
73+
iosX64("ios", nativeTargetConfig())
74+
} else {
75+
ios(configure = nativeTargetConfig())
76+
}
77+
78+
js {
79+
useCommonJs()
80+
nodejs()
81+
browser()
6182
}
6283

6384
sourceSets {
85+
all {
86+
languageSettings.apply {
87+
apiVersion = "1.4"
88+
languageVersion = "1.4"
89+
progressiveMode = true
90+
}
91+
}
92+
6493
val commonMain by getting {
6594
dependencies {
6695
implementation(project(":firebase-common"))
6796
}
6897
}
98+
6999
val androidMain by getting {
70100
dependencies {
71101
api("com.google.firebase:firebase-common:19.5.0")
72102
}
73103
}
74104

75-
configure(listOf(iosArm64, iosX64)) {
76-
compilations.getByName("main") {
77-
source(sourceSets.get("iosMain"))
78-
val firebasecore by cinterops.creating {
79-
packageName("cocoapods.FirebaseCore")
80-
defFile(file("$projectDir/src/iosMain/c_interop/FirebaseCore.def"))
81-
compilerOpts("-F$projectDir/src/iosMain/c_interop/Carthage/Build/iOS/")
82-
}
83-
}
84-
}
105+
val iosMain by getting
106+
107+
val jsMain by getting
85108
}
86109
}
87110

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
language = Objective-C
2+
package = cocoapods.FirebaseCore
23
modules = FirebaseCore
34
compilerOpts = -framework FirebaseCore
45
linkerOpts = -framework FirebaseCore -framework FirebaseCoreDiagnostics -framework FirebaseAnalytics -framework FIRAnalyticsConnector -framework GoogleAppMeasurement -framework FirebaseInstallations -framework GoogleDataTransport -framework GoogleUtilities -framework PromisesObjC -framework nanopb -framework StoreKit -lsqlite3

firebase-auth/build.gradle.kts

+42-28
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/*
22
* Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license.
33
*/
4+
5+
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
6+
47
version = project.property("firebase-auth.version") as String
58

69
plugins {
@@ -65,34 +68,54 @@ android {
6568
//}
6669

6770
kotlin {
68-
js {
69-
useCommonJs()
70-
nodejs()
71-
browser()
72-
}
71+
7372
android {
74-
publishLibraryVariants("release", "debug")
73+
publishAllLibraryVariants()
7574
}
76-
val iosArm64 = iosArm64()
77-
val iosX64 = iosX64("ios") {
75+
76+
fun nativeTargetConfig(): KotlinNativeTarget.() -> Unit = {
77+
val nativeFrameworkPaths = listOf(
78+
rootProject.project("firebase-app").projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/iOS"),
79+
projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/iOS")
80+
)
81+
7882
binaries {
7983
getTest("DEBUG").apply {
80-
linkerOpts(
81-
"-F${rootProject.projectDir}/firebase-app/src/iosMain/c_interop/Carthage/Build/iOS/",
82-
"-F$projectDir/src/iosMain/c_interop/Carthage/Build/iOS/")
84+
linkerOpts(nativeFrameworkPaths.map { "-F$it" })
8385
linkerOpts("-ObjC")
8486
}
8587
}
88+
89+
compilations.getByName("main") {
90+
cinterops.create("FirebaseAuth") {
91+
compilerOpts(nativeFrameworkPaths.map { "-F$it" })
92+
extraOpts("-verbose")
93+
}
94+
}
8695
}
8796

88-
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
89-
kotlinOptions.freeCompilerArgs += listOf(
90-
"-Xuse-experimental=kotlin.Experimental",
91-
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi"
92-
)
97+
if (project.extra["ideaActive"] as Boolean) {
98+
iosX64("ios", nativeTargetConfig())
99+
} else {
100+
ios(configure = nativeTargetConfig())
101+
}
102+
103+
js {
104+
useCommonJs()
105+
nodejs()
106+
browser()
93107
}
94108

95109
sourceSets {
110+
all {
111+
languageSettings.apply {
112+
apiVersion = "1.4"
113+
languageVersion = "1.4"
114+
progressiveMode = true
115+
useExperimentalAnnotation("kotlinx.coroutines.ExperimentalCoroutinesApi")
116+
}
117+
}
118+
96119
val commonMain by getting {
97120
dependencies {
98121
api(project(":firebase-app"))
@@ -106,18 +129,9 @@ kotlin {
106129
}
107130
}
108131

109-
configure(listOf(iosArm64, iosX64)) {
110-
compilations.getByName("main") {
111-
source(sourceSets.get("iosMain"))
112-
val firebaseAuth by cinterops.creating {
113-
packageName("cocoapods.FirebaseAuth")
114-
defFile(file("$projectDir/src/iosMain/c_interop/FirebaseAuth.def"))
115-
compilerOpts(
116-
"-F$projectDir/src/iosMain/c_interop/Carthage/Build/iOS/"
117-
)
118-
}
119-
}
120-
}
132+
val iosMain by getting
133+
134+
val jsMain by getting
121135
}
122136
}
123137

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
language = Objective-C
2+
package = cocoapods.FirebaseAuth
23
modules = FirebaseAuth
34
compilerOpts = -framework FirebaseAuth
45
linkerOpts = -framework FirebaseAuth -framework GTMSessionFetcher

0 commit comments

Comments
 (0)