Files
kotlin-fork/kotlin-native/samples/curl/build.gradle.kts
T
Stanislav Erokhin f624800b84 Move everything under kotlin-native folder
I was forced to manually do update the following files, because otherwise
they would be ignored according .gitignore settings. Probably they
should be deleted from repo.

Interop/.idea/compiler.xml
Interop/.idea/gradle.xml
Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_runtime_1_0_3.xml
Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_0_3.xml
Interop/.idea/modules.xml
Interop/.idea/modules/Indexer/Indexer.iml
Interop/.idea/modules/Runtime/Runtime.iml
Interop/.idea/modules/StubGenerator/StubGenerator.iml
backend.native/backend.native.iml
backend.native/bc.frontend/bc.frontend.iml
backend.native/cli.bc/cli.bc.iml
backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt
backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt
backend.native/tests/link/lib/foo.kt
backend.native/tests/link/lib/foo2.kt
backend.native/tests/teamcity-test.property
2020-10-27 21:00:28 +03:00

72 lines
2.5 KiB
Kotlin

plugins {
kotlin("multiplatform")
}
val localRepo = rootProject.file("build/.m2-local")
repositories {
maven("file://$localRepo")
}
val mingwPath = File(System.getenv("MINGW64_DIR") ?: "C:/msys64/mingw64")
kotlin {
// Determine host preset.
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
// Create target for the host platform.
val hostTarget = when {
hostOs == "Mac OS X" -> macosX64("curl")
hostOs == "Linux" -> linuxX64("curl")
isMingwX64 -> mingwX64("curl")
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
}
hostTarget.apply {
binaries {
executable {
entryPoint = "sample.curl.main"
if (isMingwX64) {
// Add lib path to `libcurl` and its dependencies:
linkerOpts("-L${mingwPath.resolve("lib")}")
runTask?.environment("PATH" to mingwPath.resolve("bin"))
}
runTask?.args("https://www.jetbrains.com/")
}
}
}
sourceSets {
val curlMain by getting {
dependencies {
implementation("org.jetbrains.kotlin.sample.native:libcurl:1.0")
}
}
}
}
// The code snippet below is needed to make all compile tasks depend on publication of
// "libcurl" library. So that to the time of compilation the library will already be
// in Maven repo and will be successfully resolved as a dependency of this project.
tasks.withType(AbstractCompile::class) {
dependsOn(":libcurl:publish")
}
// The following snippet is needed to give instructions for IDEA user who just imported project
// and sees "Could not resolve..." message in IDEA console.
gradle.buildFinished {
val configurationName = kotlin.targets["curl"].compilations["main"].compileDependencyConfigurationName
val configuration = project.configurations[configurationName]
if (configuration.isCanBeResolved && configuration.state == Configuration.State.RESOLVED_WITH_FAILURES) {
println(
"""
|
|IMPORTANT:
|The message about unresolved "libcurl" dependency likely means that "libcurl" has not been built and published to local Maven repo yet.
|Please run "publish" task for "libcurl" sub-project and re-import Kotlin/Native samples in IDEA.
""".trimMargin()
)
}
}