summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Earhart <rob@vertex.ai>2018-01-05 11:31:31 -0800
committerAndreas Schuh <andreas.schuh.84@gmail.com>2018-01-07 10:40:06 +0000
commit6d1c363dde8a4277f7f363446a82b2188fd94608 (patch)
tree093c9a961c013355bf3fdb19e6bf621f1ee982b0
parent77592648e3f3be87d6c7123eb81cbad75f9aef5a (diff)
downloadgflags-6d1c363dde8a4277f7f363446a82b2188fd94608.tar.gz
gflags-6d1c363dde8a4277f7f363446a82b2188fd94608.tar.bz2
gflags-6d1c363dde8a4277f7f363446a82b2188fd94608.zip
Add Bazel-on-Windows support
-rw-r--r--BUILD6
-rw-r--r--bazel/gflags.bzl31
2 files changed, 29 insertions, 8 deletions
diff --git a/BUILD b/BUILD
index aa61563..0e7ccdd 100644
--- a/BUILD
+++ b/BUILD
@@ -6,7 +6,13 @@ licenses(["notice"])
exports_files(["src/gflags_completions.sh", "COPYING.txt"])
+config_setting(
+ name = "x64_windows",
+ values = {"cpu": "x64_windows"},
+)
+
load(":bazel/gflags.bzl", "gflags_sources", "gflags_library")
+
(hdrs, srcs) = gflags_sources(namespace=["gflags", "google"])
gflags_library(hdrs=hdrs, srcs=srcs, threads=0)
gflags_library(hdrs=hdrs, srcs=srcs, threads=1)
diff --git a/bazel/gflags.bzl b/bazel/gflags.bzl
index 7bf91cd..6d1ef6c 100644
--- a/bazel/gflags.bzl
+++ b/bazel/gflags.bzl
@@ -47,8 +47,14 @@ def gflags_sources(namespace=["google", "gflags"]):
"src/gflags_completions.cc",
"src/gflags_reporting.cc",
"src/mutex.h",
- "src/util.h"
- ]
+ "src/util.h",
+ ] + select({
+ "//:x64_windows": [
+ "src/windows_port.cc",
+ "src/windows_port.h",
+ ],
+ "//conditions:default": [],
+ })
return [hdrs, srcs]
# ------------------------------------------------------------------------------
@@ -64,19 +70,28 @@ def gflags_library(hdrs=[], srcs=[], threads=1):
"-DHAVE_SYS_TYPES_H",
"-DHAVE_INTTYPES_H",
"-DHAVE_SYS_STAT_H",
- "-DHAVE_UNISTD_H",
- "-DHAVE_FNMATCH_H",
"-DHAVE_STRTOLL",
"-DHAVE_STRTOQ",
- "-DHAVE_PTHREAD",
"-DHAVE_RWLOCK",
- ]
+ ] + select({
+ "//:x64_windows": [
+ "-DOS_WINDOWS",
+ ],
+ "//conditions:default": [
+ "-DHAVE_UNISTD_H",
+ "-DHAVE_FNMATCH_H",
+ "-DHAVE_PTHREAD",
+ ],
+ })
linkopts = []
if threads:
- linkopts.append("-lpthread")
+ linkopts = linkopts + select({
+ "//:x64_windows": [],
+ "//conditions:default": ["-lpthread"],
+ })
else:
name += "_nothreads"
- copts.append("-DNO_THREADS")
+ copts = copts + ["-DNO_THREADS"]
native.cc_library(
name = name,
hdrs = hdrs,