Added "optimize" flag to settings everywhere
This commit is contained in:
committed by
Alexander Udalov
parent
433c9cd4a5
commit
0e683b0b99
@@ -24,6 +24,7 @@ import org.jetbrains.jet.buildtools.core.Util;
|
||||
import org.jetbrains.jet.cli.common.arguments.CompilerArgumentsUtil;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentException;
|
||||
import org.jetbrains.jet.codegen.inline.InlineCodegenUtil;
|
||||
import org.jetbrains.jet.codegen.optimization.OptimizationUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
@@ -50,6 +51,7 @@ public class BytecodeCompilerTask extends Task {
|
||||
private Path compileClasspath;
|
||||
private boolean includeRuntime = true;
|
||||
private String inline;
|
||||
private String optimize;
|
||||
|
||||
public void setOutput(File output) {
|
||||
this.output = output;
|
||||
@@ -97,6 +99,10 @@ public class BytecodeCompilerTask extends Task {
|
||||
this.inline = inline;
|
||||
}
|
||||
|
||||
public void setOptimize(String optimize) {
|
||||
this.optimize = optimize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the classpath to be used for this compilation.
|
||||
*
|
||||
@@ -144,10 +150,15 @@ public class BytecodeCompilerTask extends Task {
|
||||
String[] externalAnnotationsPath = (this.externalAnnotations != null) ? this.externalAnnotations.list() : null;
|
||||
|
||||
if (!CompilerArgumentsUtil.checkOption(inline)) {
|
||||
throw new CompileEnvironmentException(CompilerArgumentsUtil.getWrongInlineOptionErrorMessage(inline));
|
||||
throw new CompileEnvironmentException(CompilerArgumentsUtil.getWrongCheckOptionErrorMessage("inline", inline));
|
||||
}
|
||||
|
||||
if (!CompilerArgumentsUtil.checkOption(optimize)) {
|
||||
throw new CompileEnvironmentException(CompilerArgumentsUtil.getWrongCheckOptionErrorMessage("optimize", optimize));
|
||||
}
|
||||
|
||||
boolean enableInline = CompilerArgumentsUtil.optionToBooleanFlag(inline, InlineCodegenUtil.DEFAULT_INLINE_FLAG);
|
||||
boolean enableOptimization = CompilerArgumentsUtil.optionToBooleanFlag(optimize, OptimizationUtils.DEFAULT_OPTIMIZATION_FLAG);
|
||||
|
||||
if (this.src != null) {
|
||||
|
||||
@@ -161,10 +172,16 @@ public class BytecodeCompilerTask extends Task {
|
||||
log(String.format("Compiling [%s] => [%s]", Arrays.toString(source), destination));
|
||||
|
||||
if (this.output != null) {
|
||||
compiler.sourcesToDir(source, destination, stdlibPath, classpath, externalAnnotationsPath, enableInline);
|
||||
compiler.sourcesToDir(
|
||||
source, destination, stdlibPath, classpath, externalAnnotationsPath,
|
||||
enableInline, enableOptimization
|
||||
);
|
||||
}
|
||||
else {
|
||||
compiler.sourcesToJar(source, destination, this.includeRuntime, stdlibPath, classpath, externalAnnotationsPath, enableInline);
|
||||
compiler.sourcesToJar(
|
||||
source, destination, this.includeRuntime, stdlibPath, classpath, externalAnnotationsPath,
|
||||
enableInline, enableOptimization
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (this.module != null) {
|
||||
@@ -179,7 +196,10 @@ public class BytecodeCompilerTask extends Task {
|
||||
log(jarPath != null ? String.format("Compiling [%s] => [%s]", modulePath, jarPath) :
|
||||
String.format("Compiling [%s]", modulePath));
|
||||
|
||||
compiler.moduleToJar(modulePath, jarPath, this.includeRuntime, stdlibPath, classpath, externalAnnotationsPath, enableInline);
|
||||
compiler.moduleToJar(
|
||||
modulePath, jarPath, this.includeRuntime, stdlibPath, classpath, externalAnnotationsPath,
|
||||
enableInline, enableOptimization
|
||||
);
|
||||
}
|
||||
else {
|
||||
throw new CompileEnvironmentException("\"src\" or \"module\" should be specified");
|
||||
|
||||
@@ -40,9 +40,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.cli.jvm.JVMConfigurationKeys.ANNOTATIONS_PATH_KEY;
|
||||
import static org.jetbrains.jet.cli.jvm.JVMConfigurationKeys.CLASSPATH_KEY;
|
||||
import static org.jetbrains.jet.cli.jvm.JVMConfigurationKeys.ENABLE_INLINE;
|
||||
import static org.jetbrains.jet.cli.jvm.JVMConfigurationKeys.*;
|
||||
import static org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentUtil.loadModuleDescriptions;
|
||||
|
||||
|
||||
@@ -65,6 +63,7 @@ public class BytecodeCompiler {
|
||||
* @param classpath compilation classpath, only used if not null and not empty
|
||||
* @param sourceRoots
|
||||
* @param enableInline
|
||||
* @param enableOptimization
|
||||
* @return compile environment instance
|
||||
*/
|
||||
private JetCoreEnvironment env(
|
||||
@@ -72,9 +71,12 @@ public class BytecodeCompiler {
|
||||
String[] classpath,
|
||||
String[] externalAnnotationsPath,
|
||||
String[] sourceRoots,
|
||||
boolean enableInline
|
||||
boolean enableInline,
|
||||
boolean enableOptimization
|
||||
) {
|
||||
CompilerConfiguration configuration = createConfiguration(stdlib, classpath, externalAnnotationsPath, sourceRoots, enableInline);
|
||||
CompilerConfiguration configuration = createConfiguration(
|
||||
stdlib, classpath, externalAnnotationsPath, sourceRoots, enableInline, enableOptimization
|
||||
);
|
||||
|
||||
return JetCoreEnvironment.createForProduction(Disposer.newDisposable(), configuration);
|
||||
}
|
||||
@@ -84,7 +86,8 @@ public class BytecodeCompiler {
|
||||
@Nullable String[] classpath,
|
||||
@Nullable String[] externalAnnotationsPath,
|
||||
@NotNull String[] sourceRoots,
|
||||
boolean enableInline
|
||||
boolean enableInline,
|
||||
boolean enableOptimization
|
||||
) {
|
||||
KotlinPaths paths = getKotlinPathsForAntTask();
|
||||
CompilerConfiguration configuration = new CompilerConfiguration();
|
||||
@@ -123,6 +126,7 @@ public class BytecodeCompiler {
|
||||
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR);
|
||||
|
||||
configuration.put(ENABLE_INLINE, enableInline);
|
||||
configuration.put(ENABLE_OPTIMIZATION, enableOptimization);
|
||||
|
||||
// lets register any compiler plugins
|
||||
configuration.addAll(CLIConfigurationKeys.COMPILER_PLUGINS, getCompilerPlugins());
|
||||
@@ -169,9 +173,10 @@ public class BytecodeCompiler {
|
||||
@Nullable String stdlib,
|
||||
@Nullable String[] classpath,
|
||||
@Nullable String[] externalAnnotationsPath,
|
||||
boolean enableInline) {
|
||||
boolean enableInline,
|
||||
boolean enableOptimization) {
|
||||
try {
|
||||
JetCoreEnvironment environment = env(stdlib, classpath, externalAnnotationsPath, src, enableInline);
|
||||
JetCoreEnvironment environment = env(stdlib, classpath, externalAnnotationsPath, src, enableInline, enableOptimization);
|
||||
|
||||
boolean success = KotlinToJVMBytecodeCompiler.compileBunchOfSources(environment, null, new File(output), true);
|
||||
if (!success) {
|
||||
@@ -199,9 +204,10 @@ public class BytecodeCompiler {
|
||||
@Nullable String stdlib,
|
||||
@Nullable String[] classpath,
|
||||
@Nullable String[] externalAnnotationsPath,
|
||||
boolean enableInline) {
|
||||
boolean enableInline,
|
||||
boolean enableOptimization) {
|
||||
try {
|
||||
JetCoreEnvironment environment = env(stdlib, classpath, externalAnnotationsPath, src, enableInline);
|
||||
JetCoreEnvironment environment = env(stdlib, classpath, externalAnnotationsPath, src, enableInline, enableOptimization);
|
||||
|
||||
boolean success = KotlinToJVMBytecodeCompiler.compileBunchOfSources(environment, new File(jar), null, includeRuntime);
|
||||
if (!success) {
|
||||
@@ -222,6 +228,7 @@ public class BytecodeCompiler {
|
||||
* @param stdlib "kotlin-runtime.jar" path
|
||||
* @param classpath compilation classpath, can be <code>null</code> or empty
|
||||
* @param enableInline
|
||||
* @param enableOptimization
|
||||
*/
|
||||
public void moduleToJar(
|
||||
@NotNull String module,
|
||||
@@ -229,7 +236,7 @@ public class BytecodeCompiler {
|
||||
boolean includeRuntime,
|
||||
@Nullable String stdlib,
|
||||
@Nullable String[] classpath,
|
||||
@Nullable String[] externalAnnotationsPath, boolean enableInline
|
||||
@Nullable String[] externalAnnotationsPath, boolean enableInline, boolean enableOptimization
|
||||
) {
|
||||
try {
|
||||
ModuleScriptData moduleScriptData =
|
||||
@@ -240,7 +247,7 @@ public class BytecodeCompiler {
|
||||
sourcesRoots.addAll(m.getSourceFiles());
|
||||
}
|
||||
CompilerConfiguration configuration = createConfiguration(stdlib, classpath, externalAnnotationsPath, sourcesRoots.toArray(new String[0]),
|
||||
enableInline);
|
||||
enableInline, enableOptimization);
|
||||
File directory = new File(module).getParentFile();
|
||||
boolean success = KotlinToJVMBytecodeCompiler.compileModules(configuration, modules, directory, new File(jar), includeRuntime);
|
||||
if (!success) {
|
||||
|
||||
Reference in New Issue
Block a user