Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 62 additions & 57 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,47 @@ copy_file(
out = "src/pcre2_chartables.c",
)

LOCAL_DEFINES = [
"HAVE_CONFIG_H",
"HAVE_MEMMOVE",
"HAVE_STRERROR",
"PCRE2_CODE_UNIT_WIDTH=8",
"PCRE2_STATIC",
"SUPPORT_PCRE2_8",
"SUPPORT_UNICODE",
] + select({
"@platforms//os:windows": [],
"//conditions:default": ["HAVE_UNISTD_H"],
})

# Workaround for a Bazel quirk. It is extremely strict about the #include path
# used for internal headers. We have our headers inside src/, but we #include
# them as '#include "pcre2_internal.h"', assuming that src/ is added to the
# compiler's include path. Unfortunately, that violates the conventions used by
# Bazel.
#
# This is a workaround. Note that we can't use the "include = [...]" property
# to add the src/ directory, since that pollutes the include path for projects
# depending on PCRE2 (we must not make our config.h file visible to consumers
# of PCRE2).
cc_library(
name = "pcre2_internal_headers",
hdrs = [
"src/pcre2_compile.h",
"src/pcre2_internal.h",
"src/pcre2_intmodedep.h",
"src/pcre2_jit_match_inc.h",
"src/pcre2_jit_misc_inc.h",
"src/pcre2_printint_inc.h",
"src/pcre2_ucp.h",
"src/pcre2_ucptables_inc.h",
"src/pcre2_util.h",
":config_h_generic",
],
strip_include_prefix = "src",
visibility = ["//visibility:private"],
)

cc_library(
name = "pcre2",
srcs = [
Expand All @@ -36,15 +77,12 @@ cc_library(
"src/pcre2_extuni.c",
"src/pcre2_find_bracket.c",
"src/pcre2_jit_compile.c",
"src/pcre2_jit_match_inc.h",
"src/pcre2_jit_misc_inc.h",
"src/pcre2_maketables.c",
"src/pcre2_match.c",
"src/pcre2_match_data.c",
"src/pcre2_newline.c",
"src/pcre2_ord2utf.c",
"src/pcre2_pattern_info.c",
"src/pcre2_printint_inc.h",
"src/pcre2_script_run.c",
"src/pcre2_serialize.c",
"src/pcre2_string_utils.c",
Expand All @@ -56,48 +94,20 @@ cc_library(
"src/pcre2_valid_utf.c",
"src/pcre2_xclass.c",
":pcre2_chartables_c",
"src/pcre2_compile.h",
"src/pcre2_internal.h",
"src/pcre2_intmodedep.h",
"src/pcre2_ucp.h",
"src/pcre2_ucptables_inc.h",
"src/pcre2_util.h",
":config_h_generic",
],
textual_hdrs = [
],
hdrs = [
":pcre2_h_generic",
],
local_defines = [
"HAVE_CONFIG_H",
"HAVE_MEMMOVE",
"PCRE2_CODE_UNIT_WIDTH=8",
"PCRE2_STATIC",
"SUPPORT_UNICODE",
],
includes = ["src"],
hdrs = [":pcre2_h_generic"],
implementation_deps = [":pcre2_internal_headers"],
local_defines = LOCAL_DEFINES,
strip_include_prefix = "src",
visibility = ["//visibility:public"],
)

cc_library(
name = "pcre2-posix",
srcs = [
"src/pcre2posix.c",
":config_h_generic",
],
hdrs = [
"src/pcre2posix.h",
],
local_defines = [
"HAVE_CONFIG_H",
"HAVE_MEMMOVE",
"PCRE2_CODE_UNIT_WIDTH=8",
"PCRE2_STATIC",
"SUPPORT_UNICODE",
],
includes = ["src"],
srcs = ["src/pcre2posix.c"],
hdrs = ["src/pcre2posix.h"],
implementation_deps = [":pcre2_internal_headers"],
local_defines = LOCAL_DEFINES,
strip_include_prefix = "src",
visibility = ["//visibility:public"],
deps = [":pcre2"],
Expand Down Expand Up @@ -127,27 +137,19 @@ cc_library(

cc_binary(
name = "pcre2test",
srcs = [
"src/pcre2test.c",
":config_h_generic",
],
local_defines = [
"HAVE_CONFIG_H",
"HAVE_MEMMOVE",
"HAVE_STRERROR",
"PCRE2_STATIC",
"SUPPORT_UNICODE",
"SUPPORT_PCRE2_8",
] + select({
"@platforms//os:windows": [],
"//conditions:default": ["HAVE_UNISTD_H"],
}),
srcs = ["src/pcre2test.c"],
linkopts = select({
"@platforms//os:windows": ["-STACK:2500000"],
"//conditions:default": [],
}),
local_defines = LOCAL_DEFINES,
visibility = ["//visibility:public"],
deps = [":pcre2test_dotc_headers", ":pcre2", ":pcre2-posix"],
deps = [
":pcre2",
":pcre2-posix",
":pcre2_internal_headers",
":pcre2test_dotc_headers",
],
)

filegroup(
Expand All @@ -157,6 +159,7 @@ filegroup(

native_test(
name = "pcre2_test",
size = "small",
src = select({
"@platforms//os:windows": "RunTest.bat",
"//conditions:default": "RunTest",
Expand All @@ -165,6 +168,8 @@ native_test(
"@platforms//os:windows": "RunTest.bat",
"//conditions:default": "RunTest",
}),
data = [":pcre2test", ":testdata"],
size = "small",
)
data = [
":pcre2test",
":testdata",
],
)