Skip to content

Commit 153c51f

Browse files
committed
feat: libcurl project update with the kotlin native template
1 parent fbeaa1a commit 153c51f

15 files changed

+311
-244
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ build/
44
out/
55
.DS_Store
66
.idea/
7+
.kotlin/

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
# Kotlin/Native tutorial: C interop and libcurl
88

99

10-
This repository is the resulting code corresponding to the [Creating an app using C Interop and libcurl](https://kotlinlang.org/docs/curl.html) tutorial.
10+
This repository is the resulting code corresponding to the [Creating an app using C interop and libcurl](https://kotlinlang.org/docs/native-app-with-c-and-libcurl.html) tutorial.

build.gradle

-41
This file was deleted.

build.gradle.kts

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
plugins {
2+
alias(libs.plugins.kotlinMultiplatform)
3+
alias(libs.plugins.kotlinxSerialization)
4+
}
5+
6+
group = "me.user"
7+
version = "1.0-SNAPSHOT"
8+
9+
repositories {
10+
mavenCentral()
11+
}
12+
13+
kotlin {
14+
val hostOs = System.getProperty("os.name")
15+
val isArm64 = System.getProperty("os.arch") == "aarch64"
16+
val isMingwX64 = hostOs.startsWith("Windows")
17+
val nativeTarget = when {
18+
hostOs == "Mac OS X" && isArm64 -> macosArm64("native")
19+
hostOs == "Mac OS X" && !isArm64 -> macosX64("native")
20+
hostOs == "Linux" && isArm64 -> linuxArm64("native")
21+
hostOs == "Linux" && !isArm64 -> linuxX64("native")
22+
isMingwX64 -> mingwX64("native")
23+
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
24+
}
25+
26+
nativeTarget.apply {
27+
compilations.getByName("main") {
28+
cinterops {
29+
val libcurl by creating
30+
}
31+
}
32+
binaries {
33+
executable {
34+
entryPoint = "main"
35+
}
36+
}
37+
}
38+
39+
sourceSets {
40+
nativeMain.dependencies {
41+
implementation(libs.kotlinxSerializationJson)
42+
}
43+
}
44+
}

gradle.properties

-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
kotlin.code.style=official
2-
kotlin.mpp.enableGranularSourceSetsMetadata=true
3-
kotlin.native.enableDependencyPropagation=false

gradle/libs.versions.toml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[versions]
2+
kotlin = "2.1.20"
3+
kotlinxSerialization = "1.8.0"
4+
5+
[libraries]
6+
kotlinxSerializationJson = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerialization" }
7+
8+
[plugins]
9+
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
10+
kotlinxSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }

gradle/wrapper/gradle-wrapper.jar

1.19 KB
Binary file not shown.
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
5-
zipStorePath=wrapper/dists
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)