Introduce -Xcommon-sources and pass it correctly from build tool plugins

#KT-25196 In Progress
This commit is contained in:
Alexander Udalov
2018-07-27 14:15:12 +02:00
parent d35e73d29b
commit 0f003802fe
28 changed files with 205 additions and 126 deletions
@@ -180,6 +180,14 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
)
var metadataVersion: String? by FreezableVar(null)
@Argument(
value = "-Xcommon-sources",
valueDescription = "<path>",
description = "Sources of the common module that need to be compiled together with this module in the multi-platform mode.\n" +
"Should be a subset of sources passed as free arguments"
)
var commonSources: Array<String>? by FreezableVar(null)
open fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
return HashMap<AnalysisFlag<*>, Any>().apply {
put(AnalysisFlag.skipMetadataVersionCheck, skipMetadataVersionCheck)
@@ -21,11 +21,12 @@ import org.jetbrains.kotlin.modules.Module
import java.util.*
class ModuleBuilder(
private val name: String,
private val outputDir: String,
private val type: String
private val name: String,
private val outputDir: String,
private val type: String
) : Module {
private val sourceFiles = ArrayList<String>()
private val commonSourceFiles = ArrayList<String>()
private val classpathRoots = ArrayList<String>()
private val javaSourceRoots = ArrayList<JavaRootPath>()
private val friendDirs = ArrayList<String>()
@@ -35,6 +36,10 @@ class ModuleBuilder(
sourceFiles.add(path)
}
fun addCommonSourceFiles(path: String) {
commonSourceFiles.add(path)
}
fun addClasspathEntry(path: String) {
classpathRoots.add(path)
}
@@ -51,6 +56,7 @@ class ModuleBuilder(
override fun getFriendPaths(): List<String> = friendDirs
override fun getJavaSourceRoots(): List<JavaRootPath> = javaSourceRoots
override fun getSourceFiles(): List<String> = sourceFiles
override fun getCommonSourceFiles(): List<String> = commonSourceFiles
override fun getClasspathRoots(): List<String> = classpathRoots
override fun getModuleName(): String = name
override fun getModuleType(): String = type
@@ -47,6 +47,7 @@ public class ModuleXmlParser {
public static final String OUTPUT_DIR = "outputDir";
public static final String FRIEND_DIR = "friendDir";
public static final String SOURCES = "sources";
public static final String COMMON_SOURCES = "commonSources";
public static final String JAVA_SOURCE_ROOTS = "javaSourceRoots";
public static final String JAVA_SOURCE_PACKAGE_PREFIX = "packagePrefix";
public static final String PATH = "path";
@@ -159,6 +160,10 @@ public class ModuleXmlParser {
String path = getAttribute(attributes, PATH, qName);
moduleBuilder.addSourceFiles(path);
}
else if (COMMON_SOURCES.equalsIgnoreCase(qName)) {
String path = getAttribute(attributes, PATH, qName);
moduleBuilder.addCommonSourceFiles(path);
}
else if (FRIEND_DIR.equalsIgnoreCase(qName)) {
String path = getAttribute(attributes, PATH, qName);
moduleBuilder.addFriendDir(path);