-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make tests pass on Windows Bunch of changes. Here's some highlights: Code Changes - Refactored ScalacWorker to abstract common code between Scala 2 & 3 - Refactored dependency-analyzer plugin javaargs to use ‘;’ as a delimiter instead of ‘:’ - Renamed a couple function names containing rpathlocation to rlocationpath - added lineEndings=preserve to scalafmt.conf - added .bazelrc to enable needed flags for Windows Test Changes - disable running tests for features not-supported on Windows - make tests handle fact that sh_binary outputs .exe on Windows - Handle other Windows specifics where needed (i.e. backslash as pathseparator, crlf linendings, dependence on bash) * Fixed some minor nits
- Loading branch information
Showing
42 changed files
with
416 additions
and
545 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
build --enable_platform_specific_config | ||
|
||
#Windows needs --worker_quit_after_build due to workers not being shut down when the compiler tools need to be rebuilt (resulting in 'file in use' errors). See Bazel Issue#10498. | ||
|
||
build:windows --worker_quit_after_build --enable_runfiles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ rewrite.rules = [ | |
SortImports | ||
] | ||
unindentTopLevelOperators = false | ||
lineEndings=preserve |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import ../../.bazelrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import ../../.bazelrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build --enable_platform_specific_config | ||
windows:build --enable_runfiles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build --enable_platform_specific_config | ||
windows:build --enable_runfiles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package io.bazel.rulesscala.scalac; | ||
|
||
import io.bazel.rulesscala.scalac.reporter.DepsTrackingReporter; | ||
import io.bazel.rulesscala.scalac.compileoptions.CompileOptions; | ||
import java.nio.file.Paths; | ||
import io.bazel.rulesscala.scalac.reporter.ProtoReporter; | ||
import scala.tools.nsc.reporters.ConsoleReporter; | ||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.nio.file.Files; | ||
|
||
//Invokes Scala 2 compiler | ||
class ScalacInvoker{ | ||
|
||
public static ScalacInvokerResults invokeCompiler(CompileOptions ops, String[] compilerArgs) | ||
throws IOException, Exception{ | ||
|
||
ReportableMainClass comp = new ReportableMainClass(ops); | ||
|
||
ScalacInvokerResults results = new ScalacInvokerResults(); | ||
|
||
results.startTime = System.currentTimeMillis(); | ||
try { | ||
comp.process(compilerArgs); | ||
} catch (Throwable ex) { | ||
if (ex.toString().contains("scala.reflect.internal.Types$TypeError")) { | ||
throw new RuntimeException("Build failure with type error", ex); | ||
} else if (ex.toString().contains("java.lang.StackOverflowError")) { | ||
throw new RuntimeException("Build failure with StackOverflowError", ex); | ||
} else if (isMacroException(ex)) { | ||
throw new RuntimeException("Build failure during macro expansion", ex); | ||
} else { | ||
throw ex; | ||
} | ||
} | ||
|
||
results.stopTime = System.currentTimeMillis(); | ||
|
||
ConsoleReporter reporter = (ConsoleReporter) comp.getReporter(); | ||
if (reporter instanceof ProtoReporter) { | ||
ProtoReporter protoReporter = (ProtoReporter) reporter; | ||
protoReporter.writeTo(Paths.get(ops.diagnosticsFile)); | ||
} | ||
|
||
if (reporter instanceof DepsTrackingReporter) { | ||
DepsTrackingReporter depTrackingReporter = (DepsTrackingReporter) reporter; | ||
depTrackingReporter.prepareReport(); | ||
depTrackingReporter.writeDiagnostics(ops.diagnosticsFile); | ||
} | ||
|
||
if (reporter.hasErrors()) { | ||
reporter.flush(); | ||
throw new RuntimeException("Build failed"); | ||
} | ||
|
||
return results; | ||
} | ||
|
||
public static boolean isMacroException(Throwable ex) { | ||
for (StackTraceElement elem : ex.getStackTrace()) { | ||
if (elem.getMethodName().equals("macroExpand")) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package io.bazel.rulesscala.scalac; | ||
|
||
import io.bazel.rulesscala.scalac.compileoptions.CompileOptions; | ||
import java.nio.file.Paths; | ||
import java.nio.file.Files; | ||
import scala.Tuple2; | ||
import java.io.IOException; | ||
|
||
import dotty.tools.dotc.reporting.Reporter; | ||
import dotty.tools.dotc.Compiler; | ||
import dotty.tools.dotc.Driver; | ||
import dotty.tools.dotc.core.Contexts; | ||
import dotty.tools.io.AbstractFile; | ||
|
||
//Invokes Scala 3 compiler | ||
class ScalacInvoker{ | ||
public static ScalacInvokerResults invokeCompiler(CompileOptions ops, String[] compilerArgs) | ||
throws IOException, Exception{ | ||
|
||
|
||
ScalacInvokerResults results = new ScalacInvokerResults(); | ||
Driver driver = new dotty.tools.dotc.Driver(); | ||
Contexts.Context ctx = driver.initCtx().fresh(); | ||
|
||
Tuple2<scala.collection.immutable.List<AbstractFile>, Contexts.Context> r = driver.setup(compilerArgs, ctx).get(); | ||
|
||
Compiler compiler = driver.newCompiler(r._2); | ||
|
||
results.startTime= System.currentTimeMillis(); | ||
|
||
Reporter reporter = driver.doCompile(compiler, r._1, r._2); | ||
|
||
results.stopTime = System.currentTimeMillis(); | ||
|
||
Files.createFile( | ||
Paths.get(ops.diagnosticsFile)); | ||
Files.createFile( | ||
Paths.get(ops.scalaDepsFile)); | ||
|
||
|
||
if (reporter.hasErrors()) { | ||
// reporter.flush(); | ||
throw new RuntimeException("Build failed"); | ||
} | ||
|
||
return results; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/java/io/bazel/rulesscala/scalac/ScalacInvokerResults.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.bazel.rulesscala.scalac; | ||
|
||
public class ScalacInvokerResults{ | ||
public long startTime; //unixTime ms | ||
public long stopTime; //unixTime ms | ||
} |
Oops, something went wrong.