K2: introduce "no source files" CLI check
This commit is contained in:
committed by
Space Team
parent
b821009617
commit
9bff7e3045
@@ -26,7 +26,9 @@ data class GroupedKtSources(
|
|||||||
val platformSources: Collection<KtSourceFile>,
|
val platformSources: Collection<KtSourceFile>,
|
||||||
val commonSources: Collection<KtSourceFile>,
|
val commonSources: Collection<KtSourceFile>,
|
||||||
val sourcesByModuleName: Map<String, Set<KtSourceFile>>,
|
val sourcesByModuleName: Map<String, Set<KtSourceFile>>,
|
||||||
)
|
) {
|
||||||
|
fun isEmpty(): Boolean = platformSources.isEmpty() && commonSources.isEmpty()
|
||||||
|
}
|
||||||
|
|
||||||
fun collectSources(
|
fun collectSources(
|
||||||
compilerConfiguration: CompilerConfiguration,
|
compilerConfiguration: CompilerConfiguration,
|
||||||
|
|||||||
@@ -142,13 +142,15 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
|||||||
val targetDescription = chunk.map { input -> input.getModuleName() + "-" + input.getModuleType() }.let { names ->
|
val targetDescription = chunk.map { input -> input.getModuleName() + "-" + input.getModuleType() }.let { names ->
|
||||||
names.singleOrNull() ?: names.joinToString()
|
names.singleOrNull() ?: names.joinToString()
|
||||||
}
|
}
|
||||||
if (configuration.getBoolean(CommonConfigurationKeys.USE_FIR) && configuration.getBoolean(CommonConfigurationKeys.USE_LIGHT_TREE)) {
|
if (configuration.getBoolean(CommonConfigurationKeys.USE_FIR) && configuration.getBoolean(CommonConfigurationKeys.USE_LIGHT_TREE)) {
|
||||||
|
if (messageCollector.hasErrors()) return COMPILATION_ERROR
|
||||||
val projectEnvironment =
|
val projectEnvironment =
|
||||||
createProjectEnvironment(configuration, rootDisposable, EnvironmentConfigFiles.JVM_CONFIG_FILES, messageCollector)
|
createProjectEnvironment(configuration, rootDisposable, EnvironmentConfigFiles.JVM_CONFIG_FILES, messageCollector)
|
||||||
if (messageCollector.hasErrors()) return COMPILATION_ERROR
|
if (messageCollector.hasErrors()) return COMPILATION_ERROR
|
||||||
|
|
||||||
compileModulesUsingFrontendIrAndLightTree(
|
compileModulesUsingFrontendIrAndLightTree(
|
||||||
projectEnvironment, configuration, messageCollector, buildFile, chunk, targetDescription
|
projectEnvironment, configuration, messageCollector, buildFile, chunk, targetDescription,
|
||||||
|
checkSourceFiles = !arguments.allowNoSourceFiles && !arguments.version
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
val environment = createCoreEnvironment(
|
val environment = createCoreEnvironment(
|
||||||
|
|||||||
+10
-1
@@ -79,7 +79,8 @@ fun compileModulesUsingFrontendIrAndLightTree(
|
|||||||
messageCollector: MessageCollector,
|
messageCollector: MessageCollector,
|
||||||
buildFile: File?,
|
buildFile: File?,
|
||||||
chunk: List<Module>,
|
chunk: List<Module>,
|
||||||
targetDescription: String
|
targetDescription: String,
|
||||||
|
checkSourceFiles: Boolean
|
||||||
): Boolean {
|
): Boolean {
|
||||||
require(projectEnvironment is VfsBasedProjectEnvironment) // TODO: abstract away this requirement
|
require(projectEnvironment is VfsBasedProjectEnvironment) // TODO: abstract away this requirement
|
||||||
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
|
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
|
||||||
@@ -99,6 +100,14 @@ fun compileModulesUsingFrontendIrAndLightTree(
|
|||||||
put(JVMConfigurationKeys.FRIEND_PATHS, module.getFriendPaths())
|
put(JVMConfigurationKeys.FRIEND_PATHS, module.getFriendPaths())
|
||||||
}
|
}
|
||||||
val groupedSources = collectSources(compilerConfiguration, projectEnvironment, messageCollector)
|
val groupedSources = collectSources(compilerConfiguration, projectEnvironment, messageCollector)
|
||||||
|
if (messageCollector.hasErrors()) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkSourceFiles && groupedSources.isEmpty() && buildFile == null) {
|
||||||
|
messageCollector.report(CompilerMessageSeverity.ERROR, "No source files")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
val compilerInput = ModuleCompilerInput(
|
val compilerInput = ModuleCompilerInput(
|
||||||
TargetId(module),
|
TargetId(module),
|
||||||
|
|||||||
Reference in New Issue
Block a user