Added -builtins CLI option. Using it instead of "-mode stdlib" to enable special frontend and backend modes.
This commit is contained in:
@@ -450,6 +450,7 @@
|
||||
<arg value="-noStdlib"/>
|
||||
<arg value="-mode"/>
|
||||
<arg value="builtins"/>
|
||||
<arg value="-builtins"/>
|
||||
</java>
|
||||
|
||||
<!-- Not used yet -->
|
||||
|
||||
@@ -33,7 +33,6 @@ import org.jetbrains.jet.codegen.BuiltinToJavaTypesMapping;
|
||||
import org.jetbrains.jet.codegen.CompilationException;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.lang.BuiltinsScopeExtensionMode;
|
||||
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
|
||||
import java.io.File;
|
||||
@@ -56,7 +55,6 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, K2JVMComp
|
||||
@Override
|
||||
@NotNull
|
||||
protected ExitCode doExecute(K2JVMCompilerArguments arguments, PrintingMessageCollector messageCollector, Disposable rootDisposable) {
|
||||
CompilerSpecialMode mode = parseCompilerSpecialMode(arguments);
|
||||
CompilerConfiguration compilerConfiguration = createCompilerConfiguration(arguments);
|
||||
|
||||
final List<String> argumentsSourceDirs = arguments.getSourceDirs();
|
||||
@@ -71,7 +69,7 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, K2JVMComp
|
||||
}
|
||||
|
||||
JetCoreEnvironment environment = JetCoreEnvironment.createCoreEnvironmentForJVM(rootDisposable, compilerConfiguration);
|
||||
boolean builtins = mode == CompilerSpecialMode.BUILTINS;
|
||||
boolean builtins = arguments.builtins;
|
||||
K2JVMCompileEnvironmentConfiguration configuration = new K2JVMCompileEnvironmentConfiguration(
|
||||
environment, messageCollector, arguments.script,
|
||||
builtins ? BuiltinsScopeExtensionMode.ONLY_STANDARD_CLASSES : BuiltinsScopeExtensionMode.ALL,
|
||||
@@ -135,22 +133,6 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, K2JVMComp
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static CompilerSpecialMode parseCompilerSpecialMode(@NotNull K2JVMCompilerArguments arguments) {
|
||||
if (arguments.mode == null) {
|
||||
return CompilerSpecialMode.REGULAR;
|
||||
}
|
||||
else {
|
||||
for (CompilerSpecialMode variant : CompilerSpecialMode.values()) {
|
||||
if (arguments.mode.equalsIgnoreCase(variant.name().replaceAll("_", ""))) {
|
||||
return variant;
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: report properly
|
||||
throw new IllegalArgumentException("unknown compiler mode: " + arguments.mode);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Allow derived classes to add additional command line arguments
|
||||
|
||||
@@ -63,6 +63,9 @@ public class K2JVMCompilerArguments extends CompilerArguments {
|
||||
@Argument(value = "noJdkAnnotations", description = "don't include JDK external annotations into classpath")
|
||||
public boolean noJdkAnnotations;
|
||||
|
||||
@Argument(value = "builtins", description = "compile builtin classes (internal)")
|
||||
public boolean builtins;
|
||||
|
||||
@Deprecated
|
||||
@Argument(value = "stdlib", description = "Path to the stdlib.jar")
|
||||
public String stdlib;
|
||||
|
||||
@@ -39,7 +39,8 @@ public class ForTestCompileBuiltins {
|
||||
@Override
|
||||
protected void doCompile(@NotNull File classesDir) throws Exception {
|
||||
ExitCode exitCode = new K2JVMCompiler().exec(
|
||||
System.err, "-output", classesDir.getPath(), "-src", "./compiler/frontend/src", "-noStdlib", "-mode", "builtins");
|
||||
System.err, "-output", classesDir.getPath(), "-src", "./compiler/frontend/src", "-noStdlib", "-mode", "builtins",
|
||||
"-builtins");
|
||||
if (exitCode != ExitCode.OK) {
|
||||
throw new IllegalStateException("builtins compilation failed: " + exitCode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user