delegated module build.gradle cleanp and macos build fix
This commit is contained in:
parent
137fe3fe62
commit
bb58a372e7
@ -21,5 +21,11 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven ("https://dl.bintray.com/kotlin/kotlin-eap")
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4-M1")
|
||||||
|
}
|
||||||
|
@ -27,7 +27,7 @@ object Versions {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object Published {
|
object ReleaseInfo {
|
||||||
val group = "com.ionspin.kotlin"
|
val group = "com.ionspin.kotlin"
|
||||||
val version = "0.0.5-SNAPSHOT"
|
val version = "0.0.5-SNAPSHOT"
|
||||||
}
|
}
|
||||||
|
63
buildSrc/src/main/kotlin/Utils.kt
Normal file
63
buildSrc/src/main/kotlin/Utils.kt
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
import org.gradle.api.NamedDomainObjectContainer
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Ugljesa Jovanovic
|
||||||
|
* ugljesa.jovanovic@ionspin.com
|
||||||
|
* on 30-May-2020
|
||||||
|
*/
|
||||||
|
fun isInIdea() = System.getProperty("idea.active") == "true"
|
||||||
|
|
||||||
|
fun isInTravis() = System.getenv("TRAVIS") == "true"
|
||||||
|
|
||||||
|
fun getHostOsName(): String {
|
||||||
|
val target = System.getProperty("os.name")
|
||||||
|
if (target == "Linux") return "linux"
|
||||||
|
if (target.startsWith("Windows")) return "windows"
|
||||||
|
if (target.startsWith("Mac")) return "macos"
|
||||||
|
return "unknown"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun KotlinMultiplatformExtension.isRunningInIdea(block : KotlinMultiplatformExtension.() -> Unit) {
|
||||||
|
if (isInIdea()) {
|
||||||
|
block(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun KotlinMultiplatformExtension.runningOnLinux(block : KotlinMultiplatformExtension.() -> Unit) {
|
||||||
|
if (getHostOsName() == "linux") {
|
||||||
|
block(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun KotlinMultiplatformExtension.runningOnMacos(block : KotlinMultiplatformExtension.() -> Unit) {
|
||||||
|
if (getHostOsName() == "macos") {
|
||||||
|
block(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun KotlinMultiplatformExtension.runningOnWindows(block : KotlinMultiplatformExtension.() -> Unit) {
|
||||||
|
if (getHostOsName() == "windows") {
|
||||||
|
block(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fun independentDependencyBlock(nativeDeps : KotlinDependencyHandler.() -> Unit) : KotlinDependencyHandler.() -> Unit {
|
||||||
|
return nativeDeps
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On mac when two targets that have the same parent source set have cinterops defined, gradle creates a "common"
|
||||||
|
* target task for that source set metadata, even though it's a native source set, to work around that, we create
|
||||||
|
* an intermediary source set with the same set of dependancies
|
||||||
|
*/
|
||||||
|
fun NamedDomainObjectContainer<KotlinSourceSet>.createWorkaroundNativeMainSourceSet(name : String, nativeDeps : KotlinDependencyHandler.() -> Unit) : KotlinSourceSet {
|
||||||
|
return create("${name}Workaround") {
|
||||||
|
kotlin.srcDir("src/nativeMain/kotlin")
|
||||||
|
dependencies {
|
||||||
|
nativeDeps.invoke(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -33,8 +33,8 @@ repositories {
|
|||||||
jcenter()
|
jcenter()
|
||||||
|
|
||||||
}
|
}
|
||||||
group = Published.group
|
group = ReleaseInfo.group
|
||||||
version = Published.version
|
version = ReleaseInfo.version
|
||||||
|
|
||||||
val ideaActive = System.getProperty("idea.active") == "true"
|
val ideaActive = System.getProperty("idea.active") == "true"
|
||||||
|
|
||||||
|
@ -45,22 +45,17 @@ repositories {
|
|||||||
jcenter()
|
jcenter()
|
||||||
|
|
||||||
}
|
}
|
||||||
group = Published.group
|
group = ReleaseInfo.group
|
||||||
version = Published.version
|
version = ReleaseInfo.version
|
||||||
|
|
||||||
|
val ideaActive = isInIdea()
|
||||||
|
println("Idea active: $ideaActive")
|
||||||
|
|
||||||
val ideaActive = System.getProperty("idea.active") == "true"
|
|
||||||
|
|
||||||
fun getHostOsName(): String {
|
|
||||||
val target = System.getProperty("os.name")
|
|
||||||
if (target == "Linux") return "linux"
|
|
||||||
if (target.startsWith("Windows")) return "windows"
|
|
||||||
if (target.startsWith("Mac")) return "macos"
|
|
||||||
return "unknown"
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
val hostOsName = getHostOsName()
|
val hostOsName = getHostOsName()
|
||||||
if (hostOsName == "linux") {
|
runningOnLinux {
|
||||||
jvm()
|
jvm()
|
||||||
js {
|
js {
|
||||||
browser {
|
browser {
|
||||||
@ -103,29 +98,29 @@ kotlin {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hostOsName == "macos") {
|
runningOnMacos {
|
||||||
// iosX64("ios") {
|
iosX64("ios") {
|
||||||
// binaries {
|
binaries {
|
||||||
// framework {
|
framework {
|
||||||
// optimized = true
|
optimized = true
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// iosArm64("ios64Arm") {
|
iosArm64("ios64Arm") {
|
||||||
// binaries {
|
binaries {
|
||||||
// framework {
|
framework {
|
||||||
// optimized = true
|
optimized = true
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// iosArm32("ios32Arm") {
|
iosArm32("ios32Arm") {
|
||||||
// binaries {
|
binaries {
|
||||||
// framework {
|
framework {
|
||||||
// optimized = true
|
optimized = true
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
macosX64() {
|
macosX64() {
|
||||||
binaries {
|
binaries {
|
||||||
framework {
|
framework {
|
||||||
@ -133,8 +128,22 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tvos() {
|
||||||
|
binaries {
|
||||||
|
framework {
|
||||||
|
optimized = true
|
||||||
}
|
}
|
||||||
if (hostOsName == "windows") {
|
}
|
||||||
|
}
|
||||||
|
watchos() {
|
||||||
|
binaries {
|
||||||
|
framework {
|
||||||
|
optimized = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
runningOnWindows {
|
||||||
|
|
||||||
mingwX64() {
|
mingwX64() {
|
||||||
binaries {
|
binaries {
|
||||||
@ -173,14 +182,17 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val nativeDependencies = independentDependencyBlock {
|
||||||
|
implementation(Deps.Native.coroutines)
|
||||||
|
}
|
||||||
|
|
||||||
val nativeMain by creating {
|
val nativeMain by creating {
|
||||||
dependsOn(commonMain)
|
dependsOn(commonMain)
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(Deps.Native.coroutines)
|
nativeDependencies(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val nativeTest by creating {
|
val nativeTest by creating {
|
||||||
dependsOn(commonTest)
|
dependsOn(commonTest)
|
||||||
dependencies {
|
dependencies {
|
||||||
@ -188,13 +200,13 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
targets.withType<KotlinNativeTarget> {
|
targets.withType<KotlinNativeTarget> {
|
||||||
println("Target $name")
|
println("Target $name")
|
||||||
compilations.getByName("main") {
|
compilations.getByName("main") {
|
||||||
|
|
||||||
defaultSourceSet.dependsOn(nativeMain)
|
|
||||||
if (this@withType.name.contains("ios").not()) {
|
if (this@withType.name.contains("ios").not()) {
|
||||||
println("Setting cinterop for $this@withType.name")
|
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
|
||||||
|
println("Setting cinterop for $this")
|
||||||
val libsodiumCinterop by cinterops.creating {
|
val libsodiumCinterop by cinterops.creating {
|
||||||
defFile(project.file("src/nativeInterop/cinterop/libsodium.def"))
|
defFile(project.file("src/nativeInterop/cinterop/libsodium.def"))
|
||||||
compilerOpts.add("-I${project.rootDir}/sodiumWrapper/include/")
|
compilerOpts.add("-I${project.rootDir}/sodiumWrapper/include/")
|
||||||
@ -203,13 +215,24 @@ kotlin {
|
|||||||
"-include-binary", "${project.rootDir}/sodiumWrapper/lib/libsodium.a"
|
"-include-binary", "${project.rootDir}/sodiumWrapper/lib/libsodium.a"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (this@withType.name.contains("ios")) {
|
||||||
|
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
|
||||||
|
println("Setting ios cinterop for $this")
|
||||||
|
val libsodiumCinterop by cinterops.creating {
|
||||||
|
defFile(project.file("src/nativeInterop/cinterop/libsodium.def"))
|
||||||
|
compilerOpts.add("-I${project.rootDir}/sodiumWrapper/libsodium-ios/include/")
|
||||||
|
}
|
||||||
|
kotlinOptions.freeCompilerArgs = listOf(
|
||||||
|
"-include-binary", "${project.rootDir}/sodiumWrapper/libsodium-ios/lib/libsodium.a"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
compilations.getByName("test") {
|
compilations.getByName("test") {
|
||||||
if (this@withType.name.contains("ios").not()) {
|
|
||||||
println("Setting native test dep for $this@withType.name")
|
println("Setting native test dep for $this@withType.name")
|
||||||
defaultSourceSet.dependsOn(nativeTest)
|
defaultSourceSet.dependsOn(nativeTest)
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,14 +274,14 @@ kotlin {
|
|||||||
}
|
}
|
||||||
val linuxMain by getting {
|
val linuxMain by getting {
|
||||||
dependsOn(nativeMain)
|
dependsOn(nativeMain)
|
||||||
if (ideaActive) {
|
isRunningInIdea {
|
||||||
kotlin.srcDir("src/nativeMain/kotlin")
|
kotlin.srcDir("src/nativeMain/kotlin")
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
val linuxTest by getting {
|
val linuxTest by getting {
|
||||||
dependsOn(nativeTest)
|
dependsOn(nativeTest)
|
||||||
if (ideaActive) {
|
isRunningInIdea {
|
||||||
kotlin.srcDir("src/nativeTest/kotlin")
|
kotlin.srcDir("src/nativeTest/kotlin")
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@ -287,28 +310,6 @@ kotlin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hostOsName == "macos") {
|
if (hostOsName == "macos") {
|
||||||
|
|
||||||
// val iosMain by getting {
|
|
||||||
//// dependsOn(nativeMain)
|
|
||||||
// }
|
|
||||||
// val iosTest by getting {
|
|
||||||
//// dependsOn(nativeTest)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// val ios64ArmMain by getting {
|
|
||||||
//// dependsOn(nativeMain)
|
|
||||||
// }
|
|
||||||
// val ios64ArmTest by getting {
|
|
||||||
//// dependsOn(nativeTest)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// val ios32ArmMain by getting {
|
|
||||||
//// dependsOn(nativeMain)
|
|
||||||
// }
|
|
||||||
// val ios32ArmTest by getting {
|
|
||||||
//// dependsOn(nativeTest)
|
|
||||||
// }
|
|
||||||
|
|
||||||
val macosX64Main by getting {
|
val macosX64Main by getting {
|
||||||
dependsOn(nativeMain)
|
dependsOn(nativeMain)
|
||||||
if (ideaActive) {
|
if (ideaActive) {
|
||||||
|
@ -42,8 +42,8 @@ repositories {
|
|||||||
jcenter()
|
jcenter()
|
||||||
|
|
||||||
}
|
}
|
||||||
group = Published.group
|
group = ReleaseInfo.group
|
||||||
version = Published.version
|
version = ReleaseInfo.version
|
||||||
|
|
||||||
val ideaActive = System.getProperty("idea.active") == "true"
|
val ideaActive = System.getProperty("idea.active") == "true"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user