summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard O'Grady <rjogrady@google.com>2023-04-14 16:49:56 -0700
committerRichard O'Grady <rjogrady@google.com>2023-04-14 18:02:20 -0700
commitc9f9edf6d75bb065fa47468bf035e051a57bec7c (patch)
treee2826a57d890b2fe2db716766e423727a4ca6281
parent66a30b803fcdba99150cd6ce8f424a5c21c16054 (diff)
downloadsnappy-git-main.tar.gz
Fixes for Windows bazel build.HEADmain
Don't pass -Wno-sign-compare on Windows. Add a #define HAVE_WINDOWS_H if _WIN32 is defined. Don't assume sys/uio.h is available on Windows. PiperOrigin-RevId: 524416809
-rw-r--r--.bazelrc (renamed from opensource/.bazelrc)0
-rw-r--r--BUILD.bazel (renamed from opensource/BUILD.bazel)19
-rw-r--r--WORKSPACE (renamed from opensource/WORKSPACE)0
3 files changed, 15 insertions, 4 deletions
diff --git a/opensource/.bazelrc b/.bazelrc
index 3843446..3843446 100644
--- a/opensource/.bazelrc
+++ b/.bazelrc
diff --git a/opensource/BUILD.bazel b/BUILD.bazel
index 1c60d28..97c9f3a 100644
--- a/opensource/BUILD.bazel
+++ b/BUILD.bazel
@@ -32,6 +32,11 @@ licenses(["notice"])
SNAPPY_VERSION = (1, 1, 10)
+config_setting(
+ name = "windows",
+ constraint_values = ["@platforms//os:windows"],
+)
+
cc_library(
name = "config",
hdrs = ["config.h"],
@@ -64,9 +69,11 @@ cc_library(
"snappy.h",
"snappy-sinksource.h",
],
- copts = [
+ copts = select({
+ ":windows": [],
+ "//conditions:default": [
"-Wno-sign-compare",
- ],
+ ]}),
deps = [
":config",
":snappy-stubs-internal",
@@ -153,6 +160,10 @@ genrule(
# endif
#endif
+#if defined(_WIN32) && !defined(HAVE_WINDOWS_H)
+#define HAVE_WINDOWS_H 1
+#endif
+
#ifdef __has_include
# if !defined(HAVE_BYTESWAP_H) && __has_include(<byteswap.h>)
# define HAVE_BYTESWAP_H 1
@@ -189,9 +200,9 @@ genrule(
name = "snappy_stubs_public_h",
srcs = ["snappy-stubs-public.h.in"],
outs = ["snappy-stubs-public.h"],
- # Define HAVE_SYS_UIO_H_01 to 1; we just assume it's available.
+ # Assume sys/uio.h is available on non-Windows.
# Set the version numbers.
- cmd = ("""sed -e 's/$${\\(.*\\)_01}/1/g' \
+ 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' \
diff --git a/opensource/WORKSPACE b/WORKSPACE
index 7e60888..7e60888 100644
--- a/opensource/WORKSPACE
+++ b/WORKSPACE