File tree 2 files changed +53
-3
lines changed
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():
28
28
srcs = ["src/regex.cpp" ] + glob ([
29
29
"src/*_regex.cpp" ,
30
30
]),
31
- deps = [
32
- "fbsource//third-party/pcre2:pcre2-8" ,
33
- ],
34
31
exported_headers = subdir_glob ([
35
32
("include" , "pytorch/tokenizers/regex.h" ),
36
33
("include" , "pytorch/tokenizers/*_regex.h" ),
@@ -39,6 +36,7 @@ def define_common_targets():
39
36
":headers" ,
40
37
],
41
38
exported_external_deps = [
39
+ "pcre2" ,
42
40
"re2" ,
43
41
],
44
42
visibility = ["//pytorch/tokenizers/..." ],
Original file line number Diff line number Diff line change @@ -59,3 +59,55 @@ def define_common_targets():
59
59
":abseil" ,
60
60
],
61
61
)
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