• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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("@com_google_sandboxed_api//sandboxed_api/bazel:build_defs.bzl", "sapi_platform_copts")
16load("@com_google_sandboxed_api//sandboxed_api/bazel:proto.bzl", "sapi_proto_library")
17
18package(default_visibility = [
19    "@com_google_sandboxed_api//sandboxed_api:__subpackages__",
20])
21
22licenses(["notice"])
23
24# Another helper library with filesystem and path utility functions.
25cc_library(
26    name = "file_base",
27    srcs = ["path.cc"],
28    hdrs = ["path.h"],
29    copts = sapi_platform_copts(),
30    deps = ["@com_google_absl//absl/strings"],
31)
32
33cc_test(
34    name = "file_base_test",
35    size = "small",
36    srcs = ["path_test.cc"],
37    copts = sapi_platform_copts(),
38    deps = [
39        ":file_base",
40        "@com_google_absl//absl/strings",
41        "@com_google_googletest//:gtest_main",
42    ],
43)
44
45# String file routines
46cc_library(
47    name = "file_helpers",
48    srcs = ["file_helpers.cc"],
49    hdrs = ["file_helpers.h"],
50    copts = sapi_platform_copts(),
51    deps = [
52        "@com_google_absl//absl/status",
53        "@com_google_absl//absl/strings",
54    ],
55)
56
57cc_test(
58    name = "file_helpers_test",
59    size = "small",
60    srcs = ["file_helpers_test.cc"],
61    copts = sapi_platform_copts(),
62    deps = [
63        ":file_helpers",
64        ":status_matchers",
65        "@com_google_googletest//:gtest_main",
66    ],
67)
68
69# Portable filesystem and path utility functions
70cc_library(
71    name = "fileops",
72    srcs = ["fileops.cc"],
73    hdrs = ["fileops.h"],
74    copts = sapi_platform_copts(),
75    deps = [
76        ":strerror",
77        "@com_google_absl//absl/strings",
78    ],
79)
80
81cc_test(
82    name = "fileops_test",
83    size = "small",
84    srcs = ["fileops_test.cc"],
85    copts = sapi_platform_copts(),
86    deps = [
87        ":file_helpers",
88        ":fileops",
89        ":status_matchers",
90        "@com_google_absl//absl/strings",
91        "@com_google_googletest//:gtest_main",
92        "@com_google_sandboxed_api//sandboxed_api:testing",
93    ],
94)
95
96sapi_proto_library(
97    name = "proto_arg",
98    srcs = ["proto_arg.proto"],
99    visibility = ["//visibility:public"],
100)
101
102cc_library(
103    name = "proto_helper",
104    srcs = ["proto_helper.cc"],
105    hdrs = ["proto_helper.h"],
106    copts = sapi_platform_copts(),
107    deps = [
108        ":proto_arg_cc_proto",
109        ":status",
110        "@com_google_absl//absl/status",
111        "@com_google_absl//absl/status:statusor",
112        "@com_google_protobuf//:protobuf_lite",
113    ],
114)
115
116# Small support library emulating verbose logging using Abseil's raw logging
117# facility.
118cc_library(
119    name = "raw_logging",
120    srcs = ["raw_logging.cc"],
121    hdrs = ["raw_logging.h"],
122    copts = sapi_platform_copts(),
123    deps = [
124        ":strerror",
125        "@com_google_absl//absl/base:config",
126        "@com_google_absl//absl/base:core_headers",
127        "@com_google_absl//absl/base:log_severity",
128        "@com_google_absl//absl/strings",
129        "@com_google_absl//absl/strings:str_format",
130    ],
131)
132
133cc_library(
134    name = "runfiles",
135    srcs = ["runfiles_bazel.cc"],
136    hdrs = ["runfiles.h"],
137    copts = sapi_platform_copts(),
138    visibility = ["//visibility:public"],
139    deps = [
140        ":file_base",
141        "@bazel_tools//tools/cpp/runfiles",
142        "@com_google_absl//absl/strings",
143        "@com_google_absl//absl/strings:str_format",
144        "@com_google_sandboxed_api//sandboxed_api/util:raw_logging",
145    ],
146)
147
148sapi_proto_library(
149    name = "status_proto",
150    srcs = ["status.proto"],
151)
152
153# Implementations of utility functions not released with absl::Status.
154cc_library(
155    name = "status",
156    srcs = ["status.cc"],
157    hdrs = [
158        "status.h",
159        "status_macros.h",
160    ],
161    copts = sapi_platform_copts(),
162    visibility = ["//visibility:public"],
163    deps = [
164        ":status_cc_proto",
165        "@com_google_absl//absl/base:core_headers",
166        "@com_google_absl//absl/status",
167        "@com_google_absl//absl/strings",
168        "@com_google_absl//absl/strings:cord",
169    ],
170)
171
172# gMock matchers for absl::Status and absl::StatusOr<T> and a gUnit printer
173# extension. Adapted from the version in Asylo.
174cc_library(
175    name = "status_matchers",
176    testonly = 1,
177    hdrs = ["status_matchers.h"],
178    copts = sapi_platform_copts(),
179    visibility = ["//visibility:public"],
180    deps = [
181        ":status",
182        "@com_google_absl//absl/status",
183        "@com_google_absl//absl/status:statusor",
184        "@com_google_absl//absl/strings:string_view",
185        "@com_google_absl//absl/types:optional",
186        "@com_google_googletest//:gtest",
187    ],
188)
189
190# Tests for the Status utility.
191cc_test(
192    name = "status_test",
193    srcs = ["status_test.cc"],
194    copts = sapi_platform_copts(),
195    deps = [
196        ":status",
197        ":status_cc_proto",
198        "@com_google_absl//absl/status",
199        "@com_google_absl//absl/strings:string_view",
200        "@com_google_googletest//:gtest_main",
201    ],
202)
203
204# Tests for the Status macros.
205cc_test(
206    name = "status_macros_test",
207    srcs = ["status_macros_test.cc"],
208    copts = sapi_platform_copts(),
209    deps = [
210        ":status",
211        ":status_matchers",
212        "@com_google_absl//absl/status",
213        "@com_google_absl//absl/status:statusor",
214        "@com_google_absl//absl/strings",
215        "@com_google_googletest//:gtest_main",
216    ],
217)
218
219# Internal thread-safe helper to format system error messages. Mostly
220# equivalent to base/strerror.h.
221cc_library(
222    name = "strerror",
223    srcs = ["strerror.cc"],
224    hdrs = ["strerror.h"],
225    copts = sapi_platform_copts(),
226    deps = [
227        "@com_google_absl//absl/base:core_headers",
228        "@com_google_absl//absl/strings:str_format",
229    ],
230)
231
232cc_test(
233    name = "strerror_test",
234    srcs = ["strerror_test.cc"],
235    copts = sapi_platform_copts(),
236    deps = [
237        ":strerror",
238        ":thread",
239        "@com_google_absl//absl/strings",
240        "@com_google_googletest//:gtest_main",
241    ],
242)
243
244cc_library(
245    name = "temp_file",
246    srcs = ["temp_file.cc"],
247    hdrs = ["temp_file.h"],
248    copts = sapi_platform_copts(),
249    deps = [
250        ":status",
251        "@com_google_absl//absl/status",
252        "@com_google_absl//absl/status:statusor",
253        "@com_google_absl//absl/strings",
254    ],
255)
256
257cc_test(
258    name = "temp_file_test",
259    srcs = ["temp_file_test.cc"],
260    copts = sapi_platform_copts(),
261    deps = [
262        ":file_base",
263        ":fileops",
264        ":status_matchers",
265        ":temp_file",
266        "@com_google_absl//absl/status",
267        "@com_google_absl//absl/status:statusor",
268        "@com_google_googletest//:gtest_main",
269        "@com_google_sandboxed_api//sandboxed_api:testing",
270    ],
271)
272
273cc_library(
274    name = "thread",
275    hdrs = ["thread.h"],
276    copts = sapi_platform_copts(),
277    deps = [
278        "@com_google_absl//absl/functional:any_invocable",
279        "@com_google_absl//absl/strings:string_view",
280    ],
281)
282