JPS, native: skip and report native modules as not supported
#KT-26648 Fixed
Original commit: 9e6d6ad9da
This commit is contained in:
+9
@@ -552,6 +552,7 @@ abstract class AbstractIncrementalJpsTest(
|
||||
private class MyLogger(val rootPath: String) : ProjectBuilderLoggerBase(), TestingBuildLogger {
|
||||
private val markedDirtyBeforeRound = ArrayList<File>()
|
||||
private val markedDirtyAfterRound = ArrayList<File>()
|
||||
private val customMessages = mutableListOf<String>()
|
||||
|
||||
override fun invalidOrUnusedCache(
|
||||
chunk: KotlinChunk?,
|
||||
@@ -588,7 +589,15 @@ abstract class AbstractIncrementalJpsTest(
|
||||
logDirtyFiles(markedDirtyBeforeRound)
|
||||
}
|
||||
|
||||
override fun addCustomMessage(message: String) {
|
||||
customMessages.add(message)
|
||||
}
|
||||
|
||||
override fun buildFinished(exitCode: ModuleLevelBuilder.ExitCode) {
|
||||
customMessages.forEach {
|
||||
logLine(it)
|
||||
}
|
||||
customMessages.clear()
|
||||
logDirtyFiles(markedDirtyAfterRound)
|
||||
logLine("Exit code: $exitCode")
|
||||
logLine("------------------------------------------")
|
||||
|
||||
@@ -1001,6 +1001,7 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
||||
target: KotlinModuleBuildTarget<*>?,
|
||||
attributesDiff: CacheAttributesDiff<*>
|
||||
) {}
|
||||
override fun addCustomMessage(message: String) {}
|
||||
override fun buildFinished(exitCode: ModuleLevelBuilder.ExitCode) {}
|
||||
override fun markedAsDirtyBeforeRound(files: Iterable<File>) {}
|
||||
override fun markedAsDirtyAfterRound(files: Iterable<File>) {}
|
||||
|
||||
+31
@@ -29,6 +29,37 @@ public class MultiplatformJpsTestWithGeneratedContentGenerated extends AbstractM
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class IgnoreAndWarnAboutNative extends AbstractMultiplatformJpsTestWithGeneratedContent {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInIgnoreAndWarnAboutNative() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("editingCKotlin")
|
||||
public void testEditingCKotlin() throws Exception {
|
||||
runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative/editingCKotlin/");
|
||||
}
|
||||
|
||||
@TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative/editingCKotlin")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class EditingCKotlin extends AbstractMultiplatformJpsTestWithGeneratedContent {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInEditingCKotlin() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative/editingCKotlin"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simple")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+14
-8
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.config.KotlinFacetSettings
|
||||
import org.jetbrains.kotlin.config.KotlinModuleKind.COMPILATION_AND_SOURCE_SET_HOLDER
|
||||
import org.jetbrains.kotlin.config.KotlinModuleKind.SOURCE_SET_HOLDER
|
||||
import org.jetbrains.kotlin.jps.build.dependeciestxt.ModulesTxt.Dependency.Kind.*
|
||||
import org.jetbrains.kotlin.platform.impl.FakeK2NativeCompilerArguments
|
||||
import org.jetbrains.kotlin.platform.impl.isCommon
|
||||
import org.jetbrains.kotlin.platform.impl.isJvm
|
||||
import java.io.File
|
||||
@@ -168,15 +169,19 @@ class ModulesTxtBuilder {
|
||||
}
|
||||
|
||||
fun readFile(file: File, fileTitle: String = file.toString()): ModulesTxt {
|
||||
file.forEachLine { line ->
|
||||
parseDeclaration(line)
|
||||
try {
|
||||
file.forEachLine { line ->
|
||||
parseDeclaration(line)
|
||||
}
|
||||
|
||||
// dependencies need to be build first: module.build() requires it
|
||||
val dependencies = dependencies.map { it.build() }
|
||||
val modules = modules.values.mapIndexed { index, moduleRef -> moduleRef.build(index) }
|
||||
|
||||
return ModulesTxt(muted, file, fileTitle, modules, dependencies)
|
||||
} catch (t: Throwable) {
|
||||
throw Error("Error while reading $file: ${t.message}", t)
|
||||
}
|
||||
|
||||
// dependencies need to be build first: module.build() requires it
|
||||
val dependencies = dependencies.map { it.build() }
|
||||
val modules = modules.values.mapIndexed { index, moduleRef -> moduleRef.build(index) }
|
||||
|
||||
return ModulesTxt(muted, file, fileTitle, modules, dependencies)
|
||||
}
|
||||
|
||||
private fun parseDeclaration(line: String) = doParseDeclaration(removeComments(line))
|
||||
@@ -251,6 +256,7 @@ class ModulesTxtBuilder {
|
||||
"common" -> settings.compilerArguments = K2MetadataCompilerArguments()
|
||||
"jvm" -> settings.compilerArguments = K2JVMCompilerArguments()
|
||||
"js" -> settings.compilerArguments = K2JSCompilerArguments()
|
||||
"native" -> settings.compilerArguments = FakeK2NativeCompilerArguments()
|
||||
else -> {
|
||||
val flagProperty = ModulesTxt.Module.flags[flag]
|
||||
if (flagProperty != null) flagProperty.set(module, true)
|
||||
|
||||
@@ -31,11 +31,12 @@ import org.jetbrains.jps.model.JpsProject
|
||||
import org.jetbrains.kotlin.build.GeneratedFile
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.ERROR
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.INFO
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollectorUtil
|
||||
import org.jetbrains.kotlin.compilerRunner.*
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||
import org.jetbrains.kotlin.config.KotlinModuleKind
|
||||
import org.jetbrains.kotlin.config.Services
|
||||
import org.jetbrains.kotlin.daemon.common.isDaemonEnabled
|
||||
import org.jetbrains.kotlin.incremental.*
|
||||
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
|
||||
@@ -45,6 +46,7 @@ import org.jetbrains.kotlin.jps.incremental.withLookupStorage
|
||||
import org.jetbrains.kotlin.jps.model.kotlinKind
|
||||
import org.jetbrains.kotlin.jps.targets.KotlinJvmModuleBuildTarget
|
||||
import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget
|
||||
import org.jetbrains.kotlin.jps.targets.KotlinUnsupportedModuleBuildTarget
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.preloading.ClassCondition
|
||||
import org.jetbrains.kotlin.utils.KotlinPaths
|
||||
@@ -327,13 +329,23 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
||||
return NOTHING_DONE
|
||||
}
|
||||
|
||||
val kotlinContext = context.kotlin
|
||||
val kotlinChunk = chunk.toKotlinChunk(context)!!
|
||||
|
||||
if (representativeTarget is KotlinUnsupportedModuleBuildTarget) {
|
||||
val msg = "${representativeTarget.kind} is not yet supported in IDEA internal build system. " +
|
||||
"Please use Gradle to build ${kotlinChunk.presentableShortName}."
|
||||
|
||||
kotlinContext.testingLogger?.addCustomMessage(msg)
|
||||
messageCollector.report(STRONG_WARNING, msg)
|
||||
|
||||
return NOTHING_DONE
|
||||
}
|
||||
|
||||
if (!kotlinChunk.isEnabled) {
|
||||
return NOTHING_DONE
|
||||
}
|
||||
|
||||
val kotlinContext = context.kotlin
|
||||
val projectDescriptor = context.projectDescriptor
|
||||
val dataManager = projectDescriptor.dataManager
|
||||
val targets = chunk.targets
|
||||
|
||||
@@ -29,6 +29,7 @@ interface TestingBuildLogger {
|
||||
fun invalidOrUnusedCache(chunk: KotlinChunk?, target: KotlinModuleBuildTarget<*>?, attributesDiff: CacheAttributesDiff<*>)
|
||||
fun chunkBuildStarted(context: CompileContext, chunk: org.jetbrains.jps.ModuleChunk)
|
||||
fun afterChunkBuildStarted(context: CompileContext, chunk: org.jetbrains.jps.ModuleChunk)
|
||||
fun addCustomMessage(message: String)
|
||||
fun buildFinished(exitCode: ModuleLevelBuilder.ExitCode)
|
||||
fun markedAsDirtyBeforeRound(files: Iterable<File>)
|
||||
fun markedAsDirtyAfterRound(files: Iterable<File>)
|
||||
|
||||
@@ -41,7 +41,7 @@ internal class KotlinTargetsIndexBuilder internal constructor(
|
||||
// visit all kotlin build targets
|
||||
jpsContext.projectDescriptor.buildTargetIndex.getSortedTargetChunks(jpsContext).forEach { chunk ->
|
||||
val moduleBuildTargets = chunk.targets.mapNotNull {
|
||||
if (it is ModuleBuildTarget) ensureLoaded(it)!!
|
||||
if (it is ModuleBuildTarget) ensureLoaded(it)
|
||||
else null
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ internal class KotlinTargetsIndexBuilder internal constructor(
|
||||
}
|
||||
|
||||
|
||||
private fun ensureLoaded(target: ModuleBuildTarget): KotlinModuleBuildTarget<*>? {
|
||||
private fun ensureLoaded(target: ModuleBuildTarget): KotlinModuleBuildTarget<*> {
|
||||
return byJpsModuleBuildTarget.computeIfAbsent(target) {
|
||||
val platform = target.module.platform?.kind ?: detectTargetPlatform(target)
|
||||
|
||||
@@ -140,7 +140,7 @@ internal class KotlinTargetsIndexBuilder internal constructor(
|
||||
platform.isCommon -> KotlinCommonModuleBuildTarget(uninitializedContext, target)
|
||||
platform.isJavaScript -> KotlinJsModuleBuildTarget(uninitializedContext, target)
|
||||
platform.isJvm -> KotlinJvmModuleBuildTarget(uninitializedContext, target)
|
||||
else -> error("Unsupported platform $platform")
|
||||
else -> KotlinUnsupportedModuleBuildTarget(uninitializedContext, target)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.jps.targets
|
||||
|
||||
import org.jetbrains.jps.builders.storage.BuildDataPaths
|
||||
import org.jetbrains.jps.incremental.ModuleBuildTarget
|
||||
import org.jetbrains.kotlin.build.BuildMetaInfo
|
||||
import org.jetbrains.kotlin.build.BuildMetaInfoFactory
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
|
||||
import org.jetbrains.kotlin.jps.build.KotlinCompileContext
|
||||
import org.jetbrains.kotlin.jps.build.KotlinDirtySourceFilesHolder
|
||||
import org.jetbrains.kotlin.jps.incremental.JpsIncrementalCache
|
||||
import org.jetbrains.kotlin.jps.model.platform
|
||||
|
||||
class KotlinUnsupportedModuleBuildTarget(
|
||||
kotlinContext: KotlinCompileContext,
|
||||
jpsModuleBuildTarget: ModuleBuildTarget
|
||||
) : KotlinModuleBuildTarget<BuildMetaInfo>(kotlinContext, jpsModuleBuildTarget) {
|
||||
val kind = module.platform?.kind?.name
|
||||
|
||||
private fun shouldNotBeCalled(): Nothing = error("Should not be called")
|
||||
|
||||
override fun isEnabled(chunkCompilerArguments: CommonCompilerArguments): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override val isIncrementalCompilationEnabled: Boolean
|
||||
get() = false
|
||||
|
||||
override val hasCaches: Boolean
|
||||
get() = false
|
||||
|
||||
override val globalLookupCacheId: String
|
||||
get() = shouldNotBeCalled()
|
||||
|
||||
override fun compileModuleChunk(
|
||||
commonArguments: CommonCompilerArguments,
|
||||
dirtyFilesHolder: KotlinDirtySourceFilesHolder,
|
||||
environment: JpsCompilerEnvironment
|
||||
): Boolean {
|
||||
shouldNotBeCalled()
|
||||
}
|
||||
|
||||
override fun createCacheStorage(paths: BuildDataPaths): JpsIncrementalCache {
|
||||
shouldNotBeCalled()
|
||||
}
|
||||
|
||||
override val buildMetaInfoFactory: BuildMetaInfoFactory<BuildMetaInfo>
|
||||
get() = shouldNotBeCalled()
|
||||
|
||||
override val buildMetaInfoFileName: String
|
||||
get() = shouldNotBeCalled()
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
c [sourceSetHolder, edit]
|
||||
|
||||
pJvm [compilationAndSourceSetHolder, jvm]
|
||||
pJvm -> c [include]
|
||||
|
||||
pJs [compilationAndSourceSetHolder, js]
|
||||
pJs -> c [include]
|
||||
|
||||
pNative [compilationAndSourceSetHolder, native]
|
||||
pNative -> c [include]
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
================ Step #1 create new service =================
|
||||
|
||||
Building c
|
||||
Building pNative
|
||||
Native is not yet supported in IDEA internal build system. Please use Gradle to build pNative.
|
||||
Exit code: NOTHING_DONE
|
||||
------------------------------------------
|
||||
Building pJs
|
||||
Compiling files:
|
||||
c/src/serviceCNewHeader.kt
|
||||
End of files
|
||||
Exit code: OK
|
||||
------------------------------------------
|
||||
Building pJvm
|
||||
Compiling files:
|
||||
c/src/serviceCNewHeader.kt
|
||||
End of files
|
||||
Exit code: OK
|
||||
------------------------------------------
|
||||
|
||||
================ Step #2 edit new service =================
|
||||
|
||||
Building c
|
||||
Building pNative
|
||||
Native is not yet supported in IDEA internal build system. Please use Gradle to build pNative.
|
||||
Exit code: NOTHING_DONE
|
||||
------------------------------------------
|
||||
Building pJs
|
||||
Cleaning output files:
|
||||
out/production/pJs/pJs.js
|
||||
out/production/pJs/pJs.meta.js
|
||||
out/production/pJs/pJs/root-package.kjsm
|
||||
End of files
|
||||
Compiling files:
|
||||
c/src/serviceCNewHeader.kt
|
||||
End of files
|
||||
Exit code: OK
|
||||
------------------------------------------
|
||||
Building pJvm
|
||||
Cleaning output files:
|
||||
out/production/pJvm/META-INF/pJvm.kotlin_module
|
||||
out/production/pJvm/ServiceCNewHeaderKt.class
|
||||
End of files
|
||||
Compiling files:
|
||||
c/src/serviceCNewHeader.kt
|
||||
End of files
|
||||
Exit code: OK
|
||||
------------------------------------------
|
||||
|
||||
================ Step #3 delete new service =================
|
||||
|
||||
Building c
|
||||
Building pNative
|
||||
Native is not yet supported in IDEA internal build system. Please use Gradle to build pNative.
|
||||
Exit code: NOTHING_DONE
|
||||
------------------------------------------
|
||||
Cleaning output files:
|
||||
out/production/pJs/pJs.js
|
||||
out/production/pJs/pJs.meta.js
|
||||
out/production/pJs/pJs/root-package.kjsm
|
||||
End of files
|
||||
Building pJs
|
||||
Compiling files:
|
||||
End of files
|
||||
Exit code: OK
|
||||
------------------------------------------
|
||||
Cleaning output files:
|
||||
out/production/pJvm/META-INF/pJvm.kotlin_module
|
||||
out/production/pJvm/ServiceCNewHeaderKt.class
|
||||
End of files
|
||||
Building pJvm
|
||||
Compiling files:
|
||||
End of files
|
||||
Exit code: OK
|
||||
------------------------------------------
|
||||
Reference in New Issue
Block a user