diff --git a/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt b/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt index 6169b7f3b96..73f062ec526 100644 --- a/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt +++ b/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt @@ -97,8 +97,8 @@ class K2Native : CLICompiler() { arguments.libraries.toNonNullList()) put(LINKER_ARGS, arguments.linkerArguments.toNonNullList()) - if (arguments.target != null) - put(TARGET, arguments.target) + + arguments.target ?.let{ put(TARGET, it) } put(NATIVE_LIBRARY_FILES, arguments.nativeLibraries.toNonNullList()) @@ -122,10 +122,9 @@ class K2Native : CLICompiler() { put(CommonConfigurationKeys.MODULE_NAME, output) put(ABI_VERSION, 1) - if (arguments.runtimeFile != null) - put(RUNTIME_FILE, arguments.runtimeFile) - if (arguments.propertyFile != null) - put(PROPERTY_FILE, arguments.propertyFile) + arguments.runtimeFile ?.let{ put(RUNTIME_FILE, it) } + arguments.propertyFile ?.let{ put(PROPERTY_FILE, it) } + put(LIST_TARGETS, arguments.listTargets) put(OPTIMIZATION, arguments.optimization) put(DEBUG, arguments.debug) diff --git a/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.java b/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.java deleted file mode 100644 index c4c6f868f71..00000000000 --- a/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.java +++ /dev/null @@ -1,120 +0,0 @@ - -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.cli.bc; - -import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments; -import org.jetbrains.kotlin.cli.common.arguments.Argument; - -public class K2NativeCompilerArguments extends CommonCompilerArguments { - // First go the options interesting to the general public. - // Prepend them with a single dash. - // Keep the list lexically sorted. - - @Argument(value = "-g", description = "Enable emitting debug information") - public boolean debug; - - @Argument(value = "-enable_assertions", shortName = "-ea", description = "Enable runtime assertions in generated code") - public boolean enableAssertions; - - @Argument(value = "-library", shortName = "-l", valueDescription = "", description = "Link with the library") - public String[] libraries; - - @Argument(value = "-list_targets", description = "List available hardware targets") - public boolean listTargets; - - @Argument(value = "-nativelibrary", shortName = "-nl", valueDescription = "", description = "Include the native library") - public String[] nativeLibraries; - - @Argument(value = "-nomain", description = "Assume 'main' entry point to be provided by external libraries") - public boolean nomain; - - @Argument(value = "-nopack", description = "Don't pack the library into a klib file") - public boolean nopack; - - @Argument(value = "-linkerOpts", valueDescription = "", description = "Pass arguments to linker", delimiter = " ") - public String[] linkerArguments; - - @Argument(value = "-nostdlib", description = "Don't link with stdlib") - public boolean nostdlib; - - @Argument(value = "-opt", description = "Enable optimizations during compilation") - public boolean optimization; - - @Argument(value = "-output", shortName = "-o", valueDescription = "", description = "Output file path") - public String outputFile; - - @Argument(value = "-produce", shortName = "-p", valueDescription = "{program|library|bitcode}", description = "Produce either .kexe, .klib or a .bc file.") - public String produce; - - @Argument(value = "-properties", valueDescription = "", description = "Override standard 'konan.properties' location") - public String propertyFile; - - @Argument(value = "-repo", shortName = "-r", valueDescription = "", description = "Library search path") - public String[] repositories; - - @Argument(value = "-runtime", valueDescription = "", description = "Override standard 'runtime.bc' location") - public String runtimeFile; - - @Argument(value = "-target", valueDescription = "", description = "Set hardware target") - public String target; - - // The rest of the options are only interesting to the developers. - // Make sure to prepend them with a double dash. - // Keep the list lexically sorted. - - @Argument(value = "--enable", valueDescription = "", description = "Enable backend phase") - public String[] enablePhases; - - @Argument(value = "--disable", valueDescription = "", description = "Disable backend phase") - public String[] disablePhases; - - @Argument(value = "--list_phases", description = "List all backend phases") - public boolean listPhases; - - @Argument(value = "--print_bitcode", description = "Print llvm bitcode") - public boolean printBitCode; - - @Argument(value = "--print_descriptors", description = "Print descriptor tree") - public boolean printDescriptors; - - @Argument(value = "--print_ir", description = "Print IR") - public boolean printIr; - - @Argument(value = "--print_ir_with_descriptors", description = "Print IR with descriptors") - public boolean printIrWithDescriptors; - - @Argument(value = "--print_locations", description = "Print locations") - public boolean printLocations; - - @Argument(value = "--time", description = "Report execution time for compiler phases") - public boolean timePhases; - - @Argument(value = "--verbose", valueDescription = "", description = "Trace phase execution") - public String[] verbosePhases; - - @Argument(value = "--verify_bitcode", description = "Verify llvm bitcode after each method") - public boolean verifyBitCode; - - @Argument(value = "--verify_descriptors", description = "Verify descriptor tree") - public boolean verifyDescriptors; - - @Argument(value = "--verify_ir", description = "Verify IR") - public boolean verifyIr; - -} - diff --git a/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt b/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt new file mode 100644 index 00000000000..ea9fd080281 --- /dev/null +++ b/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt @@ -0,0 +1,119 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.cli.bc + +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.Argument + +class K2NativeCompilerArguments : CommonCompilerArguments() { + // First go the options interesting to the general public. + // Prepend them with a single dash. + // Keep the list lexically sorted. + + @field:Argument(value = "-g", description = "Enable emitting debug information") + @JvmField var debug: Boolean = false + + @field:Argument(value = "-enable_assertions", shortName = "-ea", description = "Enable runtime assertions in generated code") + @JvmField var enableAssertions: Boolean = false + + @field:Argument(value = "-library", shortName = "-l", valueDescription = "", description = "Link with the library") + @JvmField var libraries: Array? = null + + @field:Argument(value = "-list_targets", description = "List available hardware targets") + @JvmField var listTargets: Boolean = false + + @field:Argument(value = "-nativelibrary", shortName = "-nl", valueDescription = "", description = "Include the native library") + @JvmField var nativeLibraries: Array? = null + + @field:Argument(value = "-nomain", description = "Assume 'main' entry point to be provided by external libraries") + @JvmField var nomain: Boolean = false + + @field:Argument(value = "-nopack", description = "Don't pack the library into a klib file") + @JvmField var nopack: Boolean = false + + @field:Argument(value = "-linkerOpts", valueDescription = "", description = "Pass arguments to linker", delimiter = " ") + @JvmField var linkerArguments: Array? = null + + @field:Argument(value = "-nostdlib", description = "Don't link with stdlib") + @JvmField var nostdlib: Boolean = false + + @field:Argument(value = "-opt", description = "Enable optimizations during compilation") + @JvmField var optimization: Boolean = false + + @field:Argument(value = "-output", shortName = "-o", valueDescription = "", description = "Output file path") + @JvmField var outputFile: String? = null + + @field:Argument(value = "-produce", shortName = "-p", valueDescription = "{program|library|bitcode}", description = "Produce either .kexe, .klib or a .bc file.") + @JvmField var produce: String? = null + + @field:Argument(value = "-properties", valueDescription = "", description = "Override standard 'konan.properties' location") + @JvmField var propertyFile: String? = null + + @field:Argument(value = "-repo", shortName = "-r", valueDescription = "", description = "Library search path") + @JvmField var repositories: Array? = null + + @field:Argument(value = "-runtime", valueDescription = "", description = "Override standard 'runtime.bc' location") + @JvmField var runtimeFile: String? = null + + @field:Argument(value = "-target", valueDescription = "", description = "Set hardware target") + @JvmField var target: String? = null + + // The rest of the options are only interesting to the developers. + // Make sure to prepend them with a double dash. + // Keep the list lexically sorted. + + @field:Argument(value = "--enable", valueDescription = "", description = "Enable backend phase") + @JvmField var enablePhases: Array? = null + + @field:Argument(value = "--disable", valueDescription = "", description = "Disable backend phase") + @JvmField var disablePhases: Array? = null + + @field:Argument(value = "--list_phases", description = "List all backend phases") + @JvmField var listPhases: Boolean = false + + @field:Argument(value = "--print_bitcode", description = "Print llvm bitcode") + @JvmField var printBitCode: Boolean = false + + @field:Argument(value = "--print_descriptors", description = "Print descriptor tree") + @JvmField var printDescriptors: Boolean = false + + @field:Argument(value = "--print_ir", description = "Print IR") + @JvmField var printIr: Boolean = false + + @field:Argument(value = "--print_ir_with_descriptors", description = "Print IR with descriptors") + @JvmField var printIrWithDescriptors: Boolean = false + + @field:Argument(value = "--print_locations", description = "Print locations") + @JvmField var printLocations: Boolean = false + + @field:Argument(value = "--time", description = "Report execution time for compiler phases") + @JvmField var timePhases: Boolean = false + + @field:Argument(value = "--verbose", valueDescription = "", description = "Trace phase execution") + @JvmField var verbosePhases: Array? = null + + @field:Argument(value = "--verify_bitcode", description = "Verify llvm bitcode after each method") + @JvmField var verifyBitCode: Boolean = false + + @field:Argument(value = "--verify_descriptors", description = "Verify descriptor tree") + @JvmField var verifyDescriptors: Boolean = false + + @field:Argument(value = "--verify_ir", description = "Verify IR") + @JvmField var verifyIr: Boolean = false + +} +