BUILD.zlib.bazel 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License in the LICENSE file at the
  6. # root of this repository, or online at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. """
  16. Builds zlib.
  17. Copied from https://github.com/protocolbuffers/protobuf/blob/v3.9.1/third_party/zlib.BUILD
  18. """
  19. load("@rules_cc//cc:defs.bzl", "cc_library")
  20. _ZLIB_HEADERS = [
  21. "crc32.h",
  22. "deflate.h",
  23. "gzguts.h",
  24. "inffast.h",
  25. "inffixed.h",
  26. "inflate.h",
  27. "inftrees.h",
  28. "trees.h",
  29. "zconf.h",
  30. "zlib.h",
  31. "zutil.h",
  32. ]
  33. _ZLIB_PREFIXED_HEADERS = ["zlib/include/" + hdr for hdr in _ZLIB_HEADERS]
  34. # In order to limit the damage from the `includes` propagation
  35. # via `:zlib`, copy the public headers to a subdirectory and
  36. # expose those.
  37. genrule(
  38. name = "copy_public_headers",
  39. srcs = _ZLIB_HEADERS,
  40. outs = _ZLIB_PREFIXED_HEADERS,
  41. cmd = "cp $(SRCS) $(@D)/zlib/include/",
  42. visibility = ["//visibility:private"],
  43. )
  44. cc_library(
  45. name = "zlib",
  46. srcs = [
  47. "adler32.c",
  48. "compress.c",
  49. "crc32.c",
  50. "deflate.c",
  51. "gzclose.c",
  52. "gzlib.c",
  53. "gzread.c",
  54. "gzwrite.c",
  55. "infback.c",
  56. "inffast.c",
  57. "inflate.c",
  58. "inftrees.c",
  59. "trees.c",
  60. "uncompr.c",
  61. "zutil.c",
  62. ],
  63. hdrs = _ZLIB_PREFIXED_HEADERS,
  64. copts = select({
  65. "//conditions:default": [
  66. "-Wno-unused-variable",
  67. "-Wno-implicit-function-declaration",
  68. "-Wno-deprecated-non-prototype",
  69. ],
  70. }),
  71. includes = ["zlib/include/"],
  72. visibility = ["//visibility:public"],
  73. )
  74. # Licensed to the Apache Software Foundation (ASF) under one or more
  75. # contributor license agreements. See the NOTICE file distributed with
  76. # this work for additional information regarding copyright ownership.
  77. # The ASF licenses this file to You under the Apache License, Version 2.0
  78. # (the "License"); you may not use this file except in compliance with
  79. # the License. You may obtain a copy of the License at
  80. #
  81. # http://www.apache.org/licenses/LICENSE-2.0
  82. #
  83. # Unless required by applicable law or agreed to in writing, software
  84. # distributed under the License is distributed on an "AS IS" BASIS,
  85. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  86. # See the License for the specific language governing permissions and
  87. # limitations under the License.
  88. #
  89. # Copyright 2008 Google Inc. All rights reserved.
  90. #
  91. # Redistribution and use in source and binary forms, with or without
  92. # modification, are permitted provided that the following conditions are
  93. # met:
  94. #
  95. # * Redistributions of source code must retain the above copyright
  96. # notice, this list of conditions and the following disclaimer.
  97. # * Redistributions in binary form must reproduce the above
  98. # copyright notice, this list of conditions and the following disclaimer
  99. # in the documentation and/or other materials provided with the
  100. # distribution.
  101. # * Neither the name of Google Inc. nor the names of its
  102. # contributors may be used to endorse or promote products derived from
  103. # this software without specific prior written permission.
  104. #
  105. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  106. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  107. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  108. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  109. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  110. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  111. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  112. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  113. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  114. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  115. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.