Skip to content

Commit

Permalink
Strip out code that depends on PyProto_API when exporting from Goog…
Browse files Browse the repository at this point in the history
…le codebase to GitHub.

For context see #161, in particular #161 (comment).

Intentionally not stripping out the check_unknown_fields.h,cc sources:

1. For simplicity, and

2. so that it is more obvious externally what the corresponding code in
   pybind11_protobuf/tests/extension_test.py is about
   (stripping out the test code would lead to distracting clutter).

PiperOrigin-RevId: 644613416
  • Loading branch information
Ralf W. Grosse-Kunstleve authored and copybara-github committed Jun 21, 2024
1 parent af8ee51 commit 7187683
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 279 deletions.
13 changes: 2 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ add_library(
# bazel: pybind_library: proto_cast_util
pybind11_protobuf/proto_cast_util.cc
pybind11_protobuf/proto_cast_util.h
pybind11_protobuf/proto_caster_impl.h
# bazel: cc_library::check_unknown_fields
pybind11_protobuf/check_unknown_fields.cc
pybind11_protobuf/check_unknown_fields.h)
pybind11_protobuf/proto_caster_impl.h)

target_link_libraries(
pybind11_native_proto_caster
Expand All @@ -98,10 +95,7 @@ add_library(
# bazel: pybind_library: proto_cast_util
pybind11_protobuf/proto_cast_util.cc
pybind11_protobuf/proto_cast_util.h
pybind11_protobuf/proto_caster_impl.h
# bazel: cc_library: check_unknown_fields
pybind11_protobuf/check_unknown_fields.cc
pybind11_protobuf/check_unknown_fields.h)
pybind11_protobuf/proto_caster_impl.h)

target_link_libraries(
pybind11_wrapped_proto_caster
Expand All @@ -119,9 +113,6 @@ target_include_directories(
PRIVATE ${PROJECT_SOURCE_DIR} ${protobuf_INCLUDE_DIRS} ${protobuf_SOURCE_DIR}
${pybind11_INCLUDE_DIRS})

# TODO set defines PYBIND11_PROTOBUF_ENABLE_PYPROTO_API see: bazel:
# pybind_library: proto_cast_util

# bazel equivs. checklist
#
# bazel: pybind_library: enum_type_caster - enum_type_caster.h
Expand Down
20 changes: 0 additions & 20 deletions pybind11_protobuf/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Pybind11 bindings for Google's Protocol Buffers

load("@pybind11_bazel//:build_defs.bzl", "pybind_library")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")

licenses(["notice"])

Expand Down Expand Up @@ -30,32 +29,13 @@ pybind_library(
],
)

# To enable PyProto_API use, specify:
# bazel build --@//:enable_pyproto_api
bool_flag(
name = "enable_pyproto_api",
build_setting_default = False,
)

config_setting(
name = "enable_pyproto_api_setting",
flag_values = {
":enable_pyproto_api": "True",
},
visibility = ["//visibility:private"],
)

pybind_library(
name = "proto_cast_util",
srcs = ["proto_cast_util.cc"],
hdrs = [
"proto_cast_util.h",
"proto_caster_impl.h",
],
local_defines = select({
":enable_pyproto_api_setting": ["PYBIND11_PROTOBUF_ENABLE_PYPROTO_API"],
"//conditions:default": [],
}),
deps = [
":check_unknown_fields",
"@com_google_absl//absl/container:flat_hash_map",
Expand Down
3 changes: 0 additions & 3 deletions pybind11_protobuf/native_proto_caster.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include "google/protobuf/message.h"
#include "absl/strings/string_view.h"
#include "pybind11_protobuf/check_unknown_fields.h"
#include "pybind11_protobuf/enum_type_caster.h"
#include "pybind11_protobuf/proto_caster_impl.h"

Expand Down Expand Up @@ -64,8 +63,6 @@ inline void ImportNativeProtoCasters() { InitializePybindProtoCastUtil(); }
inline void AllowUnknownFieldsFor(
absl::string_view top_message_descriptor_full_name,
absl::string_view unknown_field_parent_message_fqn) {
check_unknown_fields::AllowUnknownFieldsFor(top_message_descriptor_full_name,
unknown_field_parent_message_fqn);
}

} // namespace pybind11_protobuf
Expand Down
Loading

0 comments on commit 7187683

Please sign in to comment.