glog.BUILD 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. licenses(["notice"])
  2. cc_library(
  3. name = "glog",
  4. srcs = [
  5. "src/base/commandlineflags.h",
  6. "src/base/googleinit.h",
  7. "src/demangle.cc",
  8. "src/logging.cc",
  9. "src/raw_logging.cc",
  10. "src/symbolize.cc",
  11. "src/utilities.cc",
  12. "src/vlog_is_on.cc",
  13. ],
  14. hdrs = [
  15. "raw_logging_h",
  16. "src/base/mutex.h",
  17. "src/demangle.h",
  18. "src/symbolize.h",
  19. "src/utilities.h",
  20. "src/glog/log_severity.h",
  21. ":config_h",
  22. ":logging_h",
  23. ":stl_logging_h",
  24. ":vlog_is_on_h",
  25. ],
  26. copts = [
  27. # Disable warnings that exists in glog
  28. "-Wno-sign-compare",
  29. "-Wno-unused-local-typedefs",
  30. # Inject google namespace as "google"
  31. "-D_START_GOOGLE_NAMESPACE_='namespace google {'",
  32. "-D_END_GOOGLE_NAMESPACE_='}'",
  33. "-DGOOGLE_NAMESPACE='google'",
  34. # Allows src/base/mutex.h to include pthread.h.
  35. "-DHAVE_PTHREAD",
  36. # Allows src/logging.cc to determine the host name.
  37. "-DHAVE_SYS_UTSNAME_H",
  38. # System header files enabler for src/utilities.cc
  39. # Enable system calls from syscall.h
  40. "-DHAVE_SYS_SYSCALL_H",
  41. # Enable system calls from sys/time.h
  42. "-DHAVE_SYS_TIME_H",
  43. "-DHAVE_STDINT_H",
  44. "-DHAVE_STRING_H",
  45. # For logging.cc
  46. "-DHAVE_PREAD",
  47. "-DHAVE_FCNTL",
  48. "-DHAVE_SYS_TYPES_H",
  49. # Allows syslog support
  50. "-DHAVE_SYSLOG_H",
  51. # GFlags
  52. "-isystem $(GENDIR)/external/com_github_gflags_gflags/",
  53. "-DHAVE_LIB_GFLAGS",
  54. # Necessary for creating soft links of log files
  55. "-DHAVE_UNISTD_H",
  56. ],
  57. includes = [
  58. ".",
  59. "src",
  60. ],
  61. visibility = ["//visibility:public"],
  62. deps = [
  63. "//external:gflags",
  64. ],
  65. )
  66. # Below are the generation rules that generates the necessary header
  67. # files for glog. Originally they are generated by CMAKE
  68. # configure_file() command, which replaces certain template
  69. # placeholders in the .in files with provided values.
  70. # gen_sh is a bash script that provides the values for generated
  71. # header files. Under the hood it is just a wrapper over sed.
  72. genrule(
  73. name = "gen_sh",
  74. outs = [
  75. "gen.sh",
  76. ],
  77. cmd = """
  78. cat > $@ <<"EOF"
  79. #! /bin/sh
  80. sed -e 's/@ac_cv_have_unistd_h@/1/g' \
  81. -e 's/@ac_cv_have_stdint_h@/1/g' \
  82. -e 's/@ac_cv_have_systypes_h@/1/g' \
  83. -e 's/@ac_cv_have_libgflags_h@/1/g' \
  84. -e 's/@ac_cv_have_uint16_t@/1/g' \
  85. -e 's/@ac_cv_have___builtin_expect@/1/g' \
  86. -e 's/@ac_cv_have_.*@/0/g' \
  87. -e 's/@ac_google_start_namespace@/namespace google {/g' \
  88. -e 's/@ac_google_end_namespace@/}/g' \
  89. -e 's/@ac_google_namespace@/google/g' \
  90. -e 's/@ac_cv___attribute___noinline@/__attribute__((noinline))/g' \
  91. -e 's/@ac_cv___attribute___noreturn@/__attribute__((noreturn))/g' \
  92. -e 's/@ac_cv___attribute___printf_4_5@/__attribute__((__format__ (__printf__, 4, 5)))/g'
  93. EOF""",
  94. )
  95. genrule(
  96. name = "config_h",
  97. srcs = [
  98. "src/config.h.cmake.in",
  99. ],
  100. outs = [
  101. "config.h",
  102. ],
  103. cmd = "awk '{ gsub(/^#cmakedefine/, \"//cmakedefine\"); print; }' $(<) > $(@)",
  104. )
  105. genrule(
  106. name = "logging_h",
  107. srcs = [
  108. "src/glog/logging.h.in",
  109. ],
  110. outs = [
  111. "glog/logging.h",
  112. ],
  113. cmd = "$(location :gen_sh) < $(<) > $(@)",
  114. tools = [":gen_sh"],
  115. )
  116. genrule(
  117. name = "raw_logging_h",
  118. srcs = [
  119. "src/glog/raw_logging.h.in",
  120. ],
  121. outs = [
  122. "glog/raw_logging.h",
  123. ],
  124. cmd = "$(location :gen_sh) < $(<) > $(@)",
  125. tools = [":gen_sh"],
  126. )
  127. genrule(
  128. name = "stl_logging_h",
  129. srcs = [
  130. "src/glog/stl_logging.h.in",
  131. ],
  132. outs = [
  133. "glog/stl_logging.h",
  134. ],
  135. cmd = "$(location :gen_sh) < $(<) > $(@)",
  136. tools = [":gen_sh"],
  137. )
  138. genrule(
  139. name = "vlog_is_on_h",
  140. srcs = [
  141. "src/glog/vlog_is_on.h.in",
  142. ],
  143. outs = [
  144. "glog/vlog_is_on.h",
  145. ],
  146. cmd = "$(location :gen_sh) < $(<) > $(@)",
  147. tools = [":gen_sh"],
  148. )