| Index: third_party/protobuf/BUILD.gn
|
| diff --git a/third_party/protobuf/BUILD.gn b/third_party/protobuf/BUILD.gn
|
| index 2cb1de57adbd35f6f91538158849718abdd79f23..2ba14ec2a79a94f765fd6fc51406684fb5775fea 100644
|
| --- a/third_party/protobuf/BUILD.gn
|
| +++ b/third_party/protobuf/BUILD.gn
|
| @@ -2,6 +2,8 @@
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
|
|
| +import("//third_party/protobuf/proto_library.gni")
|
| +
|
| config("protobuf_config") {
|
| include_dirs = [ "src" ]
|
| defines = [
|
| @@ -599,29 +601,19 @@ if (current_toolchain == host_toolchain) {
|
| }
|
| }
|
|
|
| -google_python_dir = "$root_out_dir/pyproto/google"
|
| -
|
| -copy("copy_google") {
|
| - sources = [
|
| - "__init__.py",
|
| - ]
|
| - outputs = [
|
| - "$google_python_dir/{{source_file_part}}",
|
| - ]
|
| -}
|
| +pyproto_dir = "$root_out_dir/pyproto"
|
|
|
| copy("copy_six") {
|
| sources = [
|
| "third_party/six/six.py",
|
| ]
|
| outputs = [
|
| - "$google_python_dir/third_party/six/{{source_file_part}}",
|
| + "$pyproto_dir/{{source_file_part}}",
|
| ]
|
| }
|
|
|
| copy("copy_google_protobuf") {
|
| sources = [
|
| - "python/google/protobuf/__init__.py",
|
| "python/google/protobuf/descriptor.py",
|
| "python/google/protobuf/descriptor_database.py",
|
| "python/google/protobuf/descriptor_pool.py",
|
| @@ -635,16 +627,9 @@ copy("copy_google_protobuf") {
|
| "python/google/protobuf/symbol_database.py",
|
| "python/google/protobuf/text_encoding.py",
|
| "python/google/protobuf/text_format.py",
|
| -
|
| - # TODO(ncarter): protoc's python generator treats descriptor.proto
|
| - # specially, but only when the input path is exactly
|
| - # "google/protobuf/descriptor.proto". I'm not sure how to execute a rule
|
| - # from a different directory. For now, use a manually-generated copy of
|
| - # descriptor_pb2.py.
|
| - "python/google/protobuf/descriptor_pb2.py",
|
| ]
|
| outputs = [
|
| - "$google_python_dir/protobuf/{{source_file_part}}",
|
| + "$pyproto_dir/google/protobuf/{{source_file_part}}",
|
| ]
|
| }
|
|
|
| @@ -664,21 +649,42 @@ copy("copy_google_protobuf_internal") {
|
| "python/google/protobuf/internal/wire_format.py",
|
| ]
|
| outputs = [
|
| - "$google_python_dir/protobuf/internal/{{source_file_part}}",
|
| + "$pyproto_dir/google/protobuf/internal/{{source_file_part}}",
|
| ]
|
| }
|
|
|
| +proto_library("generate_google_protobuf_descriptor") {
|
| + sources = [
|
| + "src/google/protobuf/compiler/plugin.proto",
|
| + "src/google/protobuf/descriptor.proto",
|
| + ]
|
| + proto_in_dir = "src"
|
| + proto_out_dir = ""
|
| +
|
| + generate_python = true
|
| + generate_cc = false
|
| +}
|
| +
|
| group("py_proto") {
|
| public_deps = [
|
| - ":copy_google",
|
| ":copy_google_protobuf",
|
| ":copy_google_protobuf_internal",
|
| ":copy_six",
|
| + ":generate_google_protobuf_descriptor",
|
| ]
|
|
|
| # Targets that depend on this should depend on the copied data files.
|
| - data = get_target_outputs(":copy_google")
|
| - data += get_target_outputs(":copy_six")
|
| - data += get_target_outputs(":copy_google_protobuf")
|
| - data += get_target_outputs(":copy_google_protobuf_internal")
|
| + data_deps = [
|
| + ":copy_google_protobuf",
|
| + ":copy_google_protobuf_internal",
|
| + ":copy_six",
|
| + ":generate_google_protobuf_descriptor",
|
| + ]
|
| +
|
| + # Init files implicitly created by protoc_wrapper.
|
| + data = [
|
| + "$pyproto_dir/google/__init__.py",
|
| + "$pyproto_dir/google/protobuf/__init__.py",
|
| + "$pyproto_dir/google/protobuf/compiler/__init__.py",
|
| + ]
|
| }
|
|
|