Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Commit ac21013

Browse files
authored
Allow configuring number of errors logged by compiler (#199)
1 parent 9d6eaa6 commit ac21013

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ If the right design principles are kept, implementing additional features should
4141
* [Customizable rules](docs/newdocs/phases.md#customizing-the-core-rules)
4242
* [Multiple Scala versions in one build](docs/newdocs/scala_versions.md#specifying-the-scala-version-to-use)
4343
* [Optimal handling of macros and ijars](docs/newdocs/macros.md#macros-and-ijars)
44+
* [Pass flags to Zinc compiler](docs/newdocs/zinc_flags.md)
4445

4546
## Usage
4647

docs/newdocs/zinc_flags.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## Pass flags to Zinc compiler
2+
3+
### Persistence Directory Path
4+
Use `--persistence_dir` to specify the path to save Zinc state files.
5+
6+
### Use Persistence Directory
7+
Use `--use_persistence` to enable or disable the persistence directory. The default is `true`.
8+
9+
### Maximum Error Number
10+
Use `--max_errors` to specify the number of errors to be shown from Zinc. The default is `10`.
11+
12+
## Example
13+
In `.bazelrc` file, add the following snippet
14+
```sh
15+
build --worker_extra_flag=ScalaCompile=--persistence_dir=bazel-zinc
16+
build --worker_extra_flag=ScalaCompile=--use_persistence=true
17+
build --worker_extra_flag=ScalaCompile=--max_errors=20
18+
```

src/main/scala/higherkindness/rules_scala/workers/zinc/compile/ZincRunner.scala

+6-1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ object ZincRunner extends WorkerMain[Namespace] {
6767
val parser = ArgumentParsers.newFor("zinc-worker").addHelp(true).build
6868
parser.addArgument("--persistence_dir", /* deprecated */ "--persistenceDir").metavar("path")
6969
parser.addArgument("--use_persistence").`type`(Arg.booleanType)
70+
parser.addArgument("--max_errors")
7071
parser.parseArgsOrFail(args.getOrElse(Array.empty))
7172
}
7273

@@ -212,8 +213,12 @@ object ZincRunner extends WorkerMain[Namespace] {
212213
}
213214

214215
val setup = {
216+
val maxErrors: Int = worker.getString("max_errors") match {
217+
case x: String if x.forall(_.isDigit) => x.toInt
218+
case _ => 10
219+
}
215220
val incOptions = IncOptions.create()
216-
val reporter = new LoggedReporter(10, logger)
221+
val reporter = new LoggedReporter(maxErrors, logger)
217222
val skip = false
218223
Setup.create(lookup, skip, null, compilerCache, incOptions, reporter, Optional.empty(), Array.empty)
219224
}

0 commit comments

Comments
 (0)