xref: /aosp_15_r20/external/antlr/tool/src/BUILD.bazel (revision 16467b971bd3e2009fad32dd79016f2c7e421deb)
1*16467b97STreehugger Robot"""BUILD.bazel file for ANTLR 3."""
2*16467b97STreehugger Robot
3*16467b97STreehugger Robotload("@rules_java//java:defs.bzl", "java_binary", "java_library", "java_test")
4*16467b97STreehugger Robot
5*16467b97STreehugger Robotpackage(default_visibility = ["//visibility:private"])
6*16467b97STreehugger Robot
7*16467b97STreehugger Robotjava_binary(
8*16467b97STreehugger Robot    name = "tool",
9*16467b97STreehugger Robot    main_class = "org.antlr.Tool",
10*16467b97STreehugger Robot    visibility = ["//:__pkg__"],
11*16467b97STreehugger Robot    runtime_deps = [":tool_lib"],
12*16467b97STreehugger Robot)
13*16467b97STreehugger Robot
14*16467b97STreehugger Robotjava_library(
15*16467b97STreehugger Robot    name = "tool_lib",
16*16467b97STreehugger Robot    srcs = glob(["main/java/**/*.java"]) + [
17*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/ANTLRLexer.java",
18*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/ANTLRParser.java",
19*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/ANTLRTreePrinter.java",
20*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/ANTLRv3Lexer.java",
21*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/ANTLRv3Parser.java",
22*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/ANTLRv3Tree.java",
23*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/ActionAnalysis.java",
24*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/ActionTranslator.java",
25*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/AssignTokenTypesWalker.java",
26*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/CodeGenTreeWalker.java",
27*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/DefineGrammarItemsWalker.java",
28*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/LeftRecursiveRuleWalker.java",
29*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/TreeToNFAConverter.java",
30*16467b97STreehugger Robot    ],
31*16467b97STreehugger Robot    javacopts = [
32*16467b97STreehugger Robot        "-Xep:EqualsHashCode:OFF",
33*16467b97STreehugger Robot    ],
34*16467b97STreehugger Robot    resource_strip_prefix = "tool/src/main/resources",
35*16467b97STreehugger Robot    resources = glob(["main/resources/**/*.stg"]),
36*16467b97STreehugger Robot    visibility = ["//visibility:public"],
37*16467b97STreehugger Robot    deps = [
38*16467b97STreehugger Robot        ":tool_bootstrap",
39*16467b97STreehugger Robot        "//:java_runtime",
40*16467b97STreehugger Robot        "@stringtemplate4",
41*16467b97STreehugger Robot    ],
42*16467b97STreehugger Robot)
43*16467b97STreehugger Robot
44*16467b97STreehugger Robotgenrule(
45*16467b97STreehugger Robot    name = "tool_bootstrap",
46*16467b97STreehugger Robot    srcs = [
47*16467b97STreehugger Robot        "main/antlr3/org/antlr/grammar/v3/ANTLR.g",
48*16467b97STreehugger Robot        "main/antlr3/org/antlr/grammar/v3/ANTLRTreePrinter.g",
49*16467b97STreehugger Robot        "main/antlr3/org/antlr/grammar/v3/ANTLRv3.g",
50*16467b97STreehugger Robot        "main/antlr3/org/antlr/grammar/v3/ANTLRv3Tree.g",
51*16467b97STreehugger Robot        "main/antlr3/org/antlr/grammar/v3/ActionAnalysis.g",
52*16467b97STreehugger Robot        "main/antlr3/org/antlr/grammar/v3/ActionTranslator.g",
53*16467b97STreehugger Robot        "main/antlr3/org/antlr/grammar/v3/AssignTokenTypesWalker.g",
54*16467b97STreehugger Robot        "main/antlr3/org/antlr/grammar/v3/CodeGenTreeWalker.g",
55*16467b97STreehugger Robot        "main/antlr3/org/antlr/grammar/v3/DefineGrammarItemsWalker.g",
56*16467b97STreehugger Robot        "main/antlr3/org/antlr/grammar/v3/LeftRecursiveRuleWalker.g",
57*16467b97STreehugger Robot        "main/antlr3/org/antlr/grammar/v3/TreeToNFAConverter.g",
58*16467b97STreehugger Robot    ],
59*16467b97STreehugger Robot    outs = [
60*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/ANTLRLexer.java",
61*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/ANTLRParser.java",
62*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/ANTLRTreePrinter.java",
63*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/ANTLRv3Lexer.java",
64*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/ANTLRv3Parser.java",
65*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/ANTLRv3Tree.java",
66*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/ActionAnalysis.java",
67*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/ActionTranslator.java",
68*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/AssignTokenTypesWalker.java",
69*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/CodeGenTreeWalker.java",
70*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/DefineGrammarItemsWalker.java",
71*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/LeftRecursiveRuleWalker.java",
72*16467b97STreehugger Robot        "main/java/org/antlr/grammar/v3/TreeToNFAConverter.java",
73*16467b97STreehugger Robot    ],
74*16467b97STreehugger Robot    cmd = """
75*16467b97STreehugger Robot      $(JAVA) -cp $(location @antlr3_bootstrap//jar) org.antlr.Tool -fo $(RULEDIR)/main/java/org/antlr/grammar/v3 $(location :main/antlr3/org/antlr/grammar/v3/ANTLR.g)
76*16467b97STreehugger Robot      $(JAVA) -cp $(location @antlr3_bootstrap//jar) org.antlr.Tool -fo $(RULEDIR)/main/java/org/antlr/grammar/v3 $(location :main/antlr3/org/antlr/grammar/v3/ANTLRTreePrinter.g)
77*16467b97STreehugger Robot      $(JAVA) -cp $(location @antlr3_bootstrap//jar) org.antlr.Tool -fo $(RULEDIR)/main/java/org/antlr/grammar/v3 $(location :main/antlr3/org/antlr/grammar/v3/ANTLRv3.g)
78*16467b97STreehugger Robot      $(JAVA) -cp $(location @antlr3_bootstrap//jar) org.antlr.Tool -fo $(RULEDIR)/main/java/org/antlr/grammar/v3 $(location :main/antlr3/org/antlr/grammar/v3/ANTLRv3Tree.g)
79*16467b97STreehugger Robot      $(JAVA) -cp $(location @antlr3_bootstrap//jar) org.antlr.Tool -fo $(RULEDIR)/main/java/org/antlr/grammar/v3 $(location :main/antlr3/org/antlr/grammar/v3/ActionAnalysis.g)
80*16467b97STreehugger Robot      $(JAVA) -cp $(location @antlr3_bootstrap//jar) org.antlr.Tool -fo $(RULEDIR)/main/java/org/antlr/grammar/v3 $(location :main/antlr3/org/antlr/grammar/v3/ActionTranslator.g)
81*16467b97STreehugger Robot      $(JAVA) -cp $(location @antlr3_bootstrap//jar) org.antlr.Tool -fo $(RULEDIR)/main/java/org/antlr/grammar/v3 $(location :main/antlr3/org/antlr/grammar/v3/AssignTokenTypesWalker.g)
82*16467b97STreehugger Robot      $(JAVA) -cp $(location @antlr3_bootstrap//jar) org.antlr.Tool -fo $(RULEDIR)/main/java/org/antlr/grammar/v3 $(location :main/antlr3/org/antlr/grammar/v3/CodeGenTreeWalker.g)
83*16467b97STreehugger Robot      $(JAVA) -cp $(location @antlr3_bootstrap//jar) org.antlr.Tool -fo $(RULEDIR)/main/java/org/antlr/grammar/v3 $(location :main/antlr3/org/antlr/grammar/v3/DefineGrammarItemsWalker.g)
84*16467b97STreehugger Robot      $(JAVA) -cp $(location @antlr3_bootstrap//jar) org.antlr.Tool -fo $(RULEDIR)/main/java/org/antlr/grammar/v3 $(location :main/antlr3/org/antlr/grammar/v3/LeftRecursiveRuleWalker.g)
85*16467b97STreehugger Robot      $(JAVA) -cp $(location @antlr3_bootstrap//jar) org.antlr.Tool -fo $(RULEDIR)/main/java/org/antlr/grammar/v3 $(location :main/antlr3/org/antlr/grammar/v3/TreeToNFAConverter.g)
86*16467b97STreehugger Robot    """,
87*16467b97STreehugger Robot    toolchains = ["@bazel_tools//tools/jdk:current_host_java_runtime"],
88*16467b97STreehugger Robot    tools = ["@antlr3_bootstrap//jar"],
89*16467b97STreehugger Robot)
90*16467b97STreehugger Robot
91*16467b97STreehugger Robotjava_test(
92*16467b97STreehugger Robot    name = "tests",
93*16467b97STreehugger Robot    srcs = glob(["test/java/**/*.java"]),
94*16467b97STreehugger Robot    args = [
95*16467b97STreehugger Robot        "org.antlr.test.TestASTConstruction",
96*16467b97STreehugger Robot        "org.antlr.test.TestAttributes",
97*16467b97STreehugger Robot        "org.antlr.test.TestAutoAST",
98*16467b97STreehugger Robot        "org.antlr.test.TestBufferedTreeNodeStream",
99*16467b97STreehugger Robot        "org.antlr.test.TestCharDFAConversion",
100*16467b97STreehugger Robot        "org.antlr.test.TestCommonTokenStream",
101*16467b97STreehugger Robot        "org.antlr.test.TestCompositeGrammars",
102*16467b97STreehugger Robot        "org.antlr.test.TestDFAConversion",
103*16467b97STreehugger Robot        "org.antlr.test.TestDFAMatching",
104*16467b97STreehugger Robot        "org.antlr.test.TestFastQueue",
105*16467b97STreehugger Robot        "org.antlr.test.TestHeteroAST",
106*16467b97STreehugger Robot        "org.antlr.test.TestInterpretedLexing",
107*16467b97STreehugger Robot        "org.antlr.test.TestInterpretedParsing",
108*16467b97STreehugger Robot        "org.antlr.test.TestIntervalSet",
109*16467b97STreehugger Robot        "org.antlr.test.TestJavaCodeGeneration",
110*16467b97STreehugger Robot        "org.antlr.test.TestLeftRecursion",
111*16467b97STreehugger Robot        "org.antlr.test.TestLexer",
112*16467b97STreehugger Robot        "org.antlr.test.TestMessages",
113*16467b97STreehugger Robot        "org.antlr.test.TestNFAConstruction",
114*16467b97STreehugger Robot        "org.antlr.test.TestRewriteAST",
115*16467b97STreehugger Robot        "org.antlr.test.TestRewriteTemplates",
116*16467b97STreehugger Robot        "org.antlr.test.TestSemanticPredicateEvaluation",
117*16467b97STreehugger Robot        "org.antlr.test.TestSemanticPredicates",
118*16467b97STreehugger Robot        "org.antlr.test.TestSets",
119*16467b97STreehugger Robot        "org.antlr.test.TestSymbolDefinitions",
120*16467b97STreehugger Robot        "org.antlr.test.TestSyntacticPredicateEvaluation",
121*16467b97STreehugger Robot        "org.antlr.test.TestSyntaxErrors",
122*16467b97STreehugger Robot        "org.antlr.test.TestTemplates",
123*16467b97STreehugger Robot        "org.antlr.test.TestTokenRewriteStream",
124*16467b97STreehugger Robot        "org.antlr.test.TestTopologicalSort",
125*16467b97STreehugger Robot        "org.antlr.test.TestTreeGrammarRewriteAST",
126*16467b97STreehugger Robot        "org.antlr.test.TestTreeIterator",
127*16467b97STreehugger Robot        "org.antlr.test.TestTreeNodeStream",
128*16467b97STreehugger Robot        "org.antlr.test.TestTreeParsing",
129*16467b97STreehugger Robot        "org.antlr.test.TestTrees",
130*16467b97STreehugger Robot        "org.antlr.test.TestTreeWizard",
131*16467b97STreehugger Robot    ],
132*16467b97STreehugger Robot    javacopts = [
133*16467b97STreehugger Robot        "-Xep:JUnit4RunWithMissing:OFF",
134*16467b97STreehugger Robot    ],
135*16467b97STreehugger Robot    main_class = "org.junit.runner.JUnitCore",
136*16467b97STreehugger Robot    use_testrunner = False,
137*16467b97STreehugger Robot    visibility = ["//:__pkg__"],
138*16467b97STreehugger Robot    deps = [
139*16467b97STreehugger Robot        ":tool_lib",
140*16467b97STreehugger Robot        "//:java_runtime",
141*16467b97STreehugger Robot        "@hamcrest_core//jar",
142*16467b97STreehugger Robot        "@junit//jar",
143*16467b97STreehugger Robot        "@stringtemplate4",
144*16467b97STreehugger Robot    ],
145*16467b97STreehugger Robot)
146