diff --git a/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/NativeIdePlatformKind.kt b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/NativeIdePlatformKind.kt index ae0640255fb..3d3414992ae 100644 --- a/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/NativeIdePlatformKind.kt +++ b/idea/idea-native/src/org/jetbrains/kotlin/ide/konan/NativeIdePlatformKind.kt @@ -6,7 +6,6 @@ package org.jetbrains.kotlin.ide.konan import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments -import org.jetbrains.kotlin.cli.common.arguments.konan.K2NativeCompilerArguments import org.jetbrains.kotlin.config.TargetPlatformVersion import org.jetbrains.kotlin.platform.IdePlatform import org.jetbrains.kotlin.platform.IdePlatformKind @@ -15,7 +14,7 @@ import org.jetbrains.kotlin.resolve.konan.platform.KonanPlatform object NativeIdePlatformKind : IdePlatformKind() { override fun platformByCompilerArguments(arguments: CommonCompilerArguments): IdePlatform? { - return if (arguments is K2NativeCompilerArguments) Platform + return if (arguments is FakeK2NativeCompilerArguments) Platform else null } @@ -24,20 +23,23 @@ object NativeIdePlatformKind : IdePlatformKind() { override val platforms get() = listOf(Platform) override val defaultPlatform get() = Platform - override val argumentsClass get() = K2NativeCompilerArguments::class.java + override val argumentsClass get() = FakeK2NativeCompilerArguments::class.java override val name get() = "Native" - object Platform : IdePlatform() { + object Platform : IdePlatform() { override val kind get() = NativeIdePlatformKind override val version get() = TargetPlatformVersion.NoVersion - override fun createArguments(init: K2NativeCompilerArguments.() -> Unit) = K2NativeCompilerArguments().apply(init) + override fun createArguments(init: FakeK2NativeCompilerArguments.() -> Unit) = FakeK2NativeCompilerArguments().apply(init) } override fun equals(other: Any?): Boolean = other === NativeIdePlatformKind override fun hashCode(): Int = javaClass.hashCode() } +// These are fake compiler arguments for Kotlin/Native - only for usage within IDEA plugin: +class FakeK2NativeCompilerArguments : CommonCompilerArguments() + val IdePlatformKind<*>?.isKotlinNative get() = this === NativeIdePlatformKind diff --git a/konan/library-reader/src/org/jetbrains/kotlin/cli/common/arguments/konan/K2NativeCompilerArguments.kt b/konan/library-reader/src/org/jetbrains/kotlin/cli/common/arguments/konan/K2NativeCompilerArguments.kt deleted file mode 100644 index 6d1b71b92fe..00000000000 --- a/konan/library-reader/src/org/jetbrains/kotlin/cli/common/arguments/konan/K2NativeCompilerArguments.kt +++ /dev/null @@ -1,148 +0,0 @@ -/* - * 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/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.cli.common.arguments.konan - -import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments -import org.jetbrains.kotlin.cli.common.arguments.Argument -import org.jetbrains.kotlin.cli.common.messages.MessageCollector -import org.jetbrains.kotlin.config.AnalysisFlag - -class K2NativeCompilerArguments : CommonCompilerArguments() { - // First go the options interesting to the general public. - // Prepend them with a single dash. - // Keep the list lexically sorted. - - @Argument(value = "-enable_assertions", shortName = "-ea", description = "Enable runtime assertions in generated code") - var enableAssertions: Boolean = false - - @Argument(value = "-g", description = "Enable emitting debug information") - var debug: Boolean = false - - @Argument(value = "-generate_test_runner", shortName = "-tr", description = "Produce a runner for unit tests") - var generateTestRunner: Boolean = false - - @Argument(value = "-includeBinary", shortName = "-ib", valueDescription = "", description = "Pack external binary within the klib") - var includeBinaries: Array? = null - - @Argument(value = "-library", shortName = "-l", valueDescription = "", description = "Link with the library") - var libraries: Array? = null - - @Argument(value = "-list_targets", description = "List available hardware targets") - var listTargets: Boolean = false - - @Argument(value = "-manifest", valueDescription = "", description = "Provide a maniferst addend file") - var manifestFile: String? = null - - @Argument(value = "-module_name", valueDescription = "", description = "Spicify a name for the compilation module") - var moduleName: String? = null - - @Argument(value = "-nativelibrary", shortName = "-nl", valueDescription = "", description = "Include the native bitcode library") - var nativeLibraries: Array? = null - - @Argument(value = "-nodefaultlibs", description = "Don't link the libraries from dist/klib automatically") - var nodefaultlibs: Boolean = false - - @Argument(value = "-nomain", description = "Assume 'main' entry point to be provided by external libraries") - var nomain: Boolean = false - - @Argument(value = "-nopack", description = "Don't pack the library into a klib file") - var nopack: Boolean = false - - @Argument(value = "-linkerOpts", valueDescription = "", description = "Pass arguments to linker", delimiter = " ") - var linkerArguments: Array? = null - - @Argument(value = "-nostdlib", description = "Don't link with stdlib") - var nostdlib: Boolean = false - - @Argument(value = "-opt", description = "Enable optimizations during compilation") - var optimization: Boolean = false - - @Argument(value = "-output", shortName = "-o", valueDescription = "", description = "Output name") - var outputName: String? = null - - @Argument(value = "-entry", shortName = "-e", valueDescription = "", description = "Qualified entry point name") - var mainPackage: String? = null - - @Argument(value = "-produce", shortName = "-p", - valueDescription = "{program|static|dynamic|framework|library|bitcode}", - description = "Specify output file kind") - var produce: String? = null - - @Argument(value = "-repo", shortName = "-r", valueDescription = "", description = "Library search path") - var repositories: Array? = null - - @Argument(value = "-target", valueDescription = "", description = "Set hardware target") - 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. - - @Argument(value = "--check_dependencies", description = "Check dependencies and download the missing ones") - var checkDependencies: Boolean = false - - @Argument(value = "--disable", valueDescription = "", description = "Disable backend phase") - var disablePhases: Array? = null - - @Argument(value = "--enable", valueDescription = "", description = "Enable backend phase") - var enablePhases: Array? = null - - @Argument(value = "--list_phases", description = "List all backend phases") - var listPhases: Boolean = false - - @Argument(value = "--print_bitcode", description = "Print llvm bitcode") - var printBitCode: Boolean = false - - @Argument(value = "--print_descriptors", description = "Print descriptor tree") - var printDescriptors: Boolean = false - - @Argument(value = "--print_ir", description = "Print IR") - var printIr: Boolean = false - - @Argument(value = "--print_ir_with_descriptors", description = "Print IR with descriptors") - var printIrWithDescriptors: Boolean = false - - @Argument(value = "--print_locations", description = "Print locations") - var printLocations: Boolean = false - - @Argument(value = "--purge_user_libs", description = "Don't link unused libraries even explicitly specified") - var purgeUserLibs: Boolean = false - - @Argument(value = "--runtime", valueDescription = "", description = "Override standard 'runtime.bc' location") - var runtimeFile: String? = null - - @Argument(value = "--temporary_files_dir", valueDescription = "", description = "Save temporary files to the given directory") - var temporaryFilesDir: String? = null - - @Argument(value = "--time", description = "Report execution time for compiler phases") - var timePhases: Boolean = false - - @Argument(value = "--verbose", valueDescription = "", description = "Trace phase execution") - var verbosePhases: Array? = null - - @Argument(value = "--verify_bitcode", description = "Verify llvm bitcode after each method") - var verifyBitCode: Boolean = false - - @Argument(value = "--verify_descriptors", description = "Verify descriptor tree") - var verifyDescriptors: Boolean = false - - @Argument(value = "--verify_ir", description = "Verify IR") - var verifyIr: Boolean = false - - @Argument( - value = "-friend-modules", - valueDescription = "", - description = "Paths to friend modules" - ) - var friendModules: String? = null - - override fun configureAnalysisFlags(collector: MessageCollector): MutableMap, Any> = - super.configureAnalysisFlags(collector).also { - val useExperimental = it[AnalysisFlag.useExperimental] as List<*> - it[AnalysisFlag.useExperimental] = useExperimental + listOf("kotlin.ExperimentalUnsignedTypes") - } -} -