A command-line option to ignore compilation errors and generate byte code anyway.
Needed for: building jdk-headers
This commit is contained in:
@@ -37,6 +37,9 @@ public class KotlinCompiler {
|
||||
|
||||
@Argument(value = "help", alias = "h", description = "show 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) {
|
||||
@@ -77,6 +80,7 @@ public class KotlinCompiler {
|
||||
}
|
||||
|
||||
CompileEnvironment environment = new CompileEnvironment();
|
||||
environment.setIgnoreErrors(arguments.ignoreErrors);
|
||||
|
||||
if (arguments.stdlib != null) {
|
||||
environment.setStdlib(arguments.stdlib);
|
||||
|
||||
@@ -37,6 +37,8 @@ public class CompileEnvironment {
|
||||
private PrintStream myErrorStream = System.out;
|
||||
private URL myStdlib;
|
||||
|
||||
private boolean ignoreErrors = false;
|
||||
|
||||
public CompileEnvironment() {
|
||||
myRootDisposable = new Disposable() {
|
||||
@Override
|
||||
@@ -50,6 +52,10 @@ public class CompileEnvironment {
|
||||
myErrorStream = errorStream;
|
||||
}
|
||||
|
||||
public void setIgnoreErrors(boolean ignoreErrors) {
|
||||
this.ignoreErrors = ignoreErrors;
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
Disposer.dispose(myRootDisposable);
|
||||
}
|
||||
@@ -199,7 +205,7 @@ public class CompileEnvironment {
|
||||
|
||||
ensureRuntime();
|
||||
|
||||
if (!moduleCompileSession.analyze(myErrorStream)) {
|
||||
if (!moduleCompileSession.analyze(myErrorStream) && !ignoreErrors) {
|
||||
return null;
|
||||
}
|
||||
return moduleCompileSession.generate();
|
||||
@@ -296,7 +302,7 @@ public class CompileEnvironment {
|
||||
|
||||
ensureRuntime();
|
||||
|
||||
if (!session.analyze(myErrorStream)) {
|
||||
if (!session.analyze(myErrorStream) && !ignoreErrors) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user