xref: /aosp_15_r20/external/sandboxed-api/sandboxed_api/examples/zlib/BUILD.bazel (revision ec63e07ab9515d95e79c211197c445ef84cefa6a)
1# Copyright 2019 Google LLC
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 at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# Description: Sandboxed API reimplementation of zlib's zpipe.c example.
16
17load("//sandboxed_api/bazel:build_defs.bzl", "sapi_platform_copts")
18load("//sandboxed_api/bazel:sapi.bzl", "sapi_library")
19
20package(default_visibility = ["//sandboxed_api:__subpackages__"])
21
22licenses(["notice"])
23
24sapi_library(
25    name = "zlib-sapi",
26    srcs = [],
27    hdrs = [],
28    functions = [
29        "deflateInit_",
30        "deflate",
31        "deflateEnd",
32    ],
33    generator_version = 1,
34    lib = "@net_zlib//:zlib",
35    lib_name = "Zlib",
36    namespace = "sapi::zlib",
37)
38
39cc_binary(
40    name = "main_zlib",
41    srcs = ["main_zlib.cc"],
42    copts = sapi_platform_copts(),
43    deps = [
44        ":zlib-sapi",
45        "//sandboxed_api:vars",
46        "@com_google_absl//absl/base:core_headers",
47        "@com_google_absl//absl/base:log_severity",
48        "@com_google_absl//absl/flags:parse",
49        "@com_google_absl//absl/log",
50        "@com_google_absl//absl/log:globals",
51        "@com_google_absl//absl/log:initialize",
52        "@com_google_absl//absl/status",
53        "@com_google_absl//absl/status:statusor",
54    ],
55)
56
57# Tests input/output conversion of zlib and compares with golden files
58sh_test(
59    name = "main_zlib_test",
60    srcs = ["main_zlib_test.sh"],
61    data = [
62        ":main_zlib",
63    ],
64    tags = ["notsan"],
65)
66