Skip to content
This repository has been archived by the owner on Jun 22, 2024. It is now read-only.

Commit

Permalink
chore(examples/native): Fix build.gradle.kts
Browse files Browse the repository at this point in the history
  • Loading branch information
sya-ri committed Nov 10, 2023
1 parent 1bc9899 commit 9a35d41
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 36 deletions.
44 changes: 13 additions & 31 deletions examples/native/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,15 @@ plugins {
}

kotlin {
macosX64 {
binaries {
executable {
entryPoint = "dev.s7a.example.gofile.main"
}
}
}

linuxX64 {
binaries {
executable {
entryPoint = "dev.s7a.example.gofile.main"
}
}
}
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")

mingwX64 {
when {
hostOs == "Mac OS X" -> macosX64()
hostOs == "Linux" -> linuxX64()
isMingwX64 -> mingwX64()
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}.apply {
binaries {
executable {
entryPoint = "dev.s7a.example.gofile.main"
Expand All @@ -32,21 +24,11 @@ kotlin {
dependencies {
implementation(project(":"))
implementation("com.squareup.okio:okio:3.2.0")
}
}
macosMain {
dependencies {
implementation("io.ktor:ktor-client-cio:2.3.6")
}
}
linuxMain {
dependencies {
implementation("io.ktor:ktor-client-cio:2.3.6")
}
}
mingwMain {
dependencies {
implementation("io.ktor:ktor-client-winhttp:2.3.6")
if (isMingwX64) {
implementation("io.ktor:ktor-client-winhttp:2.3.6")
} else {
implementation("io.ktor:ktor-client-cio:2.3.6")
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ fun main() {
}
}

private object ExitCode {
const val NoInputPath = 1
const val NoSuchFile = 2
const val IsNotFile = 3
const val UploadFailed = 4
private enum class ExitCode {
NoInputPath,
NoSuchFile,
IsNotFile,
UploadFailed,
}

private fun exitProcess(exitCode: ExitCode): Nothing {
exitProcess(exitCode.ordinal + 1)
}

private fun inputFile(): Pair<String, ByteArray> {
Expand Down

0 comments on commit 9a35d41

Please sign in to comment.