Unverified Commit 0a2e5931 authored by Phillipp Schoppmann's avatar Phillipp Schoppmann Committed by GitHub

Fix build for Emscripten (#546)

Add back config_setting for WASM (no HAVE_SYSCALL_H)

Since there is no config_setting for Linux
(https://github.com/bazelbuild/bazel/issues/11107), Linux needs to be
the default case.
parent 3ba89765
......@@ -18,6 +18,12 @@ 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",
......@@ -25,7 +31,7 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
"-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",
......@@ -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",
......@@ -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",
......@@ -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 = [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment