Skip to content

Commit c9f9edf

Browse files
committed
Fixes for Windows bazel build.
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
1 parent 66a30b8 commit c9f9edf

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed
File renamed without changes.

opensource/BUILD.bazel renamed to BUILD.bazel

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ licenses(["notice"])
3232

3333
SNAPPY_VERSION = (1, 1, 10)
3434

35+
config_setting(
36+
name = "windows",
37+
constraint_values = ["@platforms//os:windows"],
38+
)
39+
3540
cc_library(
3641
name = "config",
3742
hdrs = ["config.h"],
@@ -64,9 +69,11 @@ cc_library(
6469
"snappy.h",
6570
"snappy-sinksource.h",
6671
],
67-
copts = [
72+
copts = select({
73+
":windows": [],
74+
"//conditions:default": [
6875
"-Wno-sign-compare",
69-
],
76+
]}),
7077
deps = [
7178
":config",
7279
":snappy-stubs-internal",
@@ -153,6 +160,10 @@ genrule(
153160
# endif
154161
#endif
155162
163+
#if defined(_WIN32) && !defined(HAVE_WINDOWS_H)
164+
#define HAVE_WINDOWS_H 1
165+
#endif
166+
156167
#ifdef __has_include
157168
# if !defined(HAVE_BYTESWAP_H) && __has_include(<byteswap.h>)
158169
# define HAVE_BYTESWAP_H 1
@@ -189,9 +200,9 @@ genrule(
189200
name = "snappy_stubs_public_h",
190201
srcs = ["snappy-stubs-public.h.in"],
191202
outs = ["snappy-stubs-public.h"],
192-
# Define HAVE_SYS_UIO_H_01 to 1; we just assume it's available.
203+
# Assume sys/uio.h is available on non-Windows.
193204
# Set the version numbers.
194-
cmd = ("""sed -e 's/$${\\(.*\\)_01}/1/g' \
205+
cmd = ("""sed -e 's/$${HAVE_SYS_UIO_H_01}/!_WIN32/g' \
195206
-e 's/$${PROJECT_VERSION_MAJOR}/%d/g' \
196207
-e 's/$${PROJECT_VERSION_MINOR}/%d/g' \
197208
-e 's/$${PROJECT_VERSION_PATCH}/%d/g' \
File renamed without changes.

0 commit comments

Comments
 (0)