Got rid of ModuleChunk (it makes no sense now).
This commit is contained in:
@@ -230,10 +230,10 @@ public class BytecodeCompiler {
|
|||||||
@Nullable String[] externalAnnotationsPath, boolean enableInline
|
@Nullable String[] externalAnnotationsPath, boolean enableInline
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
ModuleChunk modules = CompileEnvironmentUtil.loadModuleDescriptions(getKotlinPathsForAntTask(), module,
|
List<Module> modules = CompileEnvironmentUtil.loadModuleDescriptions(getKotlinPathsForAntTask(), module,
|
||||||
MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR);
|
MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR);
|
||||||
List<String> sourcesRoots = new ArrayList<String>();
|
List<String> sourcesRoots = new ArrayList<String>();
|
||||||
for (Module m : modules.getModules()) {
|
for (Module m : modules) {
|
||||||
sourcesRoots.addAll(m.getSourceFiles());
|
sourcesRoots.addAll(m.getSourceFiles());
|
||||||
}
|
}
|
||||||
CompilerConfiguration configuration = createConfiguration(stdlib, classpath, externalAnnotationsPath, sourcesRoots.toArray(new String[0]),
|
CompilerConfiguration configuration = createConfiguration(stdlib, classpath, externalAnnotationsPath, sourcesRoots.toArray(new String[0]),
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.google.common.base.Splitter;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.intellij.openapi.Disposable;
|
import com.intellij.openapi.Disposable;
|
||||||
import com.intellij.openapi.util.text.StringUtil;
|
import com.intellij.openapi.util.text.StringUtil;
|
||||||
|
import kotlin.modules.Module;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.cli.common.CLICompiler;
|
import org.jetbrains.jet.cli.common.CLICompiler;
|
||||||
import org.jetbrains.jet.cli.common.CLIConfigurationKeys;
|
import org.jetbrains.jet.cli.common.CLIConfigurationKeys;
|
||||||
@@ -124,7 +125,7 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
|
|||||||
|
|
||||||
if (arguments.module != null) {
|
if (arguments.module != null) {
|
||||||
MessageCollector sanitizedCollector = new FilteringMessageCollector(messageCollector, in(CompilerMessageSeverity.VERBOSE));
|
MessageCollector sanitizedCollector = new FilteringMessageCollector(messageCollector, in(CompilerMessageSeverity.VERBOSE));
|
||||||
ModuleChunk modules = CompileEnvironmentUtil.loadModuleDescriptions(paths, arguments.module, sanitizedCollector);
|
List<Module> modules = CompileEnvironmentUtil.loadModuleDescriptions(paths, arguments.module, sanitizedCollector);
|
||||||
|
|
||||||
if (outputDir != null) {
|
if (outputDir != null) {
|
||||||
messageCollector.report(CompilerMessageSeverity.WARNING, "The '-output' option is ignored because '-module' is specified",
|
messageCollector.report(CompilerMessageSeverity.WARNING, "The '-output' option is ignored because '-module' is specified",
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2014 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.jet.cli.jvm.compiler
|
|
||||||
|
|
||||||
import kotlin.modules.Module
|
|
||||||
|
|
||||||
class ChunkAsOneModule(private val chunk: ModuleChunk) : Module {
|
|
||||||
fun getModules(): List<Module> {
|
|
||||||
return chunk.getModules()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getModuleName(): String = "chunk" + getModules().map { it.getModuleName() }.toString()
|
|
||||||
|
|
||||||
override fun getOutputDirectory(): String {
|
|
||||||
throw UnsupportedOperationException("Each module in a chunk has its own output directory")
|
|
||||||
}
|
|
||||||
override fun getSourceFiles(): List<String> = chunk.getModules().flatMap { it.getSourceFiles() }
|
|
||||||
|
|
||||||
override fun getClasspathRoots(): List<String> = chunk.getModules().flatMap { it.getClasspathRoots() }
|
|
||||||
|
|
||||||
override fun getAnnotationsRoots(): List<String> = chunk.getModules().flatMap { it.getAnnotationsRoots() }
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -51,6 +51,7 @@ import java.net.MalformedURLException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.jar.*;
|
import java.util.jar.*;
|
||||||
|
|
||||||
@@ -66,28 +67,28 @@ public class CompileEnvironmentUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static ModuleChunk loadModuleDescriptions(KotlinPaths paths, String moduleDefinitionFile, MessageCollector messageCollector) {
|
public static List<Module> loadModuleDescriptions(KotlinPaths paths, String moduleDefinitionFile, MessageCollector messageCollector) {
|
||||||
File file = new File(moduleDefinitionFile);
|
File file = new File(moduleDefinitionFile);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
messageCollector.report(ERROR, "Module definition file does not exist: " + moduleDefinitionFile, NO_LOCATION);
|
messageCollector.report(ERROR, "Module definition file does not exist: " + moduleDefinitionFile, NO_LOCATION);
|
||||||
return ModuleChunk.EMPTY;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
String extension = FileUtilRt.getExtension(moduleDefinitionFile);
|
String extension = FileUtilRt.getExtension(moduleDefinitionFile);
|
||||||
if ("ktm".equalsIgnoreCase(extension)) {
|
if ("ktm".equalsIgnoreCase(extension)) {
|
||||||
return new ModuleChunk(loadModuleScript(paths, moduleDefinitionFile, messageCollector));
|
return loadModuleScript(paths, moduleDefinitionFile, messageCollector);
|
||||||
}
|
}
|
||||||
if ("xml".equalsIgnoreCase(extension)) {
|
if ("xml".equalsIgnoreCase(extension)) {
|
||||||
return new ModuleChunk(ContainerUtil.map(
|
return ContainerUtil.map(
|
||||||
ModuleXmlParser.parse(moduleDefinitionFile, messageCollector),
|
ModuleXmlParser.parse(moduleDefinitionFile, messageCollector),
|
||||||
new Function<ModuleDescription, Module>() {
|
new Function<ModuleDescription, Module>() {
|
||||||
@Override
|
@Override
|
||||||
public Module fun(ModuleDescription description) {
|
public Module fun(ModuleDescription description) {
|
||||||
return new DescriptionToModuleAdapter(description);
|
return new DescriptionToModuleAdapter(description);
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
messageCollector.report(ERROR, "Unknown module definition type: " + moduleDefinitionFile, NO_LOCATION);
|
messageCollector.report(ERROR, "Unknown module definition type: " + moduleDefinitionFile, NO_LOCATION);
|
||||||
return ModuleChunk.EMPTY;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
+3
-5
@@ -153,18 +153,16 @@ public class KotlinToJVMBytecodeCompiler {
|
|||||||
|
|
||||||
public static boolean compileModules(
|
public static boolean compileModules(
|
||||||
@NotNull CompilerConfiguration configuration,
|
@NotNull CompilerConfiguration configuration,
|
||||||
@NotNull ModuleChunk chunk,
|
@NotNull List<Module> chunk,
|
||||||
@NotNull File directory,
|
@NotNull File directory,
|
||||||
@Nullable File jarPath,
|
@Nullable File jarPath,
|
||||||
boolean jarRuntime
|
boolean jarRuntime
|
||||||
) {
|
) {
|
||||||
List<Module> modules = chunk.getModules();
|
Map<Module, ClassFileFactory> outputFiles = compileModule(configuration, chunk, directory);
|
||||||
|
|
||||||
Map<Module, ClassFileFactory> outputFiles = compileModule(configuration, modules, directory);
|
|
||||||
if (outputFiles == null) {
|
if (outputFiles == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (Module module : modules) {
|
for (Module module : chunk) {
|
||||||
writeOutput(configuration, outputFiles.get(module), new File(module.getOutputDirectory()), jarPath, jarRuntime, null);
|
writeOutput(configuration, outputFiles.get(module), new File(module.getOutputDirectory()), jarPath, jarRuntime, null);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2013 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.jet.cli.jvm.compiler;
|
|
||||||
|
|
||||||
import kotlin.modules.Module;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ModuleChunk {
|
|
||||||
|
|
||||||
public static final ModuleChunk EMPTY = new ModuleChunk(Collections.<Module>emptyList());
|
|
||||||
|
|
||||||
private final List<Module> modules;
|
|
||||||
|
|
||||||
public ModuleChunk(@NotNull List<Module> modules) {
|
|
||||||
this.modules = modules;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public List<Module> getModules() {
|
|
||||||
return modules;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user