OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # Compile a protocol buffer. | 5 # Compile a protocol buffer. |
6 # | 6 # |
7 # Protobuf parameters: | 7 # Protobuf parameters: |
8 # | 8 # |
9 # proto_out_dir (optional) | 9 # proto_out_dir (optional) |
10 # Specifies the path suffix that output files are generated under. This | 10 # Specifies the path suffix that output files are generated under. This |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 sources = invoker.sources | 68 sources = invoker.sources |
69 | 69 |
70 # Compute the output directory, both relative to the source root (for | 70 # Compute the output directory, both relative to the source root (for |
71 # declaring "outputs") and relative to the build dir (for passing to the | 71 # declaring "outputs") and relative to the build dir (for passing to the |
72 # script). | 72 # script). |
73 if (defined(invoker.proto_out_dir)) { | 73 if (defined(invoker.proto_out_dir)) { |
74 # Put the results in the specified dir in the gen tree. | 74 # Put the results in the specified dir in the gen tree. |
75 out_dir = "$root_gen_dir/" + invoker.proto_out_dir | 75 out_dir = "$root_gen_dir/" + invoker.proto_out_dir |
76 rel_out_dir = rebase_path(out_dir, root_build_dir) | 76 rel_out_dir = rebase_path(out_dir, root_build_dir) |
| 77 py_out_dir = "$root_out_dir/pyproto/" + invoker.proto_out_dir |
77 } else { | 78 } else { |
78 # Use the gen directory corresponding to the source file. This expansion | 79 # Use the gen directory corresponding to the source file for C++ sources. |
79 # will be done differently in the outputs and the args, so we don't need | 80 # This expansion will be done differently in the outputs and the args, so |
80 # to worry about rebasing as above. | 81 # we don't need to worry about rebasing as above. Always put Python |
| 82 # sources in "pyproto". |
81 out_dir = "{{source_gen_dir}}" | 83 out_dir = "{{source_gen_dir}}" |
82 rel_out_dir = "{{source_gen_dir}}" | 84 rel_out_dir = "{{source_gen_dir}}" |
| 85 py_out_dir = "$root_out_dir/pyproto/{{source_root_relative_dir}}" |
83 } | 86 } |
| 87 rel_py_out_dir = rebase_path(py_out_dir, root_build_dir) |
84 | 88 |
85 outputs = [ | 89 outputs = [ |
86 "$out_dir/{{source_name_part}}_pb2.py", | 90 "$py_out_dir/{{source_name_part}}_pb2.py", |
87 "$out_dir/{{source_name_part}}.pb.cc", | 91 "$out_dir/{{source_name_part}}.pb.cc", |
88 "$out_dir/{{source_name_part}}.pb.h", | 92 "$out_dir/{{source_name_part}}.pb.h", |
89 ] | 93 ] |
90 | 94 |
91 args = [] | 95 args = [] |
92 if (defined(invoker.cc_include)) { | 96 if (defined(invoker.cc_include)) { |
93 args += [ | 97 args += [ |
94 "--include", | 98 "--include", |
95 invoker.cc_include, | 99 invoker.cc_include, |
96 ] | 100 ] |
(...skipping 29 matching lines...) Expand all Loading... |
126 if (defined(invoker.cc_generator_options)) { | 130 if (defined(invoker.cc_generator_options)) { |
127 cc_generator_options = invoker.cc_generator_options | 131 cc_generator_options = invoker.cc_generator_options |
128 } else { | 132 } else { |
129 cc_generator_options = "" | 133 cc_generator_options = "" |
130 } | 134 } |
131 args += [ | 135 args += [ |
132 # cc_generator_options is supposed to end in a colon if it's nonempty. | 136 # cc_generator_options is supposed to end in a colon if it's nonempty. |
133 "--cpp_out", | 137 "--cpp_out", |
134 "$cc_generator_options$rel_out_dir", | 138 "$cc_generator_options$rel_out_dir", |
135 "--python_out", | 139 "--python_out", |
136 rel_out_dir, | 140 rel_py_out_dir, |
137 ] | 141 ] |
138 | 142 |
139 deps = [ | 143 deps = [ |
140 protoc_label, | 144 protoc_label, |
141 ] | 145 ] |
142 | 146 |
143 if (defined(invoker.deps)) { | 147 if (defined(invoker.deps)) { |
144 deps += invoker.deps | 148 deps += invoker.deps |
145 } | 149 } |
146 } | 150 } |
(...skipping 17 matching lines...) Expand all Loading... |
164 public_deps = [ | 168 public_deps = [ |
165 # The generated headers reference headers within protobuf_lite, so | 169 # The generated headers reference headers within protobuf_lite, so |
166 # dependencies must be able to find those headers too. | 170 # dependencies must be able to find those headers too. |
167 "//third_party/protobuf:protobuf_lite", | 171 "//third_party/protobuf:protobuf_lite", |
168 ] | 172 ] |
169 deps = [ | 173 deps = [ |
170 ":$action_name", | 174 ":$action_name", |
171 ] | 175 ] |
172 } | 176 } |
173 } | 177 } |
OLD | NEW |