|
| 1 | +--- /dev/null |
| 2 | ++++ BUILD.bazel |
| 3 | +@@ -0,0 +1,133 @@ |
| 4 | ++# Adapted from https://github.com/protocolbuffers/protobuf/blob/master/third_party/zlib.BUILD |
| 5 | ++ |
| 6 | ++# Copyright 2008 Google Inc. All rights reserved. |
| 7 | ++# |
| 8 | ++# Redistribution and use in source and binary forms, with or without |
| 9 | ++# modification, are permitted provided that the following conditions are |
| 10 | ++# met: |
| 11 | ++# |
| 12 | ++# * Redistributions of source code must retain the above copyright |
| 13 | ++# notice, this list of conditions and the following disclaimer. |
| 14 | ++# * Redistributions in binary form must reproduce the above |
| 15 | ++# copyright notice, this list of conditions and the following disclaimer |
| 16 | ++# in the documentation and/or other materials provided with the |
| 17 | ++# distribution. |
| 18 | ++# * Neither the name of Google Inc. nor the names of its |
| 19 | ++# contributors may be used to endorse or promote products derived from |
| 20 | ++# this software without specific prior written permission. |
| 21 | ++# |
| 22 | ++# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 23 | ++# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 24 | ++# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 25 | ++# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 26 | ++# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 27 | ++# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 28 | ++# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 29 | ++# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 30 | ++# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 31 | ++# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 32 | ++# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 33 | ++# |
| 34 | ++# Code generated by the Protocol Buffer compiler is owned by the owner |
| 35 | ++# of the input file used when generating it. This code is not |
| 36 | ++# standalone and requires a support library to be linked with it. This |
| 37 | ++# support library is itself covered by the above license. |
| 38 | ++ |
| 39 | ++load("@rules_cc//cc:defs.bzl", "cc_library") |
| 40 | ++load("@rules_license//rules:license.bzl", "license") |
| 41 | ++ |
| 42 | ++package( |
| 43 | ++ default_applicable_licenses = [":license"], |
| 44 | ++) |
| 45 | ++ |
| 46 | ++license( |
| 47 | ++ name = "license", |
| 48 | ++ license_kinds = ["@rules_license//licenses/spdx:Zlib"], |
| 49 | ++ license_text = "LICENSE", |
| 50 | ++) |
| 51 | ++ |
| 52 | ++exports_files([ |
| 53 | ++ "LICENSE", |
| 54 | ++]) |
| 55 | ++ |
| 56 | ++_ZLIB_HEADERS = [ |
| 57 | ++ "crc32.h", |
| 58 | ++ "deflate.h", |
| 59 | ++ "gzguts.h", |
| 60 | ++ "inffast.h", |
| 61 | ++ "inffixed.h", |
| 62 | ++ "inflate.h", |
| 63 | ++ "inftrees.h", |
| 64 | ++ "trees.h", |
| 65 | ++ "zconf.h", |
| 66 | ++ "zlib.h", |
| 67 | ++ "zutil.h", |
| 68 | ++] |
| 69 | ++ |
| 70 | ++_ZLIB_PREFIXED_HEADERS = ["zlib/include/" + hdr for hdr in _ZLIB_HEADERS] |
| 71 | ++ |
| 72 | ++# In order to limit the damage from the `includes` propagation |
| 73 | ++# via `:zlib`, copy the public headers to a subdirectory and |
| 74 | ++# expose those. |
| 75 | ++genrule( |
| 76 | ++ name = "copy_public_headers", |
| 77 | ++ srcs = _ZLIB_HEADERS, |
| 78 | ++ outs = _ZLIB_PREFIXED_HEADERS, |
| 79 | ++ cmd_bash = "cp $(SRCS) $(@D)/zlib/include/", |
| 80 | ++ cmd_bat = " && ".join( |
| 81 | ++ ["@copy /Y \"$(location %s)\" \"$(@D)\\zlib\\include\\\" >NUL" % |
| 82 | ++ s for s in _ZLIB_HEADERS], |
| 83 | ++ ), |
| 84 | ++) |
| 85 | ++ |
| 86 | ++config_setting( |
| 87 | ++ name = "mingw_gcc_compiler", |
| 88 | ++ flag_values = { |
| 89 | ++ "@bazel_tools//tools/cpp:compiler": "mingw-gcc", |
| 90 | ++ }, |
| 91 | ++ visibility = [":__subpackages__"], |
| 92 | ++) |
| 93 | ++ |
| 94 | ++cc_library( |
| 95 | ++ name = "z", |
| 96 | ++ srcs = [ |
| 97 | ++ "adler32.c", |
| 98 | ++ "compress.c", |
| 99 | ++ "crc32.c", |
| 100 | ++ "deflate.c", |
| 101 | ++ "gzclose.c", |
| 102 | ++ "gzlib.c", |
| 103 | ++ "gzread.c", |
| 104 | ++ "gzwrite.c", |
| 105 | ++ "infback.c", |
| 106 | ++ "inffast.c", |
| 107 | ++ "inflate.c", |
| 108 | ++ "inftrees.c", |
| 109 | ++ "trees.c", |
| 110 | ++ "uncompr.c", |
| 111 | ++ "zutil.c", |
| 112 | ++ # Include the un-prefixed headers in srcs to work |
| 113 | ++ # around the fact that zlib isn't consistent in its |
| 114 | ++ # choice of <> or "" delimiter when including itself. |
| 115 | ++ ] + _ZLIB_HEADERS, |
| 116 | ++ hdrs = _ZLIB_PREFIXED_HEADERS, |
| 117 | ++ copts = select({ |
| 118 | ++ ":mingw_gcc_compiler": [ |
| 119 | ++ "-fpermissive", |
| 120 | ++ ], |
| 121 | ++ "@platforms//os:windows": [], |
| 122 | ++ "//conditions:default": [ |
| 123 | ++ "-Wno-deprecated-non-prototype", |
| 124 | ++ "-Wno-unused-variable", |
| 125 | ++ "-Wno-implicit-function-declaration", |
| 126 | ++ ], |
| 127 | ++ }), |
| 128 | ++ includes = ["zlib/include/"], |
| 129 | ++ visibility = ["//visibility:public"], |
| 130 | ++) |
| 131 | ++ |
| 132 | ++alias( |
| 133 | ++ name = "zlib", |
| 134 | ++ actual = ":z", |
| 135 | ++ visibility = ["//visibility:public"], |
| 136 | ++) |
0 commit comments