Skip to content

Commit

Permalink
Fixes for Windows bazel build.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rjogrady committed Apr 15, 2023
1 parent 66a30b8 commit c9f9edf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
File renamed without changes.
19 changes: 15 additions & 4 deletions opensource/BUILD.bazel → BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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' \
Expand Down
File renamed without changes.

0 comments on commit c9f9edf

Please sign in to comment.