xref: /aosp_15_r20/external/sandboxed-api/sandboxed_api/examples/sum/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
15load("//sandboxed_api/bazel:build_defs.bzl", "sapi_platform_copts")
16load("//sandboxed_api/bazel:proto.bzl", "sapi_proto_library")
17load("//sandboxed_api/bazel:sapi.bzl", "sapi_library")
18
19package(default_visibility = ["//sandboxed_api:__subpackages__"])
20
21licenses(["notice"])
22
23sapi_proto_library(
24    name = "sum_params_proto",
25    srcs = ["sum_params.proto"],
26    visibility = ["//visibility:public"],
27    alwayslink = 1,
28)
29
30cc_library(
31    name = "sum",
32    srcs = [
33        "sum.c",
34        "sum_cpp.cc",
35    ],
36    copts = sapi_platform_copts(),
37    visibility = ["//visibility:public"],
38    deps = [
39        ":sum_params_cc_proto",
40        "@com_google_absl//absl/log",
41    ],
42    alwayslink = 1,  # All functions are linked into depending binaries
43)
44
45sapi_library(
46    name = "sum-sapi",
47    functions = [
48        "sum",
49        "sums",
50        "addf",
51        "sub",
52        "mul",
53        "divs",
54        "muld",
55        "crash",
56        "violate",
57        "sumarr",
58        "testptr",
59        "read_int",
60        "sleep_for_sec",
61        "sumproto",
62    ],
63    generator_version = 1,
64    input_files = [
65        "sum.c",
66        "sum_cpp.cc",
67    ],
68    lib = ":sum",
69    lib_name = "Sum",
70    namespace = "",
71    visibility = ["//visibility:public"],
72    deps = [":sum_params_cc_proto"],
73)
74
75# A quick'n'dirty testing binary
76cc_binary(
77    name = "main_sum",
78    srcs = ["main_sum.cc"],
79    copts = sapi_platform_copts(),
80    deps = [
81        ":sum-sapi",
82        ":sum_params_cc_proto",
83        "//sandboxed_api:sapi",
84        "//sandboxed_api:vars",
85        "@com_google_absl//absl/base:core_headers",
86        "@com_google_absl//absl/base:log_severity",
87        "@com_google_absl//absl/flags:parse",
88        "@com_google_absl//absl/log",
89        "@com_google_absl//absl/log:check",
90        "@com_google_absl//absl/log:globals",
91        "@com_google_absl//absl/log:initialize",
92        "@com_google_absl//absl/status",
93        "@com_google_absl//absl/status:statusor",
94        "@com_google_absl//absl/strings",
95    ],
96)
97
98# For now we only test exit status from the binary
99sh_test(
100    name = "main_sum_test",
101    srcs = ["main_sum_test.sh"],
102    data = [":main_sum"],
103)
104