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.
This commit is contained in:
parent
3ba8976592
commit
0a2e5931bd
@ -18,6 +18,12 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
|
|||||||
gendir = "$(GENDIR)"
|
gendir = "$(GENDIR)"
|
||||||
src_windows = "src/windows"
|
src_windows = "src/windows"
|
||||||
|
|
||||||
|
# Config setting for WebAssembly target.
|
||||||
|
native.config_setting(
|
||||||
|
name = "wasm",
|
||||||
|
values = {"cpu": "wasm"},
|
||||||
|
)
|
||||||
|
|
||||||
common_copts = [
|
common_copts = [
|
||||||
"-DGLOG_BAZEL_BUILD",
|
"-DGLOG_BAZEL_BUILD",
|
||||||
"-DHAVE_STDINT_H",
|
"-DHAVE_STDINT_H",
|
||||||
@ -25,7 +31,7 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
|
|||||||
"-DHAVE_UNWIND_H",
|
"-DHAVE_UNWIND_H",
|
||||||
] + (["-DHAVE_LIB_GFLAGS"] if with_gflags else [])
|
] + (["-DHAVE_LIB_GFLAGS"] if with_gflags else [])
|
||||||
|
|
||||||
linux_or_darwin_copts = [
|
wasm_copts = [
|
||||||
# Disable warnings that exists in glog.
|
# Disable warnings that exists in glog.
|
||||||
"-Wno-sign-compare",
|
"-Wno-sign-compare",
|
||||||
"-Wno-unused-function",
|
"-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.
|
# Allows src/logging.cc to determine the host name.
|
||||||
"-DHAVE_SYS_UTSNAME_H",
|
"-DHAVE_SYS_UTSNAME_H",
|
||||||
# For src/utilities.cc.
|
# For src/utilities.cc.
|
||||||
"-DHAVE_SYS_SYSCALL_H",
|
|
||||||
"-DHAVE_SYS_TIME_H",
|
"-DHAVE_SYS_TIME_H",
|
||||||
# Enable dumping stacktrace upon sigaction.
|
# Enable dumping stacktrace upon sigaction.
|
||||||
"-DHAVE_SIGACTION",
|
"-DHAVE_SIGACTION",
|
||||||
@ -48,6 +53,11 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
|
|||||||
"-I%s/glog_internal" % gendir,
|
"-I%s/glog_internal" % gendir,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
linux_or_darwin_copts = wasm_copts + [
|
||||||
|
# For src/utilities.cc.
|
||||||
|
"-DHAVE_SYS_SYSCALL_H",
|
||||||
|
]
|
||||||
|
|
||||||
freebsd_only_copts = [
|
freebsd_only_copts = [
|
||||||
# Enable declaration of _Unwind_Backtrace
|
# Enable declaration of _Unwind_Backtrace
|
||||||
"-D_GNU_SOURCE",
|
"-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:windows": common_copts + windows_only_copts,
|
||||||
"@bazel_tools//src/conditions:darwin": common_copts + linux_or_darwin_copts + darwin_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,
|
"@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,
|
"//conditions:default": common_copts + linux_or_darwin_copts,
|
||||||
}),
|
}),
|
||||||
deps = [
|
deps = [
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user