[KLIB tool] Entry point for tests: org.jetbrains.kotlin.cli.klib.Main.exec
^KT-62340
This commit is contained in:
committed by
Space Team
parent
16a27c2e05
commit
215303606b
@@ -2,16 +2,28 @@
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
@file:JvmName("Main")
|
||||
|
||||
package org.jetbrains.kotlin.cli.klib
|
||||
|
||||
// TODO: Extract `library` package as a shared jar?
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
fun main(rawArgs: Array<String>) {
|
||||
val output = KlibToolOutput(stdout = System.out, stderr = System.err)
|
||||
/**
|
||||
* This entry point is used in various KLIB dumping tests: dumping IR, dumping metadata, dumping signatures, etc.
|
||||
*/
|
||||
@Suppress("unused")
|
||||
fun exec(stdout: Appendable, stderr: Appendable, args: Array<String>): Int {
|
||||
return execImpl(KlibToolOutput(stdout, stderr), args)
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val exitCode = execImpl(KlibToolOutput(stdout = System.out, stderr = System.err), args)
|
||||
if (exitCode != 0) exitProcess(exitCode)
|
||||
}
|
||||
|
||||
private fun execImpl(output: KlibToolOutput, rawArgs: Array<String>): Int {
|
||||
val args = KlibToolArgumentsParser(output).parseArguments(rawArgs)
|
||||
|
||||
if (args != null) {
|
||||
val command = when (args.commandName) {
|
||||
"dump-abi" -> DumpAbi(output, args)
|
||||
@@ -37,6 +49,5 @@ fun main(rawArgs: Array<String>) {
|
||||
}
|
||||
}
|
||||
|
||||
if (output.hasErrors)
|
||||
exitProcess(1)
|
||||
return if (output.hasErrors) 1 else 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user