2020-01-17 21:05:03 +08:00
|
|
|
# Copyright 2019 Google LLC
|
2019-03-19 00:21:48 +08:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
2022-01-28 17:38:27 +08:00
|
|
|
# https://www.apache.org/licenses/LICENSE-2.0
|
2019-03-19 00:21:48 +08:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2020-02-28 01:23:44 +08:00
|
|
|
load("//sandboxed_api/bazel:build_defs.bzl", "sapi_platform_copts")
|
|
|
|
load("//sandboxed_api/bazel:proto.bzl", "sapi_proto_library")
|
|
|
|
|
2022-11-29 01:55:23 +08:00
|
|
|
package(
|
|
|
|
default_visibility = [
|
|
|
|
"//sandboxed_api:__subpackages__",
|
|
|
|
"//security/bedebox:__subpackages__",
|
|
|
|
],
|
|
|
|
)
|
2019-03-19 00:21:48 +08:00
|
|
|
|
2019-09-25 22:13:33 +08:00
|
|
|
licenses(["notice"])
|
2019-03-19 00:21:48 +08:00
|
|
|
|
2021-01-14 01:25:25 +08:00
|
|
|
# Another helper library with filesystem and path utility functions.
|
|
|
|
cc_library(
|
|
|
|
name = "file_base",
|
|
|
|
srcs = ["path.cc"],
|
|
|
|
hdrs = ["path.h"],
|
|
|
|
copts = sapi_platform_copts(),
|
|
|
|
deps = ["@com_google_absl//absl/strings"],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_test(
|
|
|
|
name = "file_base_test",
|
|
|
|
size = "small",
|
|
|
|
srcs = ["path_test.cc"],
|
|
|
|
copts = sapi_platform_copts(),
|
|
|
|
deps = [
|
|
|
|
":file_base",
|
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
"@com_google_googletest//:gtest_main",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
# String file routines
|
|
|
|
cc_library(
|
|
|
|
name = "file_helpers",
|
|
|
|
srcs = ["file_helpers.cc"],
|
|
|
|
hdrs = ["file_helpers.h"],
|
|
|
|
copts = sapi_platform_copts(),
|
|
|
|
deps = [
|
|
|
|
"@com_google_absl//absl/status",
|
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_test(
|
|
|
|
name = "file_helpers_test",
|
|
|
|
size = "small",
|
|
|
|
srcs = ["file_helpers_test.cc"],
|
|
|
|
copts = sapi_platform_copts(),
|
|
|
|
deps = [
|
|
|
|
":file_helpers",
|
2023-08-24 21:23:03 +08:00
|
|
|
":status_matchers",
|
2021-01-14 01:25:25 +08:00
|
|
|
"@com_google_googletest//:gtest_main",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
# Portable filesystem and path utility functions
|
|
|
|
cc_library(
|
|
|
|
name = "fileops",
|
|
|
|
srcs = ["fileops.cc"],
|
|
|
|
hdrs = ["fileops.h"],
|
2022-04-29 17:13:32 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2021-01-14 01:25:25 +08:00
|
|
|
deps = [
|
|
|
|
":strerror",
|
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_test(
|
|
|
|
name = "fileops_test",
|
|
|
|
size = "small",
|
|
|
|
srcs = ["fileops_test.cc"],
|
|
|
|
copts = sapi_platform_copts(),
|
|
|
|
deps = [
|
|
|
|
":file_helpers",
|
|
|
|
":fileops",
|
2023-08-24 21:23:03 +08:00
|
|
|
":status_matchers",
|
2021-01-14 01:25:25 +08:00
|
|
|
"//sandboxed_api:testing",
|
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
"@com_google_googletest//:gtest_main",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
# Small support library emulating verbose logging using Abseil's raw logging
|
|
|
|
# facility.
|
|
|
|
cc_library(
|
|
|
|
name = "raw_logging",
|
|
|
|
srcs = ["raw_logging.cc"],
|
|
|
|
hdrs = ["raw_logging.h"],
|
|
|
|
copts = sapi_platform_copts(),
|
|
|
|
deps = [
|
|
|
|
":strerror",
|
|
|
|
"@com_google_absl//absl/base:config",
|
|
|
|
"@com_google_absl//absl/base:core_headers",
|
|
|
|
"@com_google_absl//absl/base:log_severity",
|
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
"@com_google_absl//absl/strings:str_format",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "runfiles",
|
2022-04-20 19:45:41 +08:00
|
|
|
srcs = ["runfiles_bazel.cc"],
|
2021-01-14 01:25:25 +08:00
|
|
|
hdrs = ["runfiles.h"],
|
|
|
|
copts = sapi_platform_copts(),
|
2021-01-14 21:10:54 +08:00
|
|
|
visibility = ["//visibility:public"],
|
2021-01-14 01:25:25 +08:00
|
|
|
deps = [
|
|
|
|
":file_base",
|
|
|
|
":raw_logging",
|
|
|
|
"@bazel_tools//tools/cpp/runfiles",
|
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
"@com_google_absl//absl/strings:str_format",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2019-03-19 00:21:48 +08:00
|
|
|
sapi_proto_library(
|
|
|
|
name = "status_proto",
|
|
|
|
srcs = ["status.proto"],
|
|
|
|
)
|
|
|
|
|
2021-07-27 19:09:37 +08:00
|
|
|
# Implementations of utility functions not released with absl::Status.
|
2019-03-19 00:21:48 +08:00
|
|
|
cc_library(
|
|
|
|
name = "status",
|
2020-02-20 20:26:01 +08:00
|
|
|
srcs = ["status.cc"],
|
2019-03-19 00:21:48 +08:00
|
|
|
hdrs = [
|
|
|
|
"status.h",
|
|
|
|
"status_macros.h",
|
|
|
|
],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-07-02 18:20:02 +08:00
|
|
|
visibility = ["//visibility:public"],
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
2019-09-25 22:13:33 +08:00
|
|
|
":status_cc_proto",
|
2019-03-19 00:21:48 +08:00
|
|
|
"@com_google_absl//absl/base:core_headers",
|
2020-02-28 01:23:44 +08:00
|
|
|
"@com_google_absl//absl/status",
|
2019-03-19 00:21:48 +08:00
|
|
|
"@com_google_absl//absl/strings",
|
2023-08-24 21:23:03 +08:00
|
|
|
"@com_google_absl//absl/strings:cord",
|
2019-03-19 00:21:48 +08:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2020-09-03 22:40:09 +08:00
|
|
|
# gMock matchers for absl::Status and absl::StatusOr<T> and a gUnit printer
|
|
|
|
# extension. Adapted from the version in Asylo.
|
2019-03-19 00:21:48 +08:00
|
|
|
cc_library(
|
|
|
|
name = "status_matchers",
|
|
|
|
testonly = 1,
|
|
|
|
hdrs = ["status_matchers.h"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-07-02 18:20:02 +08:00
|
|
|
visibility = ["//visibility:public"],
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
":status",
|
2020-02-28 01:23:44 +08:00
|
|
|
"@com_google_absl//absl/status",
|
2020-09-03 22:40:09 +08:00
|
|
|
"@com_google_absl//absl/status:statusor",
|
2023-08-24 21:23:03 +08:00
|
|
|
"@com_google_absl//absl/strings:string_view",
|
2019-03-19 00:21:48 +08:00
|
|
|
"@com_google_absl//absl/types:optional",
|
|
|
|
"@com_google_googletest//:gtest",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
# Tests for the Status utility.
|
|
|
|
cc_test(
|
|
|
|
name = "status_test",
|
|
|
|
srcs = ["status_test.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
2019-04-26 21:21:11 +08:00
|
|
|
":status",
|
2020-02-28 01:23:44 +08:00
|
|
|
"@com_google_absl//absl/status",
|
2023-08-24 21:23:03 +08:00
|
|
|
"@com_google_absl//absl/strings:string_view",
|
2019-03-19 00:21:48 +08:00
|
|
|
"@com_google_googletest//:gtest_main",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
# Tests for the Status macros.
|
|
|
|
cc_test(
|
|
|
|
name = "status_macros_test",
|
|
|
|
srcs = ["status_macros_test.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
":status",
|
|
|
|
":status_matchers",
|
2020-02-28 01:23:44 +08:00
|
|
|
"@com_google_absl//absl/status",
|
2020-09-03 22:40:09 +08:00
|
|
|
"@com_google_absl//absl/status:statusor",
|
2019-03-19 00:21:48 +08:00
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
"@com_google_googletest//:gtest_main",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2021-01-14 01:25:25 +08:00
|
|
|
# Internal thread-safe helper to format system error messages. Mostly
|
|
|
|
# equivalent to base/strerror.h.
|
2019-06-05 15:25:50 +08:00
|
|
|
cc_library(
|
2021-01-14 01:25:25 +08:00
|
|
|
name = "strerror",
|
|
|
|
srcs = ["strerror.cc"],
|
|
|
|
hdrs = ["strerror.h"],
|
2019-06-05 15:25:50 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2021-01-14 01:25:25 +08:00
|
|
|
deps = [
|
|
|
|
"@com_google_absl//absl/base:core_headers",
|
2021-05-18 20:37:10 +08:00
|
|
|
"@com_google_absl//absl/strings:str_format",
|
2021-01-14 01:25:25 +08:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_test(
|
|
|
|
name = "strerror_test",
|
|
|
|
srcs = ["strerror_test.cc"],
|
|
|
|
copts = sapi_platform_copts(),
|
|
|
|
deps = [
|
|
|
|
":strerror",
|
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
"@com_google_googletest//:gtest_main",
|
|
|
|
],
|
2019-06-05 15:25:50 +08:00
|
|
|
)
|
|
|
|
|
2019-03-19 00:21:48 +08:00
|
|
|
cc_library(
|
2021-01-14 01:25:25 +08:00
|
|
|
name = "temp_file",
|
|
|
|
srcs = ["temp_file.cc"],
|
|
|
|
hdrs = ["temp_file.h"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
2021-05-17 19:06:39 +08:00
|
|
|
":status",
|
2021-01-14 01:25:25 +08:00
|
|
|
"@com_google_absl//absl/status",
|
|
|
|
"@com_google_absl//absl/status:statusor",
|
2019-03-19 00:21:48 +08:00
|
|
|
"@com_google_absl//absl/strings",
|
2021-01-14 01:25:25 +08:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_test(
|
|
|
|
name = "temp_file_test",
|
|
|
|
srcs = ["temp_file_test.cc"],
|
|
|
|
copts = sapi_platform_copts(),
|
|
|
|
deps = [
|
|
|
|
":file_base",
|
|
|
|
":fileops",
|
2023-08-24 21:23:03 +08:00
|
|
|
":status_matchers",
|
2021-01-14 01:25:25 +08:00
|
|
|
":temp_file",
|
|
|
|
"//sandboxed_api:testing",
|
2023-08-24 21:23:03 +08:00
|
|
|
"@com_google_absl//absl/status",
|
|
|
|
"@com_google_absl//absl/status:statusor",
|
2021-01-14 01:25:25 +08:00
|
|
|
"@com_google_googletest//:gtest_main",
|
2019-03-19 00:21:48 +08:00
|
|
|
],
|
|
|
|
)
|