Got rid of creating JetCoreEnvironment which wont be used when compiling modules from module script.
This commit is contained in:
@@ -93,7 +93,6 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
|
||||
}
|
||||
}
|
||||
|
||||
JetCoreEnvironment environment = JetCoreEnvironment.createCoreEnvironmentForJVM(rootDisposable, configuration);
|
||||
boolean builtins = arguments.builtins;
|
||||
|
||||
configuration.put(JVMConfigurationKeys.SCRIPT_PARAMETERS, arguments.script
|
||||
@@ -122,15 +121,17 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
|
||||
List<Module> modules = CompileEnvironmentUtil.loadModuleScript(arguments.module, messageCollector);
|
||||
messageCollector.setVerbose(oldVerbose);
|
||||
File directory = new File(arguments.module).getParentFile();
|
||||
noErrors = KotlinToJVMBytecodeCompiler.compileModules(environment, modules,
|
||||
noErrors = KotlinToJVMBytecodeCompiler.compileModules(configuration, modules,
|
||||
directory, jar, outputDir,
|
||||
arguments.includeRuntime);
|
||||
}
|
||||
else if (arguments.script) {
|
||||
List<String> scriptArgs = arguments.freeArgs.subList(1, arguments.freeArgs.size());
|
||||
JetCoreEnvironment environment = JetCoreEnvironment.createCoreEnvironmentForJVM(rootDisposable, configuration);
|
||||
noErrors = KotlinToJVMBytecodeCompiler.compileAndExecuteScript(environment, scriptArgs);
|
||||
}
|
||||
else {
|
||||
JetCoreEnvironment environment = JetCoreEnvironment.createCoreEnvironmentForJVM(rootDisposable, configuration);
|
||||
noErrors = KotlinToJVMBytecodeCompiler.compileBunchOfSources(environment, jar, outputDir, arguments.includeRuntime);
|
||||
}
|
||||
return noErrors ? OK : COMPILATION_ERROR;
|
||||
|
||||
+4
-5
@@ -73,13 +73,12 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ClassFileFactory compileModule(JetCoreEnvironment environment, Module moduleBuilder, File directory) {
|
||||
public static ClassFileFactory compileModule(CompilerConfiguration configuration, Module moduleBuilder, File directory) {
|
||||
if (moduleBuilder.getSourceFiles().isEmpty()) {
|
||||
throw new CompileEnvironmentException("No source files where defined");
|
||||
}
|
||||
|
||||
// TODO creating environment copy each time - not good. original environment shouldn't be passed at all
|
||||
CompilerConfiguration compilerConfiguration = environment.getConfiguration().copy();
|
||||
CompilerConfiguration compilerConfiguration = configuration.copy();
|
||||
for (String sourceFile : moduleBuilder.getSourceFiles()) {
|
||||
File source = new File(sourceFile);
|
||||
if (!source.isAbsolute()) {
|
||||
@@ -121,7 +120,7 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
}
|
||||
|
||||
public static boolean compileModules(
|
||||
JetCoreEnvironment environment,
|
||||
CompilerConfiguration configuration,
|
||||
@NotNull List<Module> modules,
|
||||
@NotNull File directory,
|
||||
@Nullable File jarPath,
|
||||
@@ -129,7 +128,7 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
boolean jarRuntime) {
|
||||
|
||||
for (Module moduleBuilder : modules) {
|
||||
ClassFileFactory moduleFactory = compileModule(environment, moduleBuilder, directory);
|
||||
ClassFileFactory moduleFactory = compileModule(configuration, moduleBuilder, directory);
|
||||
if (moduleFactory == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user