K/N: add fake compiler arguments (only to be used in IDEA plugin)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
f663c0ea87
commit
22e6948d7d
@@ -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<NativeIdePlatformKind>() {
|
||||
|
||||
override fun platformByCompilerArguments(arguments: CommonCompilerArguments): IdePlatform<NativeIdePlatformKind, CommonCompilerArguments>? {
|
||||
return if (arguments is K2NativeCompilerArguments) Platform
|
||||
return if (arguments is FakeK2NativeCompilerArguments) Platform
|
||||
else null
|
||||
}
|
||||
|
||||
@@ -24,20 +23,23 @@ object NativeIdePlatformKind : IdePlatformKind<NativeIdePlatformKind>() {
|
||||
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<NativeIdePlatformKind, K2NativeCompilerArguments>() {
|
||||
object Platform : IdePlatform<NativeIdePlatformKind, FakeK2NativeCompilerArguments>() {
|
||||
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
|
||||
|
||||
|
||||
-148
@@ -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 = "<path>", description = "Pack external binary within the klib")
|
||||
var includeBinaries: Array<String>? = null
|
||||
|
||||
@Argument(value = "-library", shortName = "-l", valueDescription = "<path>", description = "Link with the library")
|
||||
var libraries: Array<String>? = null
|
||||
|
||||
@Argument(value = "-list_targets", description = "List available hardware targets")
|
||||
var listTargets: Boolean = false
|
||||
|
||||
@Argument(value = "-manifest", valueDescription = "<path>", description = "Provide a maniferst addend file")
|
||||
var manifestFile: String? = null
|
||||
|
||||
@Argument(value = "-module_name", valueDescription = "<name>", description = "Spicify a name for the compilation module")
|
||||
var moduleName: String? = null
|
||||
|
||||
@Argument(value = "-nativelibrary", shortName = "-nl", valueDescription = "<path>", description = "Include the native bitcode library")
|
||||
var nativeLibraries: Array<String>? = 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 = "<arg>", description = "Pass arguments to linker", delimiter = " ")
|
||||
var linkerArguments: Array<String>? = 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 = "<name>", description = "Output name")
|
||||
var outputName: String? = null
|
||||
|
||||
@Argument(value = "-entry", shortName = "-e", valueDescription = "<name>", 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 = "<path>", description = "Library search path")
|
||||
var repositories: Array<String>? = null
|
||||
|
||||
@Argument(value = "-target", valueDescription = "<target>", 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 = "<Phase>", description = "Disable backend phase")
|
||||
var disablePhases: Array<String>? = null
|
||||
|
||||
@Argument(value = "--enable", valueDescription = "<Phase>", description = "Enable backend phase")
|
||||
var enablePhases: Array<String>? = 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 = "<path>", description = "Override standard 'runtime.bc' location")
|
||||
var runtimeFile: String? = null
|
||||
|
||||
@Argument(value = "--temporary_files_dir", valueDescription = "<path>", 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 = "<Phase>", description = "Trace phase execution")
|
||||
var verbosePhases: Array<String>? = 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 = "<path>",
|
||||
description = "Paths to friend modules"
|
||||
)
|
||||
var friendModules: String? = null
|
||||
|
||||
override fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> =
|
||||
super.configureAnalysisFlags(collector).also {
|
||||
val useExperimental = it[AnalysisFlag.useExperimental] as List<*>
|
||||
it[AnalysisFlag.useExperimental] = useExperimental + listOf("kotlin.ExperimentalUnsignedTypes")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user