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