| 1 |
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test") |
| 2 |
|
| 3 |
package(default_visibility = ["//visibility:public"]) |
| 4 |
|
| 5 |
filegroup( |
| 6 |
name = "config", |
| 7 |
srcs = glob(["data/config/*.json"]), |
| 8 |
) |
| 9 |
|
| 10 |
filegroup( |
| 11 |
name = "resources", |
| 12 |
srcs = [ |
| 13 |
"//plugins/jieba/deps/cppjieba:dict", |
| 14 |
":jieba_merged_dict", |
| 15 |
], |
| 16 |
) |
| 17 |
|
| 18 |
filegroup( |
| 19 |
name = "testcases", |
| 20 |
srcs = ["tests/data/jieba_comparison_testcases.json"], |
| 21 |
) |
| 22 |
|
| 23 |
cc_binary( |
| 24 |
name = "opencc-jieba", |
| 25 |
srcs = [ |
| 26 |
"include/JiebaSegmentation.hpp", |
| 27 |
"src/JiebaSegmentation.cpp", |
| 28 |
"src/JiebaSegmentationPlugin.cpp", |
| 29 |
], |
| 30 |
copts = [ |
| 31 |
"-Iplugins/jieba/include", |
| 32 |
"-Isrc", |
| 33 |
], |
| 34 |
defines = ["OPENCC_PLUGIN_BUILD"], |
| 35 |
includes = ["include"], |
| 36 |
linkopts = select({ |
| 37 |
"@platforms//os:macos": ["-Wl,-S"], |
| 38 |
"@platforms//os:windows": [], |
| 39 |
"//conditions:default": ["-Wl,-s"], |
| 40 |
}), |
| 41 |
linkshared = True, |
| 42 |
deps = [ |
| 43 |
"//plugins/jieba/deps/cppjieba:cppjieba", |
| 44 |
"//src:common_lib", |
| 45 |
"//src:exception_lib", |
| 46 |
"//src:marisa_dict_lib", |
| 47 |
"//src:plugin_api_lib", |
| 48 |
"//src:segmentation_lib", |
| 49 |
"//src:segments_lib", |
| 50 |
"//src:utf8_util_lib", |
| 51 |
], |
| 52 |
) |
| 53 |
|
| 54 |
genrule( |
| 55 |
name = "opencc_jieba_windows_zig", |
| 56 |
srcs = [ |
| 57 |
"//deps/marisa-0.3.1:all_files", |
| 58 |
"//plugins/jieba/deps/cppjieba:all_files", |
| 59 |
"//src:all_files", |
| 60 |
"include/JiebaSegmentation.hpp", |
| 61 |
"src/JiebaSegmentation.cpp", |
| 62 |
"src/JiebaSegmentationPlugin.cpp", |
| 63 |
], |
| 64 |
outs = ["windows-x64/opencc-jieba.dll"], |
| 65 |
cmd = "ZIG=$(ZIG_BIN) bash $(location //scripts:build_jieba_windows_zig) $@", |
| 66 |
tags = ["manual"], |
| 67 |
tools = ["//scripts:build_jieba_windows_zig"], |
| 68 |
toolchains = ["@rules_zig//zig:toolchain_type"], |
| 69 |
) |
| 70 |
|
| 71 |
genrule( |
| 72 |
name = "jieba_merged_dict", |
| 73 |
srcs = [ |
| 74 |
"//plugins/jieba/deps/cppjieba:dict/jieba.dict.utf8", |
| 75 |
"//plugins/jieba/deps/cppjieba:dict/user.dict.utf8", |
| 76 |
], |
| 77 |
outs = ["jieba_dict/jieba_merged.ocd2"], |
| 78 |
cmd = "$(location //src/tools:dict_converter) --from cppjieba_utf8 --to ocd2 --input $(location //plugins/jieba/deps/cppjieba:dict/jieba.dict.utf8) --input $(location //plugins/jieba/deps/cppjieba:dict/user.dict.utf8) --output $@", |
| 79 |
tools = ["//src/tools:dict_converter"], |
| 80 |
) |
| 81 |
|
| 82 |
cc_test( |
| 83 |
name = "jieba_plugin_integration_test", |
| 84 |
srcs = ["tests/JiebaPluginIntegrationTest.cpp"], |
| 85 |
data = [ |
| 86 |
":config", |
| 87 |
":opencc-jieba", |
| 88 |
":resources", |
| 89 |
":testcases", |
| 90 |
"//data/dictionary:binary_dictionaries", |
| 91 |
"//src/tools:command_line", |
| 92 |
], |
| 93 |
defines = ["BAZEL"], |
| 94 |
deps = [ |
| 95 |
"//test:portable_util_lib", |
| 96 |
"@bazel_tools//tools/cpp/runfiles", |
| 97 |
"@googletest//:gtest_main", |
| 98 |
"//deps/rapidjson-1.1.0:rapidjson", |
| 99 |
], |
| 100 |
) |