blob: 5231327600ae51d8a46bd0f5f2bc494acb732131 [file] [log] [blame]
# Bazel build rules for Fuzzyc.
load("@antlr4_deps//:requirements.bzl", "requirement")
package(default_visibility = [
"//visibility:public",
])
ANTLR4_VERSION = "4.11.1"
genrule(
name = "fuzzyc_cc_module_sources",
srcs = [
"Common.g4",
"Module.g4",
"ModuleLex.g4",
"Action.g4",
],
outs = [
"ModuleParser.cpp",
"ModuleParser.h",
"ModuleLexer.cpp",
"ModuleLexer.h",
"ModuleListener.h",
"ModuleListener.cpp",
"ModuleBaseListener.cpp",
"ModuleBaseListener.h",
],
cmd = " ".join([
"$(locations @antlr4_deps_antlr4_tools//:rules_python_wheel_entry_point_antlr4) -v ",
ANTLR4_VERSION,
" -o $(RULEDIR) -Dlanguage=Cpp -package fuzzyc_cc_module $(SRCS);",
"find $(RULEDIR) \\( -name *.cpp -o -name *.h \\) -exec cp -n {} $(RULEDIR) \\;",
]),
local = True,
tools = [
requirement("antlr4-tools"),
"@antlr4_deps_antlr4_tools//:rules_python_wheel_entry_point_antlr4",
],
)
genrule(
name = "fuzzyc_cc_function_sources",
srcs = [
"Common.g4",
"Function.g4",
"ModuleLex.g4",
"Action.g4",
],
outs = [
"FunctionParser.cpp",
"FunctionParser.h",
"FunctionLexer.cpp",
"FunctionLexer.h",
"FunctionListener.h",
"FunctionListener.cpp",
"FunctionBaseListener.cpp",
"FunctionBaseListener.h",
],
cmd = " ".join([
"$(locations @antlr4_deps_antlr4_tools//:rules_python_wheel_entry_point_antlr4) -v ",
ANTLR4_VERSION,
" -o $(RULEDIR) -Dlanguage=Cpp -package fuzzyc_cc_function $(SRCS);",
"find $(RULEDIR) \\( -name *.cpp -o -name *.h \\) -exec cp -n {} $(RULEDIR) \\;",
]),
local = True,
tools = [
requirement("antlr4-tools"),
"@antlr4_deps_antlr4_tools//:rules_python_wheel_entry_point_antlr4",
],
)
cc_library(
name = "fuzzyc_cc_module",
srcs = [
"ModuleBaseListener.cpp",
"ModuleLexer.cpp",
"ModuleListener.cpp",
"ModuleParser.cpp",
],
hdrs = [
"ModuleBaseListener.h",
"ModuleLexer.h",
"ModuleListener.h",
"ModuleParser.h",
],
linkstatic = 1,
deps = [
":fuzzyc_cc_module_sources",
"@antlr4_runtimes//:cpp",
],
)
cc_library(
name = "fuzzyc_cc_function",
srcs = [
"FunctionBaseListener.cpp",
"FunctionLexer.cpp",
"FunctionListener.cpp",
"FunctionParser.cpp",
],
hdrs = [
"FunctionBaseListener.h",
"FunctionLexer.h",
"FunctionListener.h",
"FunctionParser.h",
],
linkstatic = 1,
deps = [
":fuzzyc_cc_function_sources",
"@antlr4_runtimes//:cpp",
],
)
cc_test(
name = "fuzzyc_cc_test",
srcs = ["tests/fuzzyc_cc_test.cc"],
data = ["tests/testdata"],
deps = [
":fuzzyc_cc_function",
":fuzzyc_cc_module",
"@antlr4_runtimes//:cpp",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
"@com_google_googletest//:gtest_main",
],
)