KT-65811 Run Swift export from CLI
diff --git a/native/swift/swift-export-standalone/build.gradle.kts b/native/swift/swift-export-standalone/build.gradle.kts
index 676ec20..a0aee7d 100644
--- a/native/swift/swift-export-standalone/build.gradle.kts
+++ b/native/swift/swift-export-standalone/build.gradle.kts
@@ -48,3 +48,9 @@
}
testsJar()
+
+tasks.register("runSwiftExport", JavaExec::class) {
+ classpath(sourceSets.test.get().runtimeClasspath)
+ workingDir(project.rootDir)
+ mainClass.set("org.jetbrains.kotlin.swiftexport.standalone.SwiftExportRunner")
+}
diff --git a/native/swift/swift-export-standalone/src/org/jetbrains/kotlin/swiftexport/standalone/SwiftExportRunner.kt b/native/swift/swift-export-standalone/src/org/jetbrains/kotlin/swiftexport/standalone/SwiftExportRunner.kt
index 91f6aca..8718d87 100644
--- a/native/swift/swift-export-standalone/src/org/jetbrains/kotlin/swiftexport/standalone/SwiftExportRunner.kt
+++ b/native/swift/swift-export-standalone/src/org/jetbrains/kotlin/swiftexport/standalone/SwiftExportRunner.kt
@@ -2,6 +2,7 @@
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
+@file:JvmName("SwiftExportRunner")
package org.jetbrains.kotlin.swiftexport.standalone
@@ -15,6 +16,25 @@
import org.jetbrains.kotlin.swiftexport.standalone.writer.dumpResultToFiles
import org.jetbrains.kotlin.utils.KotlinNativePaths
import java.nio.file.Path
+import java.nio.file.Paths
+
+public fun main(args: Array<String>) {
+ runSwiftExport(
+ input = SwiftExportInput(
+ sourceRoot = Paths.get(System.getenv("SWIFT_EXPORT_INPUT_SOURCE_ROOT_PATH")),
+ libraries = emptyList(),
+ ),
+ config = SwiftExportConfig(
+ emptyMap(),
+ createDummyLogger()
+ ),
+ output = SwiftExportOutput(
+ swiftApi = Paths.get(System.getenv("SWIFT_EXPORT_OUTPUT_SWIFT_API_PATH")),
+ kotlinBridges = Paths.get(System.getenv("SWIFT_EXPORT_OUTPUT_KOTLIN_BRIDGE_PATH")),
+ cHeaderBridges = Paths.get(System.getenv("SWIFT_EXPORT_OUTPUT_C_HEADER_BRIDGE_PATH")),
+ )
+ )
+}
public data class SwiftExportConfig(
val settings: Map<String, String> = emptyMap(),