A command-line option to ignore compilation errors and generate byte code anyway.

Needed for: building jdk-headers
This commit is contained in:
Andrey Breslav
2012-01-26 19:11:12 +04:00
parent 4bd4454363
commit 167b6c8a5a
2 changed files with 12 additions and 2 deletions
@@ -37,6 +37,9 @@ public class KotlinCompiler {
@Argument(value = "help", alias = "h", description = "show help") @Argument(value = "help", alias = "h", description = "show help")
public boolean help; public boolean help;
@Argument(value = "ignoreErrors", description = "Emit byte code even if there are compilation errors (not recommended)")
public boolean ignoreErrors;
} }
private static void usage(PrintStream target) { private static void usage(PrintStream target) {
@@ -77,6 +80,7 @@ public class KotlinCompiler {
} }
CompileEnvironment environment = new CompileEnvironment(); CompileEnvironment environment = new CompileEnvironment();
environment.setIgnoreErrors(arguments.ignoreErrors);
if (arguments.stdlib != null) { if (arguments.stdlib != null) {
environment.setStdlib(arguments.stdlib); environment.setStdlib(arguments.stdlib);
@@ -37,6 +37,8 @@ public class CompileEnvironment {
private PrintStream myErrorStream = System.out; private PrintStream myErrorStream = System.out;
private URL myStdlib; private URL myStdlib;
private boolean ignoreErrors = false;
public CompileEnvironment() { public CompileEnvironment() {
myRootDisposable = new Disposable() { myRootDisposable = new Disposable() {
@Override @Override
@@ -50,6 +52,10 @@ public class CompileEnvironment {
myErrorStream = errorStream; myErrorStream = errorStream;
} }
public void setIgnoreErrors(boolean ignoreErrors) {
this.ignoreErrors = ignoreErrors;
}
public void dispose() { public void dispose() {
Disposer.dispose(myRootDisposable); Disposer.dispose(myRootDisposable);
} }
@@ -199,7 +205,7 @@ public class CompileEnvironment {
ensureRuntime(); ensureRuntime();
if (!moduleCompileSession.analyze(myErrorStream)) { if (!moduleCompileSession.analyze(myErrorStream) && !ignoreErrors) {
return null; return null;
} }
return moduleCompileSession.generate(); return moduleCompileSession.generate();
@@ -296,7 +302,7 @@ public class CompileEnvironment {
ensureRuntime(); ensureRuntime();
if (!session.analyze(myErrorStream)) { if (!session.analyze(myErrorStream) && !ignoreErrors) {
return false; return false;
} }