Import changes

PiperOrigin-RevId: 913030038
This commit is contained in:
Danila Kutenin
2026-05-09 18:33:57 +00:00
parent 8fe84c01c0
commit f50b387b42
9 changed files with 169 additions and 38 deletions

View File

@@ -26,11 +26,19 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
exports_files(["COPYING"])
exports_files([
"COPYING",
"COPYING.notestdata",
])
SNAPPY_VERSION = (1, 2, 2)
@@ -54,8 +62,10 @@ cc_library(
name = "snappy-stubs-internal",
srcs = ["snappy-stubs-internal.cc"],
hdrs = ["snappy-stubs-internal.h"],
deps = [
implementation_deps = [
":config",
],
deps = [
":snappy-stubs-public",
],
)
@@ -77,8 +87,10 @@ cc_library(
"-Wno-sign-compare",
],
}),
deps = [
implementation_deps = [
":config",
],
deps = [
":snappy-stubs-internal",
":snappy-stubs-public",
],
@@ -117,7 +129,7 @@ cc_test(
deps = [
":snappy",
":snappy-test",
"//third_party/benchmark:benchmark_main",
"@com_google_benchmark//:benchmark_main",
],
)
@@ -130,15 +142,15 @@ cc_test(
deps = [
":snappy",
":snappy-test",
"//third_party/googletest:gtest_main",
"@com_google_googletest//:gtest_main",
],
)
# Generate a config.h similar to what cmake would produce.
genrule(
write_file(
name = "config_h",
outs = ["config.h"],
cmd = """cat <<EOF >$@
out = "config.h",
content = """\
#define HAVE_STDDEF_H 1
#define HAVE_STDINT_H 1
#ifdef __has_builtin
@@ -195,19 +207,17 @@ genrule(
# define SNAPPY_IS_BIG_ENDIAN 1
# endif
#endif
EOF
""",
""".splitlines(),
)
genrule(
expand_template(
name = "snappy_stubs_public_h",
srcs = ["snappy-stubs-public.h.in"],
outs = ["snappy-stubs-public.h"],
# Assume sys/uio.h is available on non-Windows.
# Set the version numbers.
cmd = ("""sed -e 's/$${HAVE_SYS_UIO_H_01}/!_WIN32/g' \
-e 's/$${PROJECT_VERSION_MAJOR}/%d/g' \
-e 's/$${PROJECT_VERSION_MINOR}/%d/g' \
-e 's/$${PROJECT_VERSION_PATCH}/%d/g' \
$< >$@""" % SNAPPY_VERSION),
out = "snappy-stubs-public.h",
substitutions = {
"${HAVE_SYS_UIO_H_01}": "!_WIN32",
"${PROJECT_VERSION_MAJOR}": str(SNAPPY_VERSION[0]),
"${PROJECT_VERSION_MINOR}": str(SNAPPY_VERSION[1]),
"${PROJECT_VERSION_PATCH}": str(SNAPPY_VERSION[2]),
},
template = "snappy-stubs-public.h.in",
)