diff --git a/sandboxed_api/BUILD b/sandboxed_api/BUILD index d920b2ee..f08986cc 100644 --- a/sandboxed_api/BUILD +++ b/sandboxed_api/BUILD @@ -13,7 +13,6 @@ # 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__"]) @@ -31,12 +30,6 @@ cc_library( ], ) -sapi_proto_library( - name = "proto_arg", - srcs = ["proto_arg.proto"], - visibility = ["//visibility:public"], -) - cc_library( name = "embed_file", srcs = [ @@ -140,14 +133,12 @@ cc_library( 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", @@ -165,10 +156,10 @@ cc_library( deps = [ ":call", ":lenval_core", - ":proto_arg_cc_proto", ":var_type", "//sandboxed_api/sandbox2:comms", "//sandboxed_api/sandbox2:util", + "//sandboxed_api/util:proto_helper", "//sandboxed_api/util:status", "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/log", @@ -192,12 +183,12 @@ cc_library( deps = [ ":call", ":lenval_core", - ":proto_arg_cc_proto", ":var_type", - ":vars", "//sandboxed_api/sandbox2:comms", "//sandboxed_api/sandbox2:forkingclient", "//sandboxed_api/sandbox2:logsink", + "//sandboxed_api/util:proto_arg_cc_proto", + "//sandboxed_api/util:proto_helper", "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/base:dynamic_annotations", "@com_google_absl//absl/flags:parse", diff --git a/sandboxed_api/CMakeLists.txt b/sandboxed_api/CMakeLists.txt index 0ab952ec..48c820e1 100644 --- a/sandboxed_api/CMakeLists.txt +++ b/sandboxed_api/CMakeLists.txt @@ -31,20 +31,6 @@ target_link_libraries(sapi_config PUBLIC absl::config ) -# sandboxed_api:proto_arg -sapi_protobuf_generate_cpp(_sapi_proto_arg_pb_cc _sapi_proto_arg_pb_h - proto_arg.proto -) -add_library(sapi_proto_arg_proto ${SAPI_LIB_TYPE} - ${_sapi_proto_arg_pb_cc} - ${_sapi_proto_arg_pb_h} -) -add_library(sapi::proto_arg_proto ALIAS sapi_proto_arg_proto) -target_link_libraries(sapi_proto_arg_proto PRIVATE - protobuf::libprotobuf - sapi::base -) - # sandboxed_api:embed_file add_library(sapi_embed_file ${SAPI_LIB_TYPE} embed_file.cc @@ -129,8 +115,6 @@ target_link_libraries(sapi_var_type PRIVATE # sandboxed_api:vars add_library(sapi_vars ${SAPI_LIB_TYPE} - proto_helper.cc - proto_helper.h rpcchannel.cc rpcchannel.h var_abstract.cc @@ -162,10 +146,10 @@ target_link_libraries(sapi_vars sapi::base sapi::call sapi::lenval_core - sapi::proto_arg_proto sapi::status sapi::var_type PUBLIC absl::log + sapi::proto_helper ) # sandboxed_api:client @@ -191,7 +175,7 @@ target_link_libraries(sapi_client sapi::call sapi::lenval_core sapi::proto_arg_proto - sapi::vars + sapi::proto_helper ${CMAKE_DL_LIBS} ) diff --git a/sandboxed_api/client.cc b/sandboxed_api/client.cc index 1c8d56f5..4459d92e 100644 --- a/sandboxed_api/client.cc +++ b/sandboxed_api/client.cc @@ -39,11 +39,11 @@ #include "google/protobuf/message.h" #include "sandboxed_api/call.h" #include "sandboxed_api/lenval_core.h" -#include "sandboxed_api/proto_arg.pb.h" -#include "sandboxed_api/proto_helper.h" #include "sandboxed_api/sandbox2/comms.h" #include "sandboxed_api/sandbox2/forkingclient.h" #include "sandboxed_api/sandbox2/logsink.h" +#include "sandboxed_api/util/proto_arg.pb.h" +#include "sandboxed_api/util/proto_helper.h" #include "sandboxed_api/var_type.h" #include diff --git a/sandboxed_api/util/BUILD b/sandboxed_api/util/BUILD index 9dac4199..670e6f36 100644 --- a/sandboxed_api/util/BUILD +++ b/sandboxed_api/util/BUILD @@ -96,6 +96,25 @@ cc_test( ], ) +sapi_proto_library( + name = "proto_arg", + srcs = ["proto_arg.proto"], + visibility = ["//visibility:public"], +) + +cc_library( + name = "proto_helper", + srcs = ["proto_helper.cc"], + hdrs = ["proto_helper.h"], + copts = sapi_platform_copts(), + deps = [ + ":proto_arg_cc_proto", + ":status", + "@com_google_absl//absl/status", + "@com_google_absl//absl/status:statusor", + ], +) + # Small support library emulating verbose logging using Abseil's raw logging # facility. cc_library( diff --git a/sandboxed_api/util/CMakeLists.txt b/sandboxed_api/util/CMakeLists.txt index ae91c16f..36c299eb 100644 --- a/sandboxed_api/util/CMakeLists.txt +++ b/sandboxed_api/util/CMakeLists.txt @@ -47,6 +47,36 @@ target_link_libraries(sapi_util_fileops PRIVATE sapi::base ) +# sandboxed_api/util:proto_arg +sapi_protobuf_generate_cpp(_sapi_proto_arg_pb_cc _sapi_proto_arg_pb_h + proto_arg.proto +) +add_library(sapi_util_proto_arg_proto ${SAPI_LIB_TYPE} + ${_sapi_proto_arg_pb_cc} + ${_sapi_proto_arg_pb_h} +) +add_library(sapi::proto_arg_proto ALIAS sapi_util_proto_arg_proto) +target_link_libraries(sapi_util_proto_arg_proto PRIVATE + protobuf::libprotobuf + sapi::base +) + +# sandboxed_api/util:proto_helper +add_library(sapi_util_proto_helper ${SAPI_LIB_TYPE} + proto_helper.cc + proto_helper.h +) +add_library(sapi::proto_helper ALIAS sapi_util_proto_helper) +target_link_libraries(sapi_util_proto_helper + PRIVATE sapi::base + PUBLIC absl::core_headers + absl::status + absl::statusor + sapi::proto_arg_proto + sapi::status +) + + # sandboxed_api/util:raw_logging add_library(sapi_util_raw_logging ${SAPI_LIB_TYPE} raw_logging.cc diff --git a/sandboxed_api/proto_arg.proto b/sandboxed_api/util/proto_arg.proto similarity index 100% rename from sandboxed_api/proto_arg.proto rename to sandboxed_api/util/proto_arg.proto diff --git a/sandboxed_api/proto_helper.cc b/sandboxed_api/util/proto_helper.cc similarity index 97% rename from sandboxed_api/proto_helper.cc rename to sandboxed_api/util/proto_helper.cc index 0c3623b8..bea416a3 100644 --- a/sandboxed_api/proto_helper.cc +++ b/sandboxed_api/util/proto_helper.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "sandboxed_api/proto_helper.h" +#include "sandboxed_api/util/proto_helper.h" #include #include diff --git a/sandboxed_api/proto_helper.h b/sandboxed_api/util/proto_helper.h similarity index 89% rename from sandboxed_api/proto_helper.h rename to sandboxed_api/util/proto_helper.h index 267bbba2..547c0b34 100644 --- a/sandboxed_api/proto_helper.h +++ b/sandboxed_api/util/proto_helper.h @@ -14,8 +14,8 @@ // Utility functions for protobuf handling. -#ifndef SANDBOXED_API_PROTO_HELPER_H_ -#define SANDBOXED_API_PROTO_HELPER_H_ +#ifndef SANDBOXED_API_UTIL_PROTO_HELPER_H_ +#define SANDBOXED_API_UTIL_PROTO_HELPER_H_ #include #include @@ -24,7 +24,7 @@ #include "absl/status/status.h" #include "absl/status/statusor.h" -#include "sandboxed_api/proto_arg.pb.h" +#include "sandboxed_api/util/proto_arg.pb.h" #include "sandboxed_api/util/status_macros.h" namespace sapi { @@ -51,4 +51,4 @@ absl::StatusOr DeserializeProto(const char* data, size_t len) { } // namespace sapi -#endif // SANDBOXED_API_PROTO_HELPER_H_ +#endif // SANDBOXED_API_UTIL_PROTO_HELPER_H_ diff --git a/sandboxed_api/var_proto.h b/sandboxed_api/var_proto.h index 0f86ca3d..79b3117f 100644 --- a/sandboxed_api/var_proto.h +++ b/sandboxed_api/var_proto.h @@ -32,7 +32,7 @@ #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/utility/utility.h" -#include "sandboxed_api/proto_helper.h" +#include "sandboxed_api/util/proto_helper.h" #include "sandboxed_api/util/status_macros.h" #include "sandboxed_api/var_lenval.h" #include "sandboxed_api/var_ptr.h"