Skip to content

Commit 09273ac

Browse files
authored
Add license annotations (requires new module dependency on rules_license). Test with Bazel 8.x (in addition to existing supported versions).
1 parent a1fbd6c commit 09273ac

File tree

6 files changed

+185
-1
lines changed

6 files changed

+185
-1
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module(
2+
name = "zlib",
3+
version = "1.3.1.bcr.4",
4+
compatibility_level = 1,
5+
)
6+
bazel_dep(name = "platforms", version = "0.0.7")
7+
bazel_dep(name = "rules_cc", version = "0.0.8")
8+
bazel_dep(name = "rules_license", version = "1.0.0")
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
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+
+)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- MODULE.bazel
2+
+++ MODULE.bazel
3+
@@ -0,0 +1,8 @@
4+
+module(
5+
+ name = "zlib",
6+
+ version = "1.3.1.bcr.4",
7+
+ compatibility_level = 1,
8+
+)
9+
+bazel_dep(name = "platforms", version = "0.0.7")
10+
+bazel_dep(name = "rules_cc", version = "0.0.8")
11+
+bazel_dep(name = "rules_license", version = "1.0.0")
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
matrix:
2+
platform:
3+
- debian10
4+
- ubuntu2004
5+
- macos
6+
- macos_arm64
7+
- windows
8+
bazel:
9+
- 8.x
10+
- 7.x
11+
- 6.x
12+
tasks:
13+
verify_targets:
14+
name: Verify build targets
15+
platform: ${{ platform }}
16+
bazel: ${{ bazel }}
17+
build_targets:
18+
- '@zlib//:zlib'
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"url": "https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.gz",
3+
"integrity": "sha256-mpOyt9/ax3zrpaVYpYDnRmfdb+3kWFuR7vtg8Dty3yM=",
4+
"strip_prefix": "zlib-1.3.1",
5+
"patches": {
6+
"add_build_file.patch": "sha256-oDZicnafvBYwyiaH6dxR/8YMLrUJd2dYjIBU0YFuncM=",
7+
"module_dot_bazel.patch": "sha256-8SU4AGsRv5EvKXIci2AuKjbCCMMpOxgE5TSCFqj7Y7Q="
8+
},
9+
"patch_strip": 0
10+
}

modules/zlib/metadata.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"1.3.1",
1919
"1.3.1.bcr.1",
2020
"1.3.1.bcr.2",
21-
"1.3.1.bcr.3"
21+
"1.3.1.bcr.3",
22+
"1.3.1.bcr.4"
2223
],
2324
"yanked_versions": {
2425
"1.2.11": "CVE-2018-25032 (https://github.com/advisories/GHSA-jc36-42cf-vqwj)",

0 commit comments

Comments
 (0)