Skip to content

Commit 6b1e91c

Browse files
committed
Update pcre target
1 parent 1a0a8a5 commit 6b1e91c

File tree

2 files changed

+47
-55
lines changed

2 files changed

+47
-55
lines changed

targets.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ def define_common_targets():
3232
("include", "pytorch/tokenizers/regex.h"),
3333
("include", "pytorch/tokenizers/*_regex.h"),
3434
]),
35+
deps = [
36+
"fbsource//third-party/pcre2:pcre2-8",
37+
],
3538
exported_deps = [
3639
":headers",
3740
],

third-party/targets.bzl

Lines changed: 44 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -60,65 +60,54 @@ def define_common_targets():
6060
],
6161
)
6262

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+
6382
runtime.cxx_library(
6483
name = "pcre2",
65-
srcs = [
66-
"src/pcre2_auto_possess.c",
67-
"src/pcre2_chkdint.c",
68-
"src/pcre2_compile.c",
69-
"src/pcre2_compile_cgroup.c",
70-
"src/pcre2_compile_class.c",
71-
"src/pcre2_config.c",
72-
"src/pcre2_context.c",
73-
"src/pcre2_convert.c",
74-
"src/pcre2_dfa_match.c",
75-
"src/pcre2_error.c",
76-
"src/pcre2_extuni.c",
77-
"src/pcre2_find_bracket.c",
78-
"src/pcre2_jit_compile.c",
79-
"src/pcre2_maketables.c",
80-
"src/pcre2_match.c",
81-
"src/pcre2_match_data.c",
82-
"src/pcre2_match_next.c",
83-
"src/pcre2_newline.c",
84-
"src/pcre2_ord2utf.c",
85-
"src/pcre2_pattern_info.c",
86-
"src/pcre2_script_run.c",
87-
"src/pcre2_serialize.c",
88-
"src/pcre2_string_utils.c",
89-
"src/pcre2_study.c",
90-
"src/pcre2_substitute.c",
91-
"src/pcre2_substring.c",
92-
"src/pcre2_tables.c",
93-
"src/pcre2_ucd.c",
94-
"src/pcre2_valid_utf.c",
95-
"src/pcre2_xclass.c",
96-
"src/pcre2_chartables.c",
84+
srcs = glob([
85+
"pcre2/src/*.c",
86+
]) + [
87+
":pcre2_chartables_c",
9788
],
98-
headers = [
99-
"src/pcre2.h",
100-
"src/pcre2_compile.h",
101-
"src/pcre2_internal.h",
102-
"src/pcre2_intmodedep.h",
103-
"src/pcre2_jit_match_inc.h",
104-
"src/pcre2_jit_misc_inc.h",
105-
"src/pcre2_printint_inc.h",
106-
"src/pcre2_ucp.h",
107-
"src/pcre2_ucptables_inc.h",
108-
"src/pcre2_util.h",
89+
exported_headers = [
90+
":pcre2_h_generic",
10991
],
110-
header_namespace = "src",
111-
defines = [
112-
"HAVE_CONFIG_H",
113-
"HAVE_MEMMOVE",
114-
"HAVE_STRERROR",
115-
"PCRE2_CODE_UNIT_WIDTH=8",
116-
"PCpRE2_STATIC",
117-
"SUPPORT_PCRE2_8",
118-
"SUPPORT_UNICODE",
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",
119106
] + select({
120-
"DEFAULT": ["HAVE_UNISTD_H"],
121-
"WINDOWS": [],
107+
"DEFAULT": ["-DHAVE_UNISTD_H"],
108+
"ovr_config//os:windows": [],
122109
}),
110+
_is_external_target = True,
111+
public_include_directories = ["pcre2"],
123112
visibility = ["PUBLIC"],
124-
)
113+
)

0 commit comments

Comments
 (0)