HMPP: import flag indicating that the project uses HMPP feature
This commit is contained in:
+2
@@ -55,6 +55,8 @@ var DataNode<ModuleData>.compilerArgumentsBySourceSet
|
|||||||
by CopyableDataNodeUserDataProperty(Key.create<CompilerArgumentsBySourceSet>("CURRENT_COMPILER_ARGUMENTS"))
|
by CopyableDataNodeUserDataProperty(Key.create<CompilerArgumentsBySourceSet>("CURRENT_COMPILER_ARGUMENTS"))
|
||||||
var DataNode<ModuleData>.coroutines
|
var DataNode<ModuleData>.coroutines
|
||||||
by CopyableDataNodeUserDataProperty(Key.create<String>("KOTLIN_COROUTINES"))
|
by CopyableDataNodeUserDataProperty(Key.create<String>("KOTLIN_COROUTINES"))
|
||||||
|
var DataNode<out ModuleData>.isHmpp
|
||||||
|
by NotNullableCopyableDataNodeUserDataProperty(Key.create<Boolean>("IS_HMPP_MODULE"), false)
|
||||||
var DataNode<ModuleData>.platformPluginId
|
var DataNode<ModuleData>.platformPluginId
|
||||||
by CopyableDataNodeUserDataProperty(Key.create<String>("PLATFORM_PLUGIN_ID"))
|
by CopyableDataNodeUserDataProperty(Key.create<String>("PLATFORM_PLUGIN_ID"))
|
||||||
var DataNode<out ModuleData>.implementedModuleNames
|
var DataNode<out ModuleData>.implementedModuleNames
|
||||||
|
|||||||
+1
-1
@@ -288,7 +288,7 @@ fun configureFacetByGradleModule(
|
|||||||
)
|
)
|
||||||
|
|
||||||
val kotlinFacet = ideModule.getOrCreateFacet(modelsProvider, false, GradleConstants.SYSTEM_ID.id)
|
val kotlinFacet = ideModule.getOrCreateFacet(modelsProvider, false, GradleConstants.SYSTEM_ID.id)
|
||||||
kotlinFacet.configureFacet(compilerVersion, coroutinesProperty, platform, modelsProvider)
|
kotlinFacet.configureFacet(compilerVersion, coroutinesProperty, platform, modelsProvider, moduleNode.isHmpp)
|
||||||
|
|
||||||
if (sourceSetNode == null) {
|
if (sourceSetNode == null) {
|
||||||
ideModule.compilerArgumentsBySourceSet = moduleNode.compilerArgumentsBySourceSet
|
ideModule.compilerArgumentsBySourceSet = moduleNode.compilerArgumentsBySourceSet
|
||||||
|
|||||||
+1
@@ -360,6 +360,7 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mainModuleNode.coroutines = mppModel.extraFeatures.coroutinesState
|
mainModuleNode.coroutines = mppModel.extraFeatures.coroutinesState
|
||||||
|
mainModuleNode.isHmpp = mppModel.extraFeatures.isHMPPEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
fun populateContentRoots(
|
fun populateContentRoots(
|
||||||
|
|||||||
+1
-1
@@ -121,7 +121,7 @@ class KotlinSourceSetDataService : AbstractProjectDataService<GradleSourceSetDat
|
|||||||
)
|
)
|
||||||
|
|
||||||
val kotlinFacet = ideModule.getOrCreateFacet(modelsProvider, false)
|
val kotlinFacet = ideModule.getOrCreateFacet(modelsProvider, false)
|
||||||
kotlinFacet.configureFacet(compilerVersion, coroutinesProperty, platform, modelsProvider)
|
kotlinFacet.configureFacet(compilerVersion, coroutinesProperty, platform, modelsProvider, mainModuleNode.isHmpp)
|
||||||
|
|
||||||
val compilerArguments = kotlinSourceSet.compilerArguments
|
val compilerArguments = kotlinSourceSet.compilerArguments
|
||||||
val defaultCompilerArguments = kotlinSourceSet.defaultCompilerArguments
|
val defaultCompilerArguments = kotlinSourceSet.defaultCompilerArguments
|
||||||
|
|||||||
@@ -239,6 +239,7 @@ class KotlinFacetSettings {
|
|||||||
var isTestModule: Boolean = false
|
var isTestModule: Boolean = false
|
||||||
|
|
||||||
var externalProjectId: String = ""
|
var externalProjectId: String = ""
|
||||||
|
var isHmppEnabled: Boolean = false
|
||||||
}
|
}
|
||||||
|
|
||||||
interface KotlinFacetSettingsProvider {
|
interface KotlinFacetSettingsProvider {
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ private fun readV2AndLaterConfig(element: Element): KotlinFacetSettings {
|
|||||||
} ?: KotlinModuleKind.DEFAULT
|
} ?: KotlinModuleKind.DEFAULT
|
||||||
isTestModule = element.getAttributeValue("isTestModule")?.toBoolean() ?: false
|
isTestModule = element.getAttributeValue("isTestModule")?.toBoolean() ?: false
|
||||||
externalProjectId = element.getAttributeValue("externalProjectId") ?: ""
|
externalProjectId = element.getAttributeValue("externalProjectId") ?: ""
|
||||||
|
isHmppEnabled = element.getAttribute("isHmppProject")?.booleanValue ?: false
|
||||||
element.getChild("compilerSettings")?.let {
|
element.getChild("compilerSettings")?.let {
|
||||||
compilerSettings = CompilerSettings()
|
compilerSettings = CompilerSettings()
|
||||||
XmlSerializer.deserializeInto(compilerSettings!!, it)
|
XmlSerializer.deserializeInto(compilerSettings!!, it)
|
||||||
@@ -326,6 +327,9 @@ private fun KotlinFacetSettings.writeLatestConfig(element: Element) {
|
|||||||
if (externalProjectId.isNotEmpty()) {
|
if (externalProjectId.isNotEmpty()) {
|
||||||
element.setAttribute("externalProjectId", externalProjectId)
|
element.setAttribute("externalProjectId", externalProjectId)
|
||||||
}
|
}
|
||||||
|
if (isHmppEnabled) {
|
||||||
|
element.setAttribute("isHmppProject", isHmppEnabled.toString())
|
||||||
|
}
|
||||||
productionOutputPath?.let {
|
productionOutputPath?.let {
|
||||||
if (it != (compilerArguments as? K2JSCompilerArguments)?.outputFile) {
|
if (it != (compilerArguments as? K2JSCompilerArguments)?.outputFile) {
|
||||||
element.addContent(Element("productionOutputPath").apply { addContent(PathUtil.toSystemIndependentName(it)) })
|
element.addContent(Element("productionOutputPath").apply { addContent(PathUtil.toSystemIndependentName(it)) })
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ class KotlinMavenImporter : MavenImporter(KOTLIN_PLUGIN_GROUP_ID, KOTLIN_PLUGIN_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
configureFacet(mavenProject, modifiableModelsProvider, module)
|
configureFacet(mavenProject, modifiableModelsProvider, module, false) //HMPP is not supported currently for maven
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun scheduleDownloadStdlibSources(mavenProject: MavenProject, module: Module) {
|
private fun scheduleDownloadStdlibSources(mavenProject: MavenProject, module: Module) {
|
||||||
@@ -243,7 +243,7 @@ class KotlinMavenImporter : MavenImporter(KOTLIN_PLUGIN_GROUP_ID, KOTLIN_PLUGIN_
|
|||||||
PomFile.KotlinGoals.MetaData
|
PomFile.KotlinGoals.MetaData
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun configureFacet(mavenProject: MavenProject, modifiableModelsProvider: IdeModifiableModelsProvider, module: Module) {
|
private fun configureFacet(mavenProject: MavenProject, modifiableModelsProvider: IdeModifiableModelsProvider, module: Module, isHmppModule: Boolean) {
|
||||||
val mavenPlugin = mavenProject.findPlugin(KotlinMavenConfigurator.GROUP_ID, KotlinMavenConfigurator.MAVEN_PLUGIN_ID) ?: return
|
val mavenPlugin = mavenProject.findPlugin(KotlinMavenConfigurator.GROUP_ID, KotlinMavenConfigurator.MAVEN_PLUGIN_ID) ?: return
|
||||||
val compilerVersion = mavenPlugin.version ?: LanguageVersion.LATEST_STABLE.versionString
|
val compilerVersion = mavenPlugin.version ?: LanguageVersion.LATEST_STABLE.versionString
|
||||||
val kotlinFacet = module.getOrCreateFacet(
|
val kotlinFacet = module.getOrCreateFacet(
|
||||||
@@ -255,7 +255,7 @@ class KotlinMavenImporter : MavenImporter(KOTLIN_PLUGIN_GROUP_ID, KOTLIN_PLUGIN_
|
|||||||
// TODO There should be a way to figure out the correct platform version
|
// TODO There should be a way to figure out the correct platform version
|
||||||
val platform = detectPlatform(mavenProject)?.defaultPlatform
|
val platform = detectPlatform(mavenProject)?.defaultPlatform
|
||||||
|
|
||||||
kotlinFacet.configureFacet(compilerVersion, LanguageFeature.Coroutines.defaultState, platform, modifiableModelsProvider)
|
kotlinFacet.configureFacet(compilerVersion, LanguageFeature.Coroutines.defaultState, platform, modifiableModelsProvider, hmppEnabled = isHmppModule)
|
||||||
val facetSettings = kotlinFacet.configuration.settings
|
val facetSettings = kotlinFacet.configuration.settings
|
||||||
val configuredPlatform = kotlinFacet.configuration.settings.targetPlatform!!
|
val configuredPlatform = kotlinFacet.configuration.settings.targetPlatform!!
|
||||||
val configuration = mavenPlugin.configurationElement
|
val configuration = mavenPlugin.configurationElement
|
||||||
|
|||||||
+1
-1
@@ -282,7 +282,7 @@ fun configureLanguageAndApiVersion(
|
|||||||
WriteAction.run<Throwable> {
|
WriteAction.run<Throwable> {
|
||||||
val modelsProvider = IdeModifiableModelsProviderImpl(project)
|
val modelsProvider = IdeModifiableModelsProviderImpl(project)
|
||||||
val facet = module.getOrCreateFacet(modelsProvider, useProjectSettings = false)
|
val facet = module.getOrCreateFacet(modelsProvider, useProjectSettings = false)
|
||||||
facet.configureFacet(languageVersion, LanguageFeature.State.DISABLED, null, modelsProvider)
|
facet.configureFacet(languageVersion, LanguageFeature.State.DISABLED, null, modelsProvider, false)
|
||||||
if (apiVersion != null) {
|
if (apiVersion != null) {
|
||||||
facet.configuration.settings.apiLevel = LanguageVersion.fromVersionString(apiVersion)
|
facet.configuration.settings.apiLevel = LanguageVersion.fromVersionString(apiVersion)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ interface KotlinTarget : Serializable {
|
|||||||
|
|
||||||
interface ExtraFeatures : Serializable {
|
interface ExtraFeatures : Serializable {
|
||||||
val coroutinesState: String?
|
val coroutinesState: String?
|
||||||
|
val isHMPPEnabled: Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
interface KotlinMPPGradleModel : Serializable {
|
interface KotlinMPPGradleModel : Serializable {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
|||||||
val coroutinesState = getCoroutinesState(project)
|
val coroutinesState = getCoroutinesState(project)
|
||||||
reportUnresolvedDependencies(targets)
|
reportUnresolvedDependencies(targets)
|
||||||
val kotlinNativeHome = KotlinNativeHomeEvaluator.getKotlinNativeHome(project) ?: NO_KOTLIN_NATIVE_HOME
|
val kotlinNativeHome = KotlinNativeHomeEvaluator.getKotlinNativeHome(project) ?: NO_KOTLIN_NATIVE_HOME
|
||||||
return KotlinMPPGradleModelImpl(sourceSetMap, targets, ExtraFeaturesImpl(coroutinesState), kotlinNativeHome)
|
return KotlinMPPGradleModelImpl(sourceSetMap, targets, ExtraFeaturesImpl(coroutinesState, isHMPPEnabled(project)), kotlinNativeHome)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isHMPPEnabled(project: Project): Boolean {
|
private fun isHMPPEnabled(project: Project): Boolean {
|
||||||
|
|||||||
@@ -147,7 +147,8 @@ data class KotlinTargetImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
data class ExtraFeaturesImpl(
|
data class ExtraFeaturesImpl(
|
||||||
override val coroutinesState: String?
|
override val coroutinesState: String?,
|
||||||
|
override val isHMPPEnabled: Boolean
|
||||||
) : ExtraFeatures
|
) : ExtraFeatures
|
||||||
|
|
||||||
data class KotlinMPPGradleModelImpl(
|
data class KotlinMPPGradleModelImpl(
|
||||||
@@ -169,7 +170,7 @@ data class KotlinMPPGradleModelImpl(
|
|||||||
cloningCache[initialTarget] = it
|
cloningCache[initialTarget] = it
|
||||||
}
|
}
|
||||||
}.toList(),
|
}.toList(),
|
||||||
ExtraFeaturesImpl(mppModel.extraFeatures.coroutinesState),
|
ExtraFeaturesImpl(mppModel.extraFeatures.coroutinesState, mppModel.extraFeatures.isHMPPEnabled),
|
||||||
mppModel.kotlinNativeHome
|
mppModel.kotlinNativeHome
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class KotlinFacetEditorGeneralTab(
|
|||||||
lateinit var useProjectSettingsCheckBox: ThreeStateCheckBox
|
lateinit var useProjectSettingsCheckBox: ThreeStateCheckBox
|
||||||
|
|
||||||
lateinit var platformToCheckbox: Map<SimplePlatform, ThreeStateCheckBox>
|
lateinit var platformToCheckbox: Map<SimplePlatform, ThreeStateCheckBox>
|
||||||
|
lateinit var hmppCheckbox: ThreeStateCheckBox
|
||||||
|
|
||||||
private lateinit var projectSettingsLink: HoverHyperlinkLabel
|
private lateinit var projectSettingsLink: HoverHyperlinkLabel
|
||||||
|
|
||||||
@@ -111,12 +112,16 @@ class KotlinFacetEditorGeneralTab(
|
|||||||
targetPlatformsPanel.add(it)
|
targetPlatformsPanel.add(it)
|
||||||
it.isEnabled = true //TODO(auskov): think about enabling/disabling editing facet settings
|
it.isEnabled = true //TODO(auskov): think about enabling/disabling editing facet settings
|
||||||
}
|
}
|
||||||
|
hmppCheckbox = ThreeStateCheckBox().apply {
|
||||||
|
this.isEnabled = false
|
||||||
|
}
|
||||||
val contentPanel = FormBuilder
|
val contentPanel = FormBuilder
|
||||||
.createFormBuilder()
|
.createFormBuilder()
|
||||||
.addComponent(JPanel(BorderLayout()).apply {
|
.addComponent(JPanel(BorderLayout()).apply {
|
||||||
add(useProjectSettingsCheckBox, BorderLayout.WEST)
|
add(useProjectSettingsCheckBox, BorderLayout.WEST)
|
||||||
add(projectSettingsLink, BorderLayout.EAST)
|
add(projectSettingsLink, BorderLayout.EAST)
|
||||||
}).addLabeledComponent("Selected target platforms:", targetPlatformsPanel)
|
}).addLabeledComponent("Selected target platforms:", targetPlatformsPanel)
|
||||||
|
.addLabeledComponent("HMPP enabled:", hmppCheckbox)
|
||||||
.addComponent(compilerConfigurable.createComponent()!!.apply {
|
.addComponent(compilerConfigurable.createComponent()!!.apply {
|
||||||
border = null
|
border = null
|
||||||
})
|
})
|
||||||
@@ -307,6 +312,7 @@ class KotlinFacetEditorGeneralTab(
|
|||||||
editor.platformToCheckbox.forEach {
|
editor.platformToCheckbox.forEach {
|
||||||
it.value.isSelected = configuration.settings.targetPlatform?.contains(it.key) ?: false
|
it.value.isSelected = configuration.settings.targetPlatform?.contains(it.key) ?: false
|
||||||
}
|
}
|
||||||
|
editor.hmppCheckbox.isSelected = configuration.settings.isHmppEnabled
|
||||||
editor.compilerConfigurable.reset()
|
editor.compilerConfigurable.reset()
|
||||||
editor.updateCompilerConfigurable()
|
editor.updateCompilerConfigurable()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,13 +148,15 @@ fun KotlinFacet.configureFacet(
|
|||||||
compilerVersion: String?,
|
compilerVersion: String?,
|
||||||
coroutineSupport: LanguageFeature.State,
|
coroutineSupport: LanguageFeature.State,
|
||||||
platform: TargetPlatform?, // if null, detect by module dependencies
|
platform: TargetPlatform?, // if null, detect by module dependencies
|
||||||
modelsProvider: IdeModifiableModelsProvider
|
modelsProvider: IdeModifiableModelsProvider,
|
||||||
|
hmppEnabled: Boolean
|
||||||
) {
|
) {
|
||||||
val module = module
|
val module = module
|
||||||
with(configuration.settings) {
|
with(configuration.settings) {
|
||||||
compilerArguments = null
|
compilerArguments = null
|
||||||
targetPlatform = null
|
targetPlatform = null
|
||||||
compilerSettings = null
|
compilerSettings = null
|
||||||
|
isHmppEnabled = hmppEnabled
|
||||||
initializeIfNeeded(
|
initializeIfNeeded(
|
||||||
module,
|
module,
|
||||||
modelsProvider.getModifiableRootModel(module),
|
modelsProvider.getModifiableRootModel(module),
|
||||||
@@ -183,7 +185,7 @@ fun KotlinFacet.configureFacet(
|
|||||||
platform: IdePlatform<*, *>,
|
platform: IdePlatform<*, *>,
|
||||||
modelsProvider: IdeModifiableModelsProvider
|
modelsProvider: IdeModifiableModelsProvider
|
||||||
) {
|
) {
|
||||||
configureFacet(compilerVersion, coroutineSupport, platform.toNewPlatform(), modelsProvider)
|
configureFacet(compilerVersion, coroutineSupport, platform.toNewPlatform(), modelsProvider, false) //TODO(auskov): passed isHmpp = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -762,7 +762,7 @@ class KtLightAnnotationTest : KotlinLightCodeInsightFixtureTestCase() {
|
|||||||
WriteAction.run<Throwable> {
|
WriteAction.run<Throwable> {
|
||||||
val modelsProvider = IdeModifiableModelsProviderImpl(project)
|
val modelsProvider = IdeModifiableModelsProviderImpl(project)
|
||||||
val facet = module.getOrCreateFacet(modelsProvider, useProjectSettings = false)
|
val facet = module.getOrCreateFacet(modelsProvider, useProjectSettings = false)
|
||||||
facet.configureFacet(version, LanguageFeature.State.DISABLED, null, modelsProvider)
|
facet.configureFacet(version, LanguageFeature.State.DISABLED, null, modelsProvider, false)
|
||||||
modelsProvider.commit()
|
modelsProvider.commit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -350,7 +350,8 @@ public class ConfigureKotlinTest extends AbstractConfigureKotlinTest {
|
|||||||
"1.1",
|
"1.1",
|
||||||
LanguageFeature.State.ENABLED,
|
LanguageFeature.State.ENABLED,
|
||||||
platform,
|
platform,
|
||||||
modelsProvider
|
modelsProvider,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
assertEquals(platform, facet.getConfiguration().getSettings().getTargetPlatform());
|
assertEquals(platform, facet.getConfiguration().getSettings().getTargetPlatform());
|
||||||
assertEquals(jvmTarget.getDescription(),
|
assertEquals(jvmTarget.getDescription(),
|
||||||
|
|||||||
Reference in New Issue
Block a user