Skip to content

Commit faee1cf

Browse files
committed
Completed lab code
1 parent 3496567 commit faee1cf

File tree

7 files changed

+96
-0
lines changed

7 files changed

+96
-0
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.gradle/
2+
build/
3+
*.iml
4+
out/
5+
.DS_Store
6+
.idea/

build.gradle

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
plugins {
2+
id 'kotlin-multiplatform' version '1.3.31'
3+
}
4+
repositories {
5+
mavenCentral()
6+
}
7+
kotlin {
8+
// For ARM, should be changed to iosArm32 or iosArm64
9+
// For Linux, should be changed to e.g. linuxX64
10+
// For MacOS, should be changed to e.g. macosX64
11+
// For Windows, should be changed to e.g. mingwX64
12+
macosX64("macos") {
13+
compilations.main {
14+
cinterops {
15+
libcurl /*{
16+
defFile project.file("libcurl.def")
17+
packageName 'com.jetbrains.handson.http'
18+
compilerOpts '-I/'
19+
includeDirs.allHeaders("")
20+
}*/
21+
}
22+
}
23+
binaries {
24+
executable {
25+
// Change to specify fully qualified name of your application's entry point:
26+
entryPoint = 'com.jetbrains.handson.http.main'
27+
// Specify command-line arguments, if necessary:
28+
runTask?.args('')
29+
}
30+
}
31+
}
32+
sourceSets {
33+
// Note: To enable common source sets please comment out 'kotlin.import.noCommonSourceSets' property
34+
// in gradle.properties file and re-import your project in IDE.
35+
macosMain {
36+
}
37+
macosTest {
38+
}
39+
}
40+
}
41+
42+
// Use the following Gradle tasks to run your application:
43+
// :runReleaseExecutableMacos - without debug symbols
44+
// :runDebugExecutableMacos - with debug symbols

gradle.properties

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
kotlin.code.style=official
2+
kotlin.import.noCommonSourceSets=true
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Thu May 16 20:56:15 CEST 2019
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip

settings.gradle

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pluginManagement {
2+
resolutionStrategy {
3+
eachPlugin {
4+
if (requested.id.id == "kotlin-multiplatform") {
5+
useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${requested.version}")
6+
}
7+
}
8+
}
9+
}
10+
rootProject.name = 'kotlin-hands-on-intro-kotlin-native'
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.jetbrains.handson.http
2+
3+
4+
import kotlinx.cinterop.*
5+
import libcurl.*
6+
7+
fun main(args: Array<String>) {
8+
if (args.size == 1) {
9+
val curl = curl_easy_init()
10+
if (curl != null) {
11+
curl_easy_setopt(curl, CURLOPT_URL, args[0])
12+
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L)
13+
val res = curl_easy_perform(curl)
14+
if (res != CURLE_OK) {
15+
println("curl_easy_perform() failed ${curl_easy_strerror(res)?.toKString()}")
16+
}
17+
curl_easy_cleanup(curl)
18+
}
19+
} else {
20+
println("Please provide a URL")
21+
}
22+
}
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
headers = curl/curl.h
2+
headerFilter = curl/*
3+
linkerOpts.osx = -L/opt/local/lib -L/usr/local/opt/curl/lib -lcurl
4+
linkerOpts.linux = -L/usr/lib64 -L/usr/lib/x86_64-linux-gnu -lcurl
5+
linkerOpts.mingw = -lcurl

0 commit comments

Comments
 (0)