mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
51799f99ae
Instead of calling `google::InitGoogleLogging()` directly, introduce an indirection via a new utility library. After this change, Sandboxed API should consistently use `sapi::InitLogging()` everywhere. For now, `sapi::InitLogging()` simply calls its glog equivalent. However, this enables us to migrate away from the gflags dependency and use Abseil flags. Once a follow-up change lands, `sapi::InitLogging()` will instead initialize the google logging library with flags defined from Aseil. Later still, once Abseil releases logging, we can then drop the glog dependency entirely. PiperOrigin-RevId: 445363592 Change-Id: Ia23a7dc88b8ffe65a422ea4d5233bba7bdd1303a
230 lines
6.4 KiB
Python
230 lines
6.4 KiB
Python
# Copyright 2019 Google LLC
|
|
#
|
|
# 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
|
|
#
|
|
# https://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# 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.
|
|
|
|
load("//sandboxed_api/bazel:build_defs.bzl", "sapi_platform_copts")
|
|
load("//sandboxed_api/bazel:proto.bzl", "sapi_proto_library")
|
|
|
|
package(default_visibility = ["//sandboxed_api:__subpackages__"])
|
|
|
|
licenses(["notice"])
|
|
|
|
exports_files(["LICENSE"])
|
|
|
|
cc_library(
|
|
name = "config",
|
|
hdrs = ["config.h"],
|
|
copts = sapi_platform_copts(),
|
|
deps = ["@com_google_absl//absl/base:config"],
|
|
)
|
|
|
|
sapi_proto_library(
|
|
name = "proto_arg",
|
|
srcs = ["proto_arg.proto"],
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
cc_library(
|
|
name = "embed_file",
|
|
srcs = [
|
|
"embed_file.cc",
|
|
"file_toc.h",
|
|
],
|
|
hdrs = ["embed_file.h"],
|
|
copts = sapi_platform_copts(),
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
"//sandboxed_api/sandbox2:util",
|
|
"//sandboxed_api/util:fileops",
|
|
"//sandboxed_api/util:raw_logging",
|
|
"//sandboxed_api/util:strerror",
|
|
"@com_google_absl//absl/container:flat_hash_map",
|
|
"@com_google_absl//absl/status",
|
|
"@com_google_absl//absl/strings",
|
|
"@com_google_absl//absl/synchronization",
|
|
"@com_google_glog//:glog",
|
|
],
|
|
)
|
|
|
|
# The main Sandboxed-API library
|
|
cc_library(
|
|
name = "sapi",
|
|
srcs = [
|
|
"sandbox.cc",
|
|
"transaction.cc",
|
|
],
|
|
hdrs = [
|
|
# TODO(hamacher): Remove reexport workaround as soon as the buildsystem
|
|
# supports this usecase.
|
|
"embed_file.h",
|
|
"sandbox.h",
|
|
"transaction.h",
|
|
],
|
|
copts = sapi_platform_copts(),
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
":config",
|
|
":embed_file",
|
|
":vars",
|
|
"//sandboxed_api/sandbox2",
|
|
"//sandboxed_api/sandbox2:client",
|
|
"//sandboxed_api/sandbox2:comms",
|
|
"//sandboxed_api/sandbox2/util:bpf_helper",
|
|
"//sandboxed_api/util:file_base",
|
|
"//sandboxed_api/util:fileops",
|
|
"//sandboxed_api/util:runfiles",
|
|
"//sandboxed_api/util:status",
|
|
"@com_google_absl//absl/base",
|
|
"@com_google_absl//absl/base:core_headers",
|
|
"@com_google_absl//absl/base:dynamic_annotations",
|
|
"@com_google_absl//absl/container:flat_hash_map",
|
|
"@com_google_absl//absl/memory",
|
|
"@com_google_absl//absl/status",
|
|
"@com_google_absl//absl/status:statusor",
|
|
"@com_google_absl//absl/strings",
|
|
"@com_google_absl//absl/strings:str_format",
|
|
"@com_google_absl//absl/synchronization",
|
|
"@com_google_absl//absl/time",
|
|
"@com_google_glog//:glog",
|
|
],
|
|
)
|
|
|
|
# Definitions shared between sandboxee and master used for higher-level IPC.
|
|
cc_library(
|
|
name = "call",
|
|
hdrs = ["call.h"],
|
|
copts = sapi_platform_copts(),
|
|
deps = [
|
|
":var_type",
|
|
"@com_google_absl//absl/base:core_headers",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "lenval_core",
|
|
hdrs = ["lenval_core.h"],
|
|
copts = sapi_platform_copts(),
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
cc_library(
|
|
name = "var_type",
|
|
hdrs = ["var_type.h"],
|
|
copts = sapi_platform_copts(),
|
|
)
|
|
|
|
# Variable hierarchy
|
|
cc_library(
|
|
name = "vars",
|
|
srcs = [
|
|
"proto_helper.cc",
|
|
"rpcchannel.cc",
|
|
"var_abstract.cc",
|
|
"var_int.cc",
|
|
"var_lenval.cc",
|
|
],
|
|
hdrs = [
|
|
"proto_helper.h",
|
|
"rpcchannel.h",
|
|
"var_abstract.h",
|
|
"var_array.h",
|
|
"var_int.h",
|
|
"var_lenval.h",
|
|
"var_proto.h",
|
|
"var_ptr.h",
|
|
"var_reg.h",
|
|
"var_struct.h",
|
|
"var_void.h",
|
|
"vars.h",
|
|
],
|
|
copts = sapi_platform_copts(),
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
":call",
|
|
":lenval_core",
|
|
":proto_arg_cc_proto",
|
|
":var_type",
|
|
"//sandboxed_api/sandbox2:comms",
|
|
"//sandboxed_api/util:status",
|
|
"@com_google_absl//absl/base:core_headers",
|
|
"@com_google_absl//absl/memory",
|
|
"@com_google_absl//absl/status",
|
|
"@com_google_absl//absl/status:statusor",
|
|
"@com_google_absl//absl/strings",
|
|
"@com_google_absl//absl/strings:str_format",
|
|
"@com_google_absl//absl/synchronization",
|
|
"@com_google_absl//absl/utility",
|
|
"@com_google_glog//:glog",
|
|
],
|
|
)
|
|
|
|
# A stub to be linked in with SAPI libraries
|
|
cc_library(
|
|
name = "client",
|
|
srcs = ["client.cc"],
|
|
copts = sapi_platform_copts(),
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
":call",
|
|
":config",
|
|
":lenval_core",
|
|
":proto_arg_cc_proto",
|
|
":vars",
|
|
"//sandboxed_api/sandbox2:client",
|
|
"//sandboxed_api/sandbox2:comms",
|
|
"//sandboxed_api/sandbox2:forkingclient",
|
|
"//sandboxed_api/sandbox2:logsink",
|
|
"//sandboxed_api/util:flags",
|
|
"//sandboxed_api/util:logging",
|
|
"@com_google_absl//absl/base:dynamic_annotations",
|
|
"@com_google_absl//absl/strings",
|
|
"@com_google_glog//:glog",
|
|
"@com_google_protobuf//:protobuf",
|
|
"@org_sourceware_libffi//:libffi",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "sapi_test",
|
|
srcs = ["sapi_test.cc"],
|
|
copts = sapi_platform_copts(),
|
|
tags = ["local"],
|
|
deps = [
|
|
":sapi",
|
|
":testing",
|
|
"//sandboxed_api/examples/stringop:stringop-sapi",
|
|
"//sandboxed_api/examples/stringop:stringop_params_cc_proto",
|
|
"//sandboxed_api/examples/sum:sum-sapi",
|
|
"//sandboxed_api/examples/sum:sum-sapi_embed",
|
|
"//sandboxed_api/util:status_matchers",
|
|
"@com_google_absl//absl/memory",
|
|
"@com_google_absl//absl/status",
|
|
"@com_google_benchmark//:benchmark",
|
|
"@com_google_googletest//:gtest_main",
|
|
],
|
|
)
|
|
|
|
# Utility library for writing tests
|
|
cc_library(
|
|
name = "testing",
|
|
testonly = 1,
|
|
srcs = ["testing.cc"],
|
|
hdrs = ["testing.h"],
|
|
copts = sapi_platform_copts(),
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
"//sandboxed_api/util:file_base",
|
|
"@com_google_absl//absl/strings",
|
|
],
|
|
)
|