blob: c9c4e2ed43e62faba22446e96ce8032b4aa02cd0 [file] [log] [blame]
/*
* Copyright 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import androidx.build.KmpPlatformsKt
import androidx.build.LibraryType
import androidx.build.PlatformIdentifier
import androidx.build.Publish
import androidx.build.SdkHelperKt
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.konan.target.KonanTarget
plugins {
id("AndroidXPlugin")
id("com.android.library")
}
def enableNative = KmpPlatformsKt.enableNative(project)
androidXMultiplatform {
android()
// TODO(b/300666074): Enable linux target once we can compile sqlite3.c
// linux()
mac()
ios() {
// Link to sqlite3 available in iOS
binaries.all {
linkerOpts += ["-lsqlite3"]
}
}
defaultPlatform(PlatformIdentifier.ANDROID)
sourceSets {
commonMain {
dependencies {
implementation(libs.kotlinStdlib)
api(project(":sqliteMultiplatform:sqlite"))
}
}
commonTest {
dependencies {
implementation(project(":sqliteMultiplatform:conformanceTest"))
implementation(libs.kotlinTest)
implementation(project(":kruth:kruth"))
}
}
androidMain {
dependsOn(commonMain)
}
androidUnitTest {
dependsOn(commonTest)
dependencies {
implementation(libs.kotlinTestJunit)
implementation(libs.testRunner)
implementation(libs.testCore)
}
}
androidInstrumentedTest {
dependsOn(androidUnitTest)
}
if (enableNative) {
nativeMain {
dependsOn(commonMain)
}
nativeTest {
dependsOn(commonTest)
}
}
targets.all { target ->
if (target.platformType == KotlinPlatformType.native) {
def main = target.compilations["main"]
main.defaultSourceSet {
dependsOn(nativeMain)
}
// For usage of sqlite3.h C APIs
// See: https://kotlinlang.org/docs/whatsnew19.html#explicit-c-interoperability-stability-guarantees
main.compilerOptions.options.optIn.add("kotlinx.cinterop.ExperimentalForeignApi")
main.cinterops {
sqlite3 {
def externalSQLiteDir = new File(
SdkHelperKt.getCheckoutRoot(project),
"/external/sqlite/dist/orig/"
)
includeDirs(externalSQLiteDir)
}
}
def test = target.compilations["test"]
test.defaultSourceSet {
dependsOn(nativeTest)
if (target.konanTarget != KonanTarget.LINUX_X64) {
// For tests in Mac host, link to shared library included in MacOS
test.kotlinOptions.freeCompilerArgs += [
"-linker-options", "-lsqlite3"
]
}
}
}
}
}
}
android {
namespace "androidx.sqliteMultiplatform.driver"
}
androidx {
name = "SQLite KMP Implementation"
type = LibraryType.UNSET
inceptionYear = "2023"
description = "SQLite Kotlin Multiplatform Implementation"
publish = Publish.NONE
}