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

Commit a9af6a9

Browse files
authored
Merge pull request #141 from andyscott/rule-phases
Refactor rules into configurable phases
2 parents a2268a2 + 5c6004c commit a9af6a9

File tree

19 files changed

+731
-447
lines changed

19 files changed

+731
-447
lines changed

WORKSPACE

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@ http_archive(
3030
urls = ["https://github.com/google/protobuf/archive/0038ff49af882463c2af9049356eed7df45c3e8e.zip"],
3131
)
3232

33-
load("//rules/scala:workspace.bzl", "scala_repositories", "scala_register_toolchains")
33+
load("//rules/scala:workspace.bzl", "scala_register_toolchains", "scala_repositories")
3434

3535
scala_repositories()
3636

3737
scala_register_toolchains()
3838

39-
load("//rules/scalafmt:workspace.bzl", "scalafmt_repositories", "scalafmt_default_config")
39+
load("//rules/scalafmt:workspace.bzl", "scalafmt_default_config", "scalafmt_repositories")
4040

4141
scalafmt_repositories()
4242

4343
scalafmt_default_config(".scalafmt.conf")
4444

4545
load(
4646
"//rules/scala_proto:workspace.bzl",
47-
"scala_proto_repositories",
4847
"scala_proto_register_toolchains",
48+
"scala_proto_repositories",
4949
)
5050

5151
scala_proto_repositories()

docs/stardoc/providers.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,29 @@ Zinc configuration.
220220
</table>
221221

222222

223+
<a name="#ScalaRulePhase"></a>
224+
## ScalaRulePhase
225+
226+
A Scala compiler plugin
227+
228+
### Fields
229+
230+
<table class="params-table">
231+
<colgroup>
232+
<col class="col-param" />
233+
<col class="col-description" />
234+
</colgroup>
235+
<tbody>
236+
<tr id="#ScalaRulePhase_phases">
237+
<td><code>phases</code></td>
238+
<td>
239+
<p>the phases to add</p>
240+
</td>
241+
</tr>
242+
</tbody>
243+
</table>
244+
245+
223246
<a name="#ZincInfo"></a>
224247
## ZincInfo
225248

rules/providers.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ ZincConfiguration = provider(
6060
},
6161
)
6262

63+
ScalaRulePhase = provider(
64+
doc = "A Scala compiler plugin",
65+
fields = {
66+
"phases": "the phases to add",
67+
},
68+
)
69+
6370
def _declare_zinc_configuration_implementation(ctx):
6471
return [ZincConfiguration(
6572
compiler_bridge = ctx.files.compiler_bridge,

rules/rules_scala/private/compat.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ load(
1212
)
1313
load(
1414
"//rules:scala.bzl",
15-
_scala_library = "scala_library",
1615
_scala_binary = "scala_binary",
16+
_scala_library = "scala_library",
1717
_scala_test = "scala_test",
1818
)
1919
load(

rules/scala/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("//rules:scala.bzl", "scala_library", "scala_binary", "scala_deps_toolchain", "scala_runner_toolchain")
1+
load("//rules:scala.bzl", "scala_binary", "scala_deps_toolchain", "scala_library", "scala_runner_toolchain")
22
load("//rules:scalac.bzl", "scalac_binary", "scalac_library")
33
load("//rules:scalafmt.bzl", "scala_format_test")
44

rules/scala/deps/DepsRunner.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ object DepsRunner extends SimpleMain {
3838
parser
3939
}
4040

41-
protected[this] def work(args: Array[String]) = {
41+
protected[this] def work(args: Array[String]): Unit = {
4242
val namespace = argParser.parseArgs(args)
4343

4444
val label = namespace.getString("label").tail
@@ -75,11 +75,10 @@ object DepsRunner extends SimpleMain {
7575
println(s"buildozer 'add deps $depLabel' $label")
7676
}
7777

78-
if (add.nonEmpty || remove.nonEmpty) {
79-
sys.exit(1)
78+
if (add.isEmpty && remove.isEmpty) {
79+
try Files.createFile(namespace.get[File]("success").toPath)
80+
catch { case _: FileAlreadyExistsException => }
8081
}
8182

82-
try Files.createFile(namespace.get[File]("success").toPath)
83-
catch { case _: FileAlreadyExistsException => }
8483
}
8584
}

0 commit comments

Comments
 (0)