Skip to content

Commit e90f33e

Browse files
rwgkcopybara-github
authored andcommitted
Strip out code that depends on PyProto_API when exporting from Google 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: 645462442
1 parent af8ee51 commit e90f33e

File tree

5 files changed

+3
-279
lines changed

5 files changed

+3
-279
lines changed

CMakeLists.txt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ add_library(
6868
# bazel: pybind_library: proto_cast_util
6969
pybind11_protobuf/proto_cast_util.cc
7070
pybind11_protobuf/proto_cast_util.h
71-
pybind11_protobuf/proto_caster_impl.h
72-
# bazel: cc_library::check_unknown_fields
73-
pybind11_protobuf/check_unknown_fields.cc
74-
pybind11_protobuf/check_unknown_fields.h)
71+
pybind11_protobuf/proto_caster_impl.h)
7572

7673
target_link_libraries(
7774
pybind11_native_proto_caster
@@ -98,10 +95,7 @@ add_library(
9895
# bazel: pybind_library: proto_cast_util
9996
pybind11_protobuf/proto_cast_util.cc
10097
pybind11_protobuf/proto_cast_util.h
101-
pybind11_protobuf/proto_caster_impl.h
102-
# bazel: cc_library: check_unknown_fields
103-
pybind11_protobuf/check_unknown_fields.cc
104-
pybind11_protobuf/check_unknown_fields.h)
98+
pybind11_protobuf/proto_caster_impl.h)
10599

106100
target_link_libraries(
107101
pybind11_wrapped_proto_caster
@@ -119,9 +113,6 @@ target_include_directories(
119113
PRIVATE ${PROJECT_SOURCE_DIR} ${protobuf_INCLUDE_DIRS} ${protobuf_SOURCE_DIR}
120114
${pybind11_INCLUDE_DIRS})
121115

122-
# TODO set defines PYBIND11_PROTOBUF_ENABLE_PYPROTO_API see: bazel:
123-
# pybind_library: proto_cast_util
124-
125116
# bazel equivs. checklist
126117
#
127118
# bazel: pybind_library: enum_type_caster - enum_type_caster.h

pybind11_protobuf/BUILD

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Pybind11 bindings for Google's Protocol Buffers
22

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

65
licenses(["notice"])
76

@@ -30,32 +29,13 @@ pybind_library(
3029
],
3130
)
3231

33-
# To enable PyProto_API use, specify:
34-
# bazel build --@//:enable_pyproto_api
35-
bool_flag(
36-
name = "enable_pyproto_api",
37-
build_setting_default = False,
38-
)
39-
40-
config_setting(
41-
name = "enable_pyproto_api_setting",
42-
flag_values = {
43-
":enable_pyproto_api": "True",
44-
},
45-
visibility = ["//visibility:private"],
46-
)
47-
4832
pybind_library(
4933
name = "proto_cast_util",
5034
srcs = ["proto_cast_util.cc"],
5135
hdrs = [
5236
"proto_cast_util.h",
5337
"proto_caster_impl.h",
5438
],
55-
local_defines = select({
56-
":enable_pyproto_api_setting": ["PYBIND11_PROTOBUF_ENABLE_PYPROTO_API"],
57-
"//conditions:default": [],
58-
}),
5939
deps = [
6040
":check_unknown_fields",
6141
"@com_google_absl//absl/container:flat_hash_map",

pybind11_protobuf/native_proto_caster.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include "google/protobuf/message.h"
2222
#include "absl/strings/string_view.h"
23-
#include "pybind11_protobuf/check_unknown_fields.h"
2423
#include "pybind11_protobuf/enum_type_caster.h"
2524
#include "pybind11_protobuf/proto_caster_impl.h"
2625

@@ -64,8 +63,6 @@ inline void ImportNativeProtoCasters() { InitializePybindProtoCastUtil(); }
6463
inline void AllowUnknownFieldsFor(
6564
absl::string_view top_message_descriptor_full_name,
6665
absl::string_view unknown_field_parent_message_fqn) {
67-
check_unknown_fields::AllowUnknownFieldsFor(top_message_descriptor_full_name,
68-
unknown_field_parent_message_fqn);
6966
}
7067

7168
} // namespace pybind11_protobuf

0 commit comments

Comments
 (0)