Skip to content

Commit

Permalink
Somewhat hacky fix to still build other optimization levels
Browse files Browse the repository at this point in the history
  • Loading branch information
niloc132 committed Nov 27, 2023
1 parent c6665d5 commit 306a061
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 7 additions & 3 deletions j2cl-tasks/src/main/java/com/vertispan/j2cl/tools/Closure.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public boolean compile(

final InProcessJsCompRunner jscompRunner;
synchronized (GLOBAL_CLOSURE_ARGS_LOCK) {
jscompRunner = new InProcessJsCompRunner(log, jscompArgs.toArray(new String[0]), jsCompiler, exportTestFunctions, checkAssertions);
jscompRunner = new InProcessJsCompRunner(log, jscompArgs.toArray(new String[0]), jsCompiler, exportTestFunctions, checkAssertions, compilationLevel);
}
jscompArgs.forEach(log::debug);
if (!jscompRunner.shouldRunCompiler()) {
Expand All @@ -197,11 +197,13 @@ static class InProcessJsCompRunner extends CommandLineRunner {
private final boolean exportTestFunctions;
private final boolean checkAssertions;
private final Compiler compiler;
private final CompilationLevel compilationLevel;
private Integer exitCode;

InProcessJsCompRunner(BuildLog log, String[] args, Compiler compiler, boolean exportTestFunctions, boolean checkAssertions) {
InProcessJsCompRunner(BuildLog log, String[] args, Compiler compiler, boolean exportTestFunctions, boolean checkAssertions, CompilationLevel compilationLevel) {
super(args);
this.compiler = compiler;
this.compilationLevel = compilationLevel;
this.compiler.setErrorManager(new SortingErrorManager(Collections.singleton(new LoggingErrorReportGenerator(compiler, log))));
this.exportTestFunctions = exportTestFunctions;
this.checkAssertions = checkAssertions;
Expand Down Expand Up @@ -232,7 +234,9 @@ protected CompilerOptions createOptions() {
@Override
protected void setRunOptions(CompilerOptions options) throws IOException {
super.setRunOptions(options);
this.compiler.setPassConfig(new ServiceLoadingPassConfig(options));
if (compilationLevel == CompilationLevel.ADVANCED_OPTIMIZATIONS) {
this.compiler.setPassConfig(new ServiceLoadingPassConfig(options));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ public ServiceLoadingPassConfig(CompilerOptions options) {
@Override
protected PassListBuilder getOptimizations() {
PassListBuilder optimizations = super.getOptimizations();
// optimizations.addAfter(convertServiceLoaderProperties, PassNames.PARSE_INPUTS);
// optimizations.addAfter(convertServiceLoaderProperties, PassNames.NORMALIZE);
optimizations.addBefore(convertServiceLoaderProperties, PassNames.AFTER_EARLY_OPTIMIZATION_LOOP);
optimizations.addBefore(convertServiceLoaderProperties, PassNames.AFTER_MAIN_OPTIMIZATIONS);
// optimizations.addAfter(convertServiceLoaderProperties, PassNames.PEEPHOLE_OPTIMIZATIONS);
return optimizations;
}
}

0 comments on commit 306a061

Please sign in to comment.