Skip to content

Commit

Permalink
Split out proto_helper
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 628343206
Change-Id: I0a11cfcaf82260f3618b766475562a39f289445b
  • Loading branch information
happyCoder92 authored and copybara-github committed Apr 26, 2024
1 parent 1582f86 commit b544015
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 38 deletions.
15 changes: 3 additions & 12 deletions sandboxed_api/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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__"])

Expand All @@ -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 = [
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
20 changes: 2 additions & 18 deletions sandboxed_api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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}
)

Expand Down
4 changes: 2 additions & 2 deletions sandboxed_api/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ffi.h>
Expand Down
19 changes: 19 additions & 0 deletions sandboxed_api/util/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
30 changes: 30 additions & 0 deletions sandboxed_api/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cstddef>
#include <cstdint>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cstddef>
#include <cstdint>
Expand All @@ -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 {
Expand All @@ -51,4 +51,4 @@ absl::StatusOr<T> DeserializeProto(const char* data, size_t len) {

} // namespace sapi

#endif // SANDBOXED_API_PROTO_HELPER_H_
#endif // SANDBOXED_API_UTIL_PROTO_HELPER_H_
2 changes: 1 addition & 1 deletion sandboxed_api/var_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit b544015

Please sign in to comment.