• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1load(
2    "@rules_pkg//pkg:mappings.bzl",
3    "pkg_attributes",
4    "pkg_files",
5)
6load("@rules_pkg//pkg:zip.bzl", "pkg_zip")
7load("//:protobuf_release.bzl", "package_naming")
8load(":build_systems.bzl", "gen_file_lists")
9load(":cc_dist_library.bzl", "cc_dist_library")
10
11package_naming(
12    name = "protobuf_pkg_naming",
13)
14
15pkg_files(
16    name = "wkt_protos_files",
17    srcs = [
18        "//:well_known_type_protos",
19        "//go:go_features_proto_srcs",
20        "//java/core:java_features_proto_srcs",
21        "//src/google/protobuf:cpp_features_proto_srcs",
22        "//src/google/protobuf:descriptor_proto_srcs",
23    ],
24    prefix = "include/google/protobuf",
25    visibility = ["//visibility:private"],
26)
27
28pkg_files(
29    name = "compiler_plugin_protos_files",
30    srcs = [
31        "//src/google/protobuf/compiler:compiler_plugin_protos_files",
32    ],
33    prefix = "include/google/protobuf/compiler",
34    visibility = ["//visibility:private"],
35)
36
37################################################################################
38# Generates protoc release artifacts.
39################################################################################
40
41genrule(
42    name = "protoc_readme",
43    outs = ["readme.txt"],
44    cmd = """
45echo "Protocol Buffers - Google's data interchange format
46Copyright 2008 Google Inc.
47https://developers.google.com/protocol-buffers/
48This package contains a precompiled binary version of the protocol buffer
49compiler (protoc). This binary is intended for users who want to use Protocol
50Buffers in languages other than C++ but do not want to compile protoc
51themselves. To install, simply place this binary somewhere in your PATH.
52If you intend to use the included well known types then don't forget to
53copy the contents of the 'include' directory somewhere as well, for example
54into '/usr/local/include/'.
55Please refer to our official github site for more installation instructions:
56  https://github.com/protocolbuffers/protobuf" > $@
57    """,
58    visibility = ["//visibility:private"],
59)
60
61genrule(
62    name = "rename_protoc",
63    srcs = ["//:protoc_static"],
64    outs = ["bin/protoc"],
65    cmd = "cp $< $@",
66    tags = ["manual"],
67)
68
69genrule(
70    name = "rename_protoc_exe",
71    srcs = ["//:protoc_static"],
72    outs = ["bin/protoc.exe"],
73    cmd = "cp $< $@",
74    tags = ["manual"],
75)
76
77pkg_files(
78    name = "protoc_files",
79    srcs = select({
80        "//build_defs:config_win": ["bin/protoc.exe"],
81        "//conditions:default": ["bin/protoc"],
82    }),
83    attributes = pkg_attributes(mode = "0555"),
84    prefix = "bin/",
85    visibility = ["//visibility:private"],
86)
87
88pkg_zip(
89    name = "protoc_release",
90    srcs = [
91        ":compiler_plugin_protos_files",
92        ":protoc_files",
93        ":protoc_readme",
94        ":wkt_protos_files",
95    ],
96    package_file_name = "protoc-{version}-{platform}.zip",
97    package_variables = ":protobuf_pkg_naming",
98)
99
100################################################################################
101# Generated file lists for build systems
102################################################################################
103
104gen_file_lists(
105    name = "gen_src_file_lists",
106    testonly = 1,
107    out_stem = "src_file_lists",
108    src_libs = {
109        # {[source rule]: [name in generated file]}
110        # Libraries:
111        ":protobuf": "libprotobuf",
112        ":protobuf_lite": "libprotobuf_lite",
113        ":protoc": "libprotoc",
114        ":upb": "libupb",
115        ":protoc-gen-upb": "protoc-gen-upb",
116        ":protoc-gen-upbdefs": "protoc-gen-upbdefs",
117        ":protoc-gen-upb_minitable": "protoc-gen-upb_minitable",
118        # Protos:
119        "//src/google/protobuf:well_known_type_protos": "wkt_protos",
120        "//src/google/protobuf:cpp_features_proto": "cpp_features_proto",
121        "//src/google/protobuf:descriptor_proto": "descriptor_proto",
122        "//src/google/protobuf/compiler:plugin_proto": "plugin_proto",
123        "//java/core:java_features_proto": "java_features_proto,src/google/protobuf/compiler/java/",
124        "//go:go_features_proto": "go_features_proto,go/",
125
126        # Test libraries:
127        ":common_test": "common_test",
128        ":lite_test_util": "lite_test_util",
129        ":test_util": "test_util",
130        "//upb:test_util": "upb_test_util",
131        # Tests and test-only protos:
132        "//upb:test_protos": "upb_test_protos",
133        "//upb:test_srcs": "upb_test",
134        "//src/google/protobuf:full_test_srcs": "protobuf_test",
135        "//src/google/protobuf:test_proto_all_srcs": "protobuf_test_protos",
136        "//src/google/protobuf:lite_test_srcs": "protobuf_lite_test",
137        "//src/google/protobuf:lite_test_proto_srcs": "protobuf_lite_test_protos",
138        "//src/google/protobuf/compiler:fake_plugin_srcs": "fake_plugin",
139        "//src/google/protobuf/compiler:test_srcs": "compiler_test",
140        "//src/google/protobuf/compiler:test_proto_srcs": "compiler_test_protos",
141        "//src/google/protobuf/compiler:test_plugin_srcs": "test_plugin",
142        "//src/google/protobuf/io:test_srcs": "io_test",
143        "//src/google/protobuf/util:test_srcs": "util_test",
144        "//src/google/protobuf/util:test_proto_srcs": "util_test_protos",
145        "//src/google/protobuf/stubs:test_srcs": "stubs_test",
146    },
147)
148
149################################################################################
150# Protobuf runtime libraries.
151################################################################################
152
153cc_dist_library(
154    name = "protobuf_lite",
155    linkopts = select({
156        "//build_defs:config_msvc": [],
157        "//conditions:default": ["-lpthread"],
158    }),
159    tags = ["manual"],
160    deps = [
161        "//src/google/protobuf:arena_align",
162        "//src/google/protobuf:protobuf_lite",
163    ],
164)
165
166cc_dist_library(
167    name = "protobuf",
168    linkopts = select({
169        "//build_defs:config_msvc": [],
170        "//conditions:default": [
171            "-lz",
172            "-lpthread",
173        ],
174    }),
175    tags = ["manual"],
176    deps = [
177        "//src/google/protobuf",
178        "//src/google/protobuf:arena_align",
179        "//src/google/protobuf:cmake_wkt_cc_proto",
180        "//src/google/protobuf/compiler:importer",
181        "//src/google/protobuf/json",
182        "//src/google/protobuf/util:delimited_message_util",
183        "//src/google/protobuf/util:differencer",
184        "//src/google/protobuf/util:field_mask_util",
185        "//src/google/protobuf/util:json_util",
186        "//src/google/protobuf/util:time_util",
187        "//src/google/protobuf/util:type_resolver",
188    ],
189)
190
191cc_dist_library(
192    name = "protoc",
193    dist_deps = [
194        ":protobuf",
195        ":protobuf_lite",
196    ],
197    tags = ["manual"],
198    deps = [
199        "//src/google/protobuf/compiler:command_line_interface",
200        "//src/google/protobuf/compiler/cpp",
201        "//src/google/protobuf/compiler/csharp",
202        "//src/google/protobuf/compiler/java",
203        "//src/google/protobuf/compiler/kotlin",
204        "//src/google/protobuf/compiler/objectivec",
205        "//src/google/protobuf/compiler/php",
206        "//src/google/protobuf/compiler/python",
207        "//src/google/protobuf/compiler/ruby",
208        "//src/google/protobuf/compiler/rust",
209    ],
210)
211
212cc_dist_library(
213    name = "upb",
214    tags = ["manual"],
215    deps = [
216        "//upb:generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
217        "//upb/json",
218        "//upb/message:compare",
219        "//upb/message:copy",
220        "//upb/text",
221        "//upb/util:def_to_proto",
222        "//upb/util:required_fields",
223        "//upb/wire:byte_size",
224    ],
225)
226
227cc_dist_library(
228    name = "protoc-gen-upb",
229    dist_deps = [
230        ":upb",
231    ],
232    tags = ["manual"],
233    deps = [
234        "//upb_generator/c:generator_with_main",
235    ],
236)
237
238cc_dist_library(
239    name = "protoc-gen-upbdefs",
240    dist_deps = [
241        ":upb",
242    ],
243    tags = ["manual"],
244    deps = [
245        "//upb_generator/reflection:generator_with_main",
246    ],
247)
248
249cc_dist_library(
250    name = "protoc-gen-upb_minitable",
251    dist_deps = [
252        ":upb",
253    ],
254    tags = ["manual"],
255    deps = [
256        "//upb_generator/minitable:generator_with_main",
257    ],
258)
259
260cc_dist_library(
261    name = "lite_test_util",
262    testonly = 1,
263    dist_deps = [":protobuf"],
264    tags = ["manual"],
265    deps = ["//src/google/protobuf:lite_test_util"],
266)
267
268cc_dist_library(
269    name = "test_util",
270    testonly = 1,
271    dist_deps = [
272        ":common_test",
273        ":lite_test_util",
274        ":protoc",
275        ":protobuf",
276        ":protobuf_lite",
277    ],
278    tags = ["manual"],
279    deps = [
280        "//src/google/protobuf:lite_test_util",
281        "//src/google/protobuf:test_util",
282        "//src/google/protobuf:test_util2",
283        "//src/google/protobuf:unredacted_debug_format_for_test",
284        "//src/google/protobuf/compiler:annotation_test_util",
285        "//src/google/protobuf/compiler/cpp:unittest_lib",
286        "//src/google/protobuf/io:test_zero_copy_stream",
287    ],
288)
289
290cc_dist_library(
291    name = "common_test",
292    testonly = 1,
293    dist_deps = [
294        ":protobuf",
295        ":protobuf_lite",
296        ":protoc",
297    ],
298    tags = ["manual"],
299    deps = [
300        "//src/google/protobuf:descriptor_legacy",
301        "//src/google/protobuf:internal_visibility_for_testing",
302        "//src/google/protobuf:test_textproto",
303        "//src/google/protobuf/compiler:command_line_interface_tester",
304        "//src/google/protobuf/compiler:mock_code_generator",
305        "//src/google/protobuf/testing",
306        "//src/google/protobuf/testing:file",
307    ],
308)
309