From d752d97dbd695701e13b0316e5b883b5218a9289 Mon Sep 17 00:00:00 2001 From: Alexander Gorshenev Date: Tue, 12 Dec 2017 12:49:23 +0300 Subject: [PATCH] Get rid of some build warnings. --- backend.native/build.gradle | 6 ++-- .../kotlin/backend/konan/CAdapterCompile.kt | 2 +- .../kotlin/backend/konan/CAdapterGenerator.kt | 6 ++-- .../kotlin/backend/konan/CompilerOutput.kt | 2 -- .../kotlin/backend/konan/LinkStage.kt | 4 --- .../konan/serialization/SerializeIr.kt | 6 ++-- .../kotlin/backend/konan/util/util.kt | 32 ------------------- 7 files changed, 10 insertions(+), 48 deletions(-) diff --git a/backend.native/build.gradle b/backend.native/build.gradle index c8c5a130433..e255187d678 100644 --- a/backend.native/build.gradle +++ b/backend.native/build.gradle @@ -92,7 +92,7 @@ task renamePackage(type: Copy) { from 'build/generated/source/proto/compiler/java' into 'build/renamed/source/proto/compiler/java' filter {line -> line.replaceAll("com.google.protobuf", "org.jetbrains.kotlin.protobuf")} - outputs.files('build/renamed') + outputs.dir('build/renamed') } kotlinNativeInterop { @@ -197,7 +197,7 @@ targetList.each { target -> inputs.dir(project(':runtime').file('src/main/kotlin')) inputs.dir(project(':Interop:Runtime').file('src/main/kotlin')) inputs.dir(project(':Interop:Runtime').file('src/native/kotlin')) - outputs.file(project(':runtime').file("build/${target}Stdlib")) + outputs.dir(project(':runtime').file("build/${target}Stdlib")) dependsOn ":runtime:${target}Runtime" } @@ -212,7 +212,7 @@ targetList.each { target -> project(':runtime').file('src/launcher/kotlin')] inputs.dir(project(':runtime').file('src/launcher/kotlin')) - outputs.file(project(':runtime').file("build/${target}Start")) + outputs.dir(project(':runtime').file("build/${target}Start")) dependsOn ":runtime:${target}Runtime", "${target}Stdlib" } diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CAdapterCompile.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CAdapterCompile.kt index c0ce5dd8741..c7ddf4bce20 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CAdapterCompile.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CAdapterCompile.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.konan.exec.* import org.jetbrains.kotlin.konan.target.* import org.jetbrains.kotlin.konan.file.* -fun produceCAdapterBitcode(clang: TargetClang, headerFileName: String, cppFileName: String, bitcodeFileName: String) { +fun produceCAdapterBitcode(clang: TargetClang, cppFileName: String, bitcodeFileName: String) { val clangCommand = clang.clangCXX("-std=c++11", cppFileName, "-emit-llvm", "-c", "-o", bitcodeFileName) runTool(clangCommand) } diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CAdapterGenerator.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CAdapterGenerator.kt index 42192fa81bb..8b9c060139d 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CAdapterGenerator.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CAdapterGenerator.kt @@ -317,10 +317,10 @@ internal class CAdapterGenerator(val context: Context, ExportedElement(ElementKind.PROPERTY, scopes.last(), declaration.descriptor, this) } - override fun visitFunction(function: IrFunction) { - val descriptor = function.descriptor + override fun visitFunction(declaration: IrFunction) { + val descriptor = declaration.descriptor if (!descriptor.isEffectivelyPublicApi || !descriptor.kind.isReal) return - ExportedElement(ElementKind.FUNCTION, scopes.last(), function.descriptor, this) + ExportedElement(ElementKind.FUNCTION, scopes.last(), declaration.descriptor, this) } override fun visitClass(declaration: IrClass) { diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CompilerOutput.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CompilerOutput.kt index 099e525034f..194bf91b43b 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CompilerOutput.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CompilerOutput.kt @@ -38,7 +38,6 @@ internal fun produceOutput(context: Context) { CompilerOutputKind.DYNAMIC, CompilerOutputKind.FRAMEWORK, CompilerOutputKind.PROGRAM -> { - val program = context.config.outputName val output = tempFiles.nativeBinaryFileName context.bitcodeFileName = output @@ -46,7 +45,6 @@ internal fun produceOutput(context: Context) { if (produce == CompilerOutputKind.DYNAMIC) { produceCAdapterBitcode( context.config.clang, - tempFiles.cAdapterHeaderName, tempFiles.cAdapterCppName, tempFiles.cAdapterBitcodeName) listOf(tempFiles.cAdapterBitcodeName) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/LinkStage.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/LinkStage.kt index a61cf403c9b..5fffccbf981 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/LinkStage.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/LinkStage.kt @@ -22,8 +22,6 @@ import java.lang.ProcessBuilder.Redirect import org.jetbrains.kotlin.konan.file.* import org.jetbrains.kotlin.konan.properties.* import org.jetbrains.kotlin.konan.target.* -import org.jetbrains.kotlin.backend.konan.util.listConstructor -import org.jetbrains.kotlin.backend.konan.util.If typealias BitcodeFile = String typealias ObjectFile = String @@ -269,8 +267,6 @@ internal open class WasmPlatform(distribution: Distribution) private fun javaScriptLink(jsFiles: List, executable: String): String { val linkedJavaScript = File("$executable.js") - val jsLibsExceptLauncher = jsFiles.filter { it != "launcher.js" }.map { it.removeSuffix(".js") } - val linkerStub = "var konan = { libraries: [] };\n" linkedJavaScript.writeBytes(linkerStub.toByteArray()); diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/SerializeIr.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/SerializeIr.kt index 8ffd3f81f7d..e6b95b84f81 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/SerializeIr.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/SerializeIr.kt @@ -1009,7 +1009,7 @@ internal class IrDeserializer(val context: Context, return IrWhenImpl(start, end, type, null, branches) } - fun deserializeLoop(proto: KonanIr.Loop, start: Int, end: Int, type: KotlinType, loop: IrLoopBase): IrLoopBase { + fun deserializeLoop(proto: KonanIr.Loop, loop: IrLoopBase): IrLoopBase { val loopId = proto.getLoopId() loopIndex.getOrPut(loopId){loop} @@ -1028,7 +1028,7 @@ internal class IrDeserializer(val context: Context, // we create the loop before deserializing the body, so that // IrBreak statements have something to put into 'loop' field. val loop = IrDoWhileLoopImpl(start, end, type, null) - deserializeLoop(proto.loop, start, end, type, loop) + deserializeLoop(proto.loop, loop) return loop } @@ -1036,7 +1036,7 @@ internal class IrDeserializer(val context: Context, // we create the loop before deserializing the body, so that // IrBreak statements have something to put into 'loop' field. val loop = IrWhileLoopImpl(start, end, type, null) - deserializeLoop(proto.loop, start, end, type, loop) + deserializeLoop(proto.loop, loop) return loop } diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/util/util.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/util/util.kt index f10f96b7486..4eb46cf3e6a 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/util/util.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/util/util.kt @@ -54,35 +54,3 @@ fun String.removeSuffixIfPresent(suffix: String) = if (this.endsWith(suffix)) this.dropLast(suffix.length) else this fun Lazy.getValueOrNull(): T? = if (isInitialized()) value else null - -// The listConstructor() and If functions are convenient to construct -// command lines having a bunch of elements, lists and conditions. -// Use them like -// -// listConstructor( -// anElement1, -// If (condition1, -// element2), -// aList1, -// If (condition2, -// alist3, -// alist4) -// ) - -internal fun listConstructor(vararg elements: Any): List { - val result = mutableListOf() - for (element in elements) { - when (element) { - null -> {} - is String -> result.add(element) - is List<*> -> result.addAll(element as List) - else -> error("Unexpected element of listConstructor: $element") - } - } - return result -} - -internal fun If (condition: Boolean, vararg elements: Any): List = - if (condition) listConstructor(*elements) else emptyList() - -