Skip to content

Commit

Permalink
Fix build for Emscripten (#546)
Browse files Browse the repository at this point in the history
Add back config_setting for WASM (no HAVE_SYSCALL_H)

Since there is no config_setting for Linux
(bazelbuild/bazel#11107), Linux needs to be
the default case.
  • Loading branch information
schoppmp committed May 13, 2020
1 parent 3ba8976 commit 0a2e593
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions bazel/glog.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
gendir = "$(GENDIR)"
src_windows = "src/windows"

# Config setting for WebAssembly target.
native.config_setting(
name = "wasm",
values = {"cpu": "wasm"},
)

common_copts = [
"-DGLOG_BAZEL_BUILD",
"-DHAVE_STDINT_H",
"-DHAVE_STRING_H",
"-DHAVE_UNWIND_H",
] + (["-DHAVE_LIB_GFLAGS"] if with_gflags else [])

linux_or_darwin_copts = [
wasm_copts = [
# Disable warnings that exists in glog.
"-Wno-sign-compare",
"-Wno-unused-function",
Expand All @@ -38,7 +44,6 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
# Allows src/logging.cc to determine the host name.
"-DHAVE_SYS_UTSNAME_H",
# For src/utilities.cc.
"-DHAVE_SYS_SYSCALL_H",
"-DHAVE_SYS_TIME_H",
# Enable dumping stacktrace upon sigaction.
"-DHAVE_SIGACTION",
Expand All @@ -48,6 +53,11 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
"-I%s/glog_internal" % gendir,
]

linux_or_darwin_copts = wasm_copts + [
# For src/utilities.cc.
"-DHAVE_SYS_SYSCALL_H",
]

freebsd_only_copts = [
# Enable declaration of _Unwind_Backtrace
"-D_GNU_SOURCE",
Expand Down Expand Up @@ -105,6 +115,7 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
"@bazel_tools//src/conditions:windows": common_copts + windows_only_copts,
"@bazel_tools//src/conditions:darwin": common_copts + linux_or_darwin_copts + darwin_only_copts,
"@bazel_tools//src/conditions:freebsd": common_copts + linux_or_darwin_copts + freebsd_only_copts,
":wasm": common_copts + wasm_copts,
"//conditions:default": common_copts + linux_or_darwin_copts,
}),
deps = [
Expand Down

1 comment on commit 0a2e593

@kloczek
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance to make new release? :)

Please sign in to comment.