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 commonSources: Collection<KtSourceFile>,
|
||||
val sourcesByModuleName: Map<String, Set<KtSourceFile>>,
|
||||
)
|
||||
) {
|
||||
fun isEmpty(): Boolean = platformSources.isEmpty() && commonSources.isEmpty()
|
||||
}
|
||||
|
||||
fun collectSources(
|
||||
compilerConfiguration: CompilerConfiguration,
|
||||
|
||||
@@ -142,13 +142,15 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
||||
val targetDescription = chunk.map { input -> input.getModuleName() + "-" + input.getModuleType() }.let { names ->
|
||||
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 =
|
||||
createProjectEnvironment(configuration, rootDisposable, EnvironmentConfigFiles.JVM_CONFIG_FILES, messageCollector)
|
||||
if (messageCollector.hasErrors()) return COMPILATION_ERROR
|
||||
|
||||
compileModulesUsingFrontendIrAndLightTree(
|
||||
projectEnvironment, configuration, messageCollector, buildFile, chunk, targetDescription
|
||||
projectEnvironment, configuration, messageCollector, buildFile, chunk, targetDescription,
|
||||
checkSourceFiles = !arguments.allowNoSourceFiles && !arguments.version
|
||||
)
|
||||
} else {
|
||||
val environment = createCoreEnvironment(
|
||||
|
||||
+10
-1
@@ -79,7 +79,8 @@ fun compileModulesUsingFrontendIrAndLightTree(
|
||||
messageCollector: MessageCollector,
|
||||
buildFile: File?,
|
||||
chunk: List<Module>,
|
||||
targetDescription: String
|
||||
targetDescription: String,
|
||||
checkSourceFiles: Boolean
|
||||
): Boolean {
|
||||
require(projectEnvironment is VfsBasedProjectEnvironment) // TODO: abstract away this requirement
|
||||
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
|
||||
@@ -99,6 +100,14 @@ fun compileModulesUsingFrontendIrAndLightTree(
|
||||
put(JVMConfigurationKeys.FRIEND_PATHS, module.getFriendPaths())
|
||||
}
|
||||
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(
|
||||
TargetId(module),
|
||||
|
||||
Reference in New Issue
Block a user