[Platform API] Introduce fundamental abstraction of Platform
This is a large commit, which introduces general API for working with
abstraction of Platform.
- Add new abstraction to 'core' - SimplePlatform - which represents
exactly one platform
- Clients are strongly prohibited to create instances of SimplePlatform
by hand, instead, corresponding *Platforms abstraction should be used
(e.g. JvmPlatforms, JsPlatforms, KonanPlatforms)
- Move TargetPlatform to 'core', it represents now a collection of
SimplePlatforms
- Clients are strongly encouraged to use TargetPlatform
(not SimplePlatform) in API, to enforce checks for multiplatform
- Provide a helper-extensions to work with TargetPlatform
(in particular, for getting a specific component platform)
- Remove MultiTargetPlatform in favour of TargetPlatform
- Notably, this commit leaves another widely used duplicated abstraction,
namely, IdePlatform. For the sake sanity, removal of IdePlatform is
extracted in the separate commit.
This commit is contained in:
@@ -30,8 +30,8 @@ import org.jetbrains.kotlin.noarg.NoArgConfigurationKeys.ANNOTATION
|
||||
import org.jetbrains.kotlin.noarg.NoArgConfigurationKeys.INVOKE_INITIALIZERS
|
||||
import org.jetbrains.kotlin.noarg.NoArgConfigurationKeys.PRESET
|
||||
import org.jetbrains.kotlin.noarg.diagnostic.CliNoArgDeclarationChecker
|
||||
import org.jetbrains.kotlin.resolve.TargetPlatform
|
||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.kotlin.platform.jvm.isJvm
|
||||
|
||||
object NoArgConfigurationKeys {
|
||||
val ANNOTATION: CompilerConfigurationKey<List<String>> =
|
||||
@@ -89,9 +89,9 @@ class NoArgComponentRegistrar : ComponentRegistrar {
|
||||
|
||||
class CliNoArgComponentContainerContributor(val annotations: List<String>) : StorageComponentContainerContributor {
|
||||
override fun registerModuleComponents(
|
||||
container: StorageComponentContainer, platform: TargetPlatform, moduleDescriptor: ModuleDescriptor
|
||||
container: StorageComponentContainer, platform: TargetPlatform, moduleDescriptor: ModuleDescriptor
|
||||
) {
|
||||
if (platform != JvmPlatform) return
|
||||
if (!platform.isJvm()) return
|
||||
|
||||
container.useInstance(CliNoArgDeclarationChecker(annotations))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user