This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
173 additions
and
3 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
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
Empty file.
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,16 @@ | ||
load("@rules_scala_annex//rules:scala.bzl", "scala_library") | ||
load( | ||
":private.bzl", | ||
_make_semanticdb_plugin = "make_semanticdb_plugin", | ||
) | ||
|
||
scala_library( | ||
name = "lib", | ||
scala = "//external:scala_annex_scala", | ||
) | ||
|
||
_make_semanticdb_plugin( | ||
name = "2_12_7", | ||
dep = "@scala_annex_org_scalameta_semanticdb_scalac_2_12_7", | ||
visibility = ["//visibility:public"], | ||
) |
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,49 @@ | ||
load( | ||
"@rules_scala_annex//rules:providers.bzl", | ||
_ScalaRulePhase = "ScalaRulePhase", | ||
) | ||
|
||
SemanticDB = provider( | ||
doc = "Scala SemanticDB output", | ||
fields = { | ||
"output": "the semanticdb file", | ||
}, | ||
) | ||
|
||
def _phase_semanticdb_before_compile(ctx, g): | ||
print("semanticdb before compile phase") | ||
g.init.scalacopts.extend([ | ||
"-Xplugin-require:semanticdb", | ||
"-Yrangepos", | ||
#"-P:semanticdb:targetroot:~/Desktop/foo", | ||
]) | ||
|
||
def _phase_semanticdb_after_compile(ctx, g): | ||
print("semanticdb after compile phase") | ||
|
||
g.out.providers.append(SemanticDB( | ||
output = None, | ||
)) | ||
|
||
def _my_plugin_implementation(ctx): | ||
# TODO: write something intelligent that allows us to pass along | ||
# all providers from the underlying dep | ||
return [ | ||
ctx.attr.dep[JavaInfo], | ||
_ScalaRulePhase( | ||
phases = [ | ||
("-", "compile", "semanticdb", _phase_semanticdb_before_compile), | ||
("+", "compile", "semanticdb", _phase_semanticdb_after_compile), | ||
], | ||
), | ||
] | ||
|
||
make_semanticdb_plugin = rule( | ||
attrs = { | ||
"dep": attr.label( | ||
mandatory = True, | ||
providers = [JavaInfo], | ||
), | ||
}, | ||
implementation = _my_plugin_implementation, | ||
) |
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,12 @@ | ||
load("@rules_scala_annex//rules:scala.bzl", "configure_scala", "scala_library") | ||
load(":rules.bzl", "my_plugin") | ||
|
||
scala_library( | ||
name = "input", | ||
srcs = ["input.scala"], | ||
plugins = [ | ||
"@rules_scala_annex//rules/semanticdb:2_12_7", | ||
], | ||
scala = "@scala_2_12", | ||
tags = ["manual"], | ||
) |
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 @@ | ||
package anx | ||
|
||
object Foo | ||
|
||
object Bar |
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,3 @@ | ||
package annex | ||
|
||
object Plugin |
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,41 @@ | ||
load( | ||
"@rules_scala_annex//rules:providers.bzl", | ||
_ScalaRulePhase = "ScalaRulePhase", | ||
) | ||
|
||
def _foo_before_javainfo(ctx, g): | ||
if hasattr(g, "javainfo"): | ||
fail("javainfo shouldn't be in the globals, yet") | ||
|
||
def _foo_after_javainfo(ctx, g): | ||
if not hasattr(g, "javainfo"): | ||
fail("javainfo should be in the globals by now") | ||
|
||
def _foo_after_coda(ctx, g): | ||
if not hasattr(g, "compile"): | ||
fail("expected to run after compilation") | ||
|
||
print("plugin phase success") | ||
|
||
def _my_plugin_implementation(ctx): | ||
sdeps = java_common.merge([dep[JavaInfo] for dep in ctx.attr.deps]) | ||
return [ | ||
sdeps, | ||
_ScalaRulePhase( | ||
phases = [ | ||
("-", "javainfo", "foo_before_javainfo", _foo_before_javainfo), | ||
("+", "javainfo", "foo_after_javainfo", _foo_after_javainfo), | ||
("+", "coda", "foo_after_coda", _foo_after_coda), | ||
], | ||
), | ||
] | ||
|
||
my_plugin = rule( | ||
attrs = { | ||
"deps": attr.label_list( | ||
mandatory = True, | ||
providers = [JavaInfo], | ||
), | ||
}, | ||
implementation = _my_plugin_implementation, | ||
) |
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,4 @@ | ||
#!/bin/bash -e | ||
. "$(dirname "$0")"/../common.sh | ||
|
||
bazel build :input |
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,3 @@ | ||
package anx | ||
|
||
object Usage |