File tree Expand file tree Collapse file tree 2 files changed +53
-3
lines changed Expand file tree Collapse file tree 2 files changed +53
-3
lines changed Original file line number Diff line number Diff line change @@ -28,9 +28,6 @@ def define_common_targets():
2828 srcs = ["src/regex.cpp" ] + glob ([
2929 "src/*_regex.cpp" ,
3030 ]),
31- deps = [
32- "fbsource//third-party/pcre2:pcre2-8" ,
33- ],
3431 exported_headers = subdir_glob ([
3532 ("include" , "pytorch/tokenizers/regex.h" ),
3633 ("include" , "pytorch/tokenizers/*_regex.h" ),
@@ -39,6 +36,7 @@ def define_common_targets():
3936 ":headers" ,
4037 ],
4138 exported_external_deps = [
39+ "pcre2" ,
4240 "re2" ,
4341 ],
4442 visibility = ["//pytorch/tokenizers/..." ],
Original file line number Diff line number Diff line change @@ -59,3 +59,55 @@ def define_common_targets():
5959 ":abseil" ,
6060 ],
6161 )
62+
63+ runtime .genrule (
64+ name = "config_h_generic" ,
65+ srcs = ["pcre2/src/config.h.generic" ],
66+ cmd = "cp $SRCS $OUT" ,
67+ out = "pcre2/src/config.h" ,
68+ )
69+ runtime .genrule (
70+ name = "pcre2_h_generic" ,
71+ srcs = ["pcre2/src/pcre2.h.generic" ],
72+ cmd = "cp $SRCS $OUT" ,
73+ out = "pcre2/src/pcre2.h" ,
74+ )
75+ runtime .genrule (
76+ name = "pcre2_chartables_c" ,
77+ srcs = ["pcre2/src/pcre2_chartables.c.dist" ],
78+ cmd = "cp $SRCS $OUT" ,
79+ out = "pcre2/src/pcre2_chartables.c" ,
80+ )
81+
82+ runtime .cxx_library (
83+ name = "pcre2" ,
84+ srcs = glob ([
85+ "pcre2/src/*.c" ,
86+ ]) + [
87+ ":pcre2_chartables_c" ,
88+ ],
89+ exported_headers = [
90+ ":pcre2_h_generic" ,
91+ ],
92+ headers = [
93+ ":config_h_generic" ,
94+ ] + glob ([
95+ "pcre2/src/*.h" ,
96+ ]),
97+ # Preprocessor flags from https://github.com/PCRE2Project/pcre2/blob/2e03e323339ab692640626f02f8d8d6f95bff9c6/BUILD.bazel#L23.
98+ preprocessor_flags = [
99+ "-DHAVE_CONFIG_H" ,
100+ "-DHAVE_MEMMOVE" ,
101+ "-DHAVE_STRERROR" ,
102+ "-DPCRE2_CODE_UNIT_WIDTH=8" ,
103+ "-DPCRE2_STATIC" ,
104+ "-DSUPPORT_PCRE2_8" ,
105+ "-DSUPPORT_UNICODE" ,
106+ ] + select ({
107+ "DEFAULT" : ["-DHAVE_UNISTD_H" ],
108+ "ovr_config//os:windows" : [],
109+ }),
110+ _is_external_target = True ,
111+ public_include_directories = ["pcre2" ],
112+ visibility = ["PUBLIC" ],
113+ )
You can’t perform that action at this time.
0 commit comments