File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Bazel
2+
3+ on :
4+ push :
5+ pull_request :
6+
7+ jobs :
8+ build :
9+ runs-on : ubuntu-latest
10+
11+ steps :
12+ - name : Check out repository code
13+ uses : actions/checkout@v6
14+ with :
15+ submodules : recursive
16+
17+ - name : Test
18+ run : npx --yes @bazel/bazelisk test //:bazel_smoke_test
Original file line number Diff line number Diff line change 1+ load ("@rules_cc//cc:defs.bzl" , "cc_library" , "cc_test" )
2+
3+ package (default_visibility = ["//visibility:public" ])
4+
5+ cc_library (
6+ name = "limonp" ,
7+ hdrs = glob (["deps/limonp/include/limonp/**/*.hpp" ]),
8+ includes = ["deps/limonp/include" ],
9+ )
10+
11+ filegroup (
12+ name = "dict" ,
13+ srcs = glob (["dict/**" ]),
14+ )
15+
16+ cc_library (
17+ name = "cppjieba" ,
18+ hdrs = glob (["include/cppjieba/**/*.hpp" ]),
19+ includes = ["include" ],
20+ deps = [":limonp" ],
21+ )
22+
23+ cc_test (
24+ name = "bazel_smoke_test" ,
25+ srcs = ["test/bazel_smoke_test.cpp" ],
26+ data = [":dict" ],
27+ deps = [":cppjieba" ],
28+ )
Original file line number Diff line number Diff line change 1+ module (
2+ name = "cppjieba" ,
3+ version = "5.6.7" ,
4+ )
5+
6+ bazel_dep (name = "rules_cc" , version = "0.2.17" )
Original file line number Diff line number Diff line change 1+ #include " cppjieba/Jieba.hpp"
2+
3+ #include < cstdlib>
4+ #include < iostream>
5+ #include < string>
6+ #include < vector>
7+
8+ namespace {
9+
10+ std::string RunfilePath (const std::string& relative_path) {
11+ const char * test_srcdir = std::getenv (" TEST_SRCDIR" );
12+ const char * test_workspace = std::getenv (" TEST_WORKSPACE" );
13+ if (test_srcdir == NULL || test_workspace == NULL ) {
14+ return relative_path;
15+ }
16+
17+ return std::string (test_srcdir) + " /" + test_workspace + " /" + relative_path;
18+ }
19+
20+ } // namespace
21+
22+ int main () {
23+ cppjieba::Jieba jieba (
24+ RunfilePath (" dict/jieba.dict.utf8" ),
25+ RunfilePath (" dict/hmm_model.utf8" ),
26+ RunfilePath (" dict/user.dict.utf8" ),
27+ RunfilePath (" dict/idf.utf8" ),
28+ RunfilePath (" dict/stop_words.utf8" ));
29+
30+ std::vector<std::string> words;
31+ jieba.Cut (" 南京市长江大桥" , words);
32+ if (words.empty ()) {
33+ std::cerr << " Expected cppjieba to segment the smoke-test sentence.\n " ;
34+ return 1 ;
35+ }
36+
37+ return 0 ;
38+ }
You can’t perform that action at this time.
0 commit comments