xref: /aosp_15_r20/external/sandboxed-api/sandboxed_api/examples/stringop/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: Example using dynamic length structures for Sandboxed API
16
17load("//sandboxed_api/bazel:build_defs.bzl", "sapi_platform_copts")
18load("//sandboxed_api/bazel:proto.bzl", "sapi_proto_library")
19load("//sandboxed_api/bazel:sapi.bzl", "sapi_library")
20
21package(default_visibility = ["//sandboxed_api:__subpackages__"])
22
23licenses(["notice"])
24
25sapi_proto_library(
26    name = "stringop_params_proto",
27    srcs = ["stringop_params.proto"],
28    visibility = ["//visibility:public"],
29    alwayslink = True,
30)
31
32cc_library(
33    name = "stringop",
34    srcs = ["stringop.cc"],
35    copts = sapi_platform_copts(),
36    linkstatic = True,
37    deps = [
38        ":stringop_params_cc_proto",
39        "//sandboxed_api:lenval_core",
40        "@com_google_absl//absl/base:core_headers",
41    ],
42    alwayslink = True,
43)
44
45STRINGOP_FUNCTIONS = [
46    "duplicate_string",
47    "reverse_string",
48    "pb_duplicate_string",
49    "pb_reverse_string",
50    "nop",
51    "violate",
52    "get_raw_c_string",
53]
54
55sapi_library(
56    name = "stringop-sapi",
57    functions = STRINGOP_FUNCTIONS,
58    generator_version = 1,
59    input_files = ["stringop.cc"],
60    lib = ":stringop",
61    lib_name = "Stringop",
62    namespace = "",
63    deps = [":stringop_params_cc_proto"],
64)
65
66cc_test(
67    name = "main_stringop",
68    srcs = ["main_stringop.cc"],
69    copts = sapi_platform_copts(),
70    tags = ["local"],
71    deps = [
72        ":stringop-sapi",
73        ":stringop_params_cc_proto",
74        "//sandboxed_api:sapi",
75        "//sandboxed_api:vars",
76        "//sandboxed_api/util:status",
77        "//sandboxed_api/util:status_matchers",
78        "@com_google_absl//absl/log",
79        "@com_google_absl//absl/memory",
80        "@com_google_absl//absl/status",
81        "@com_google_absl//absl/status:statusor",
82        "@com_google_absl//absl/strings:string_view",
83        "@com_google_googletest//:gtest_main",
84    ],
85)
86