1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
package(default_visibility = ["//visibility:public"])
load("@jflex_rules//jflex:jflex.bzl", "jflex")
load("@jflex_rules//cup:cup.bzl", "cup")
# The best practice is to define the rules in their respective directory in
# - src/main/java/org/example/foo/BUILD
# - src/main/jflex/BUILD
# - src/test/java/org/example/foo/BUILD
# - etc.
# However, this example is simple enough and we can define all rules here.
java_library(
name = "minijava",
# glob is not a best practice, but it's good enough for this example
srcs = glob(["src/main/java/**/*.java"]) + [
":gen_lexer",
":gen_parser",
],
deps = ["//third_party/java_cup:runtime"],
)
jflex(
name = "gen_lexer",
srcs = ["src/main/jflex/minijava.flex"],
jflex_bin = "//jflex:jflex_bin",
outputs = ["Lexer.java"],
)
cup(
name = "gen_parser",
src = "src/main/cup/minijava.cup",
symbols = "sym",
)
# Tests
java_test(
name = "LexerTest",
srcs = ["src/test/java/jflex/examples/minijava/LexerTest.java"],
deps = [
":minijava",
"//third_party/com/google/truth",
"//third_party/java_cup:runtime",
],
)
|