-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
protobuf.patch
98 lines (93 loc) · 2.56 KB
/
protobuf.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
diff --git a/BUILD b/BUILD
index 1690d4219..eb3cfbc67 100644
--- a/BUILD
+++ b/BUILD
@@ -19,7 +19,7 @@ exports_files(["LICENSE"])
# ZLIB configuration
################################################################################
-ZLIB_DEPS = ["@zlib//:zlib"]
+ZLIB_DEPS = ["//external:zlib"]
################################################################################
# Protobuf Runtime Library
@@ -510,14 +510,69 @@ cc_library(
deps = [":protobuf"],
)
+
cc_binary(
- name = "protoc",
+ name = "compiled_protoc",
srcs = ["src/google/protobuf/compiler/main.cc"],
linkopts = LINK_OPTS,
visibility = ["//visibility:public"],
deps = [":protoc_lib"],
)
+
+# Lifted from `rules_proto`
+config_setting(
+ name = "linux-aarch64",
+ constraint_values = [
+ "@platforms//os:linux",
+ "@platforms//cpu:aarch64",
+ ],
+)
+
+config_setting(
+ name = "linux-x86_64",
+ constraint_values = [
+ "@platforms//os:linux",
+ "@platforms//cpu:x86_64",
+ ],
+)
+
+config_setting(
+ name = "osx-x86_64",
+ constraint_values = [
+ "@platforms//os:osx",
+ "@platforms//cpu:x86_64",
+ ],
+)
+
+config_setting(
+ name = "win64",
+ constraint_values = [
+ "@platforms//os:windows",
+ "@platforms//cpu:x86_64",
+ ],
+)
+
+config_setting(
+ name = "windows",
+ constraint_values = [
+ "@platforms//os:windows",
+ ],
+)
+
+# Use precompiled binaries where possible.
+alias(
+ name = "protoc",
+ actual = select({
+ ":linux-aarch64": "@com_google_protobuf_protoc_linux_aarch_64//:protoc",
+ ":linux-x86_64": "@com_google_protobuf_protoc_linux_x86_64//:protoc",
+ ":osx-x86_64": "@com_google_protobuf_protoc_osx_x86_64//:protoc",
+ ":win64": "@com_google_protobuf_protoc_win64//:protoc",
+ "//conditions:default": ":compiled_protoc",
+ }),
+ visibility = ["//visibility:public"],
+)
+
################################################################################
# Tests
################################################################################
diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py
index 9319c67f1..d85d53d4a 100644
--- a/python/google/protobuf/__init__.py
+++ b/python/google/protobuf/__init__.py
@@ -31,3 +31,9 @@
# Copyright 2007 Google Inc. All Rights Reserved.
__version__ = '3.19.4'
+
+if __name__ != '__main__':
+ try:
+ __import__('pkg_resources').declare_namespace(__name__)
+ except ImportError:
+ __path__ = __import__('pkgutil').extend_path(__path__, __name__)