summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Maennich <maennich@google.com>2024-02-16 17:37:53 +0000
committerMatthias Maennich <maennich@google.com>2024-05-08 09:57:34 +0000
commit2950562c4183f6c4c9fc612538c5af806e71837f (patch)
tree52a3ea68625ef86692f26931c78e7dc717218d78
parenta00117914c494f730ae780a5bd3784f6d844fc81 (diff)
downloadbuild-2950562c4183f6c4c9fc612538c5af806e71837f.tar.gz
Add zlib repository including minimal build description
This allows to replace "-lz" (hermetic prebuilt zlib) by "@zlib" (built from sources). Bug: 315488400 Bug: 339377804 Change-Id: Ib1a40c491109dfae896c1b4f1326a49550425f5b Signed-off-by: Matthias Maennich <maennich@google.com>
-rw-r--r--kleaf/bzlmod/bazel.MODULE.bazel6
-rw-r--r--kleaf/pigz.BUILD6
-rw-r--r--kleaf/workspace.bzl6
-rw-r--r--kleaf/zlib.BUILD63
4 files changed, 79 insertions, 2 deletions
diff --git a/kleaf/bzlmod/bazel.MODULE.bazel b/kleaf/bzlmod/bazel.MODULE.bazel
index 7830caf8..5e26616f 100644
--- a/kleaf/bzlmod/bazel.MODULE.bazel
+++ b/kleaf/bzlmod/bazel.MODULE.bazel
@@ -43,6 +43,12 @@ new_kleaf_local_repository(
)
new_kleaf_local_repository(
+ name = "zlib",
+ build_file = "build/kernel/kleaf/zlib.BUILD",
+ path = "external/zlib",
+)
+
+new_kleaf_local_repository(
name = "zopfli",
build_file = "build/kernel/kleaf/zopfli.BUILD",
path = "external/zopfli",
diff --git a/kleaf/pigz.BUILD b/kleaf/pigz.BUILD
index 6d6642b4..8e3c6be1 100644
--- a/kleaf/pigz.BUILD
+++ b/kleaf/pigz.BUILD
@@ -22,8 +22,10 @@ cc_binary(
linkopts = [
"-lm",
"-lpthread",
- "-lz",
],
visibility = ["//visibility:public"],
- deps = ["@zopfli"],
+ deps = [
+ "@zlib",
+ "@zopfli",
+ ],
)
diff --git a/kleaf/workspace.bzl b/kleaf/workspace.bzl
index 5e791590..13eba05f 100644
--- a/kleaf/workspace.bzl
+++ b/kleaf/workspace.bzl
@@ -156,6 +156,12 @@ WARNING: define_kleaf_workspace() should be called with common_kernel_package={}
)
new_kleaf_local_repository(
+ name = "zlib",
+ path = "external/zlib",
+ build_file = "build/kernel/kleaf/zlib.BUILD",
+ )
+
+ new_kleaf_local_repository(
name = "zopfli",
path = "external/zopfli",
build_file = "build/kernel/kleaf/zopfli.BUILD",
diff --git a/kleaf/zlib.BUILD b/kleaf/zlib.BUILD
new file mode 100644
index 00000000..c92907ad
--- /dev/null
+++ b/kleaf/zlib.BUILD
@@ -0,0 +1,63 @@
+# Copyright (C) 2024 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+cc_library(
+ name = "zlib",
+ srcs = [
+ "adler32.c",
+ "compress.c",
+ "contrib/optimizations/insert_string.h",
+ "cpu_features.c",
+ "crc32.c",
+ "crc_folding.c",
+ "deflate.c",
+ "gzclose.c",
+ "gzlib.c",
+ "gzread.c",
+ "gzwrite.c",
+ "infback.c",
+ "inffast.c",
+ "inflate.c",
+ "inftrees.c",
+ "trees.c",
+ "uncompr.c",
+ "zutil.c",
+ ],
+ hdrs = [
+ "cpu_features.h",
+ "crc32.h",
+ "deflate.h",
+ "gzguts.h",
+ "inffast.h",
+ "inffixed.h",
+ "inflate.h",
+ "inftrees.h",
+ "trees.h",
+ "zconf.h",
+ "zlib.h",
+ "zutil.h",
+ ],
+ copts = [
+ "-O3",
+ "-Wall",
+ "-Werror",
+ "-Wno-deprecated-non-prototype",
+ "-Wno-unused",
+ "-Wno-unused-parameter",
+ # Use the traditional Rabin-Karp rolling hash to match zlib DEFLATE output exactly.
+ "-DCHROMIUM_ZLIB_NO_CASTAGNOLI",
+ ],
+ includes = ["."],
+ visibility = ["//visibility:public"],
+)