Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: third_party/protobuf/proto_library.gni

Issue 386943006: Pull buildtools to get GN r282653 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/libphonenumber/BUILD.gn ('k') | tools/gn/file_template.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_in_dir (optional) 9 # proto_out_dir (optional)
10 # The path to the directory containing the .proto files. If left out, it 10 # Specifies the path suffix that output files are generated under. This
11 # defaults to '.'. 11 # path will be appended to the root_gen_dir.
12 # 12 #
13 # proto_out_dir (optional) 13 # Targets that depend on the proto target will be able to include the
14 # Specifies the path suffix that output files are generated under.
15 # Targets that gyp-depend on my_proto_lib will be able to include the
16 # resulting proto headers with an include like: 14 # resulting proto headers with an include like:
17 # #include "dir/for/my_proto_lib/foo.pb.h" 15 # #include "dir/for/my_proto_lib/foo.pb.h"
18 # If undefined, this defaults to matching the input directory. 16 # If undefined, this defaults to matching the input directory for each
17 # .proto file (you should almost always use the default mode).
19 # 18 #
20 # cc_generator_options (optional) 19 # cc_generator_options (optional)
21 # List of extra flags passed to the protocol compiler. If you need to 20 # List of extra flags passed to the protocol compiler. If you need to
22 # add an EXPORT macro to a protobuf's C++ header, set the 21 # add an EXPORT macro to a protobuf's C++ header, set the
23 # 'cc_generator_options' variable with the value: 22 # 'cc_generator_options' variable with the value:
24 # 'dllexport_decl=FOO_EXPORT:' (note trailing colon). 23 # 'dllexport_decl=FOO_EXPORT:' (note trailing colon).
25 # 24 #
26 # It is likely you also need to #include a file for the above EXPORT 25 # It is likely you also need to #include a file for the above EXPORT
27 # macro to work. See cc_include. 26 # macro to work. See cc_include.
28 # 27 #
(...skipping 26 matching lines...) Expand all
55 54
56 action_name = "${target_name}_gen" 55 action_name = "${target_name}_gen"
57 source_set_name = target_name 56 source_set_name = target_name
58 action_foreach(action_name) { 57 action_foreach(action_name) {
59 visibility = ":$source_set_name" 58 visibility = ":$source_set_name"
60 59
61 script = "//tools/protoc_wrapper/protoc_wrapper.py" 60 script = "//tools/protoc_wrapper/protoc_wrapper.py"
62 61
63 sources = invoker.sources 62 sources = invoker.sources
64 63
65 # TODO(brettw) it would be better if this used the target gen dir. 64 # Compute the output directory, both relative to the source root (for
65 # declaring "outputs") and relative to the build dir (for passing to the
66 # script).
66 if (defined(invoker.proto_out_dir)) { 67 if (defined(invoker.proto_out_dir)) {
67 proto_out_dir = invoker.proto_out_dir 68 # Put the results in the specified dir in the gen tree.
69 out_dir = "$root_gen_dir/" + invoker.proto_out_dir
70 rel_out_dir = rebase_path(out_dir, root_build_dir)
68 } else { 71 } else {
69 # This computes the relative path inside the target_gen_dir that 72 # Use the gen directory corresponding to the source file. This expansion
70 # we'd put the files in, which maps to the current directory path. 73 # will be done differently in the outputs and the args, so we don't need
71 # We'll insert "protoc_out" at the beginning for compatibility with GYP. 74 # to worry about rebasing as above.
72 proto_out_dir = rebase_path(target_gen_dir, root_gen_dir) 75 out_dir = "{{source_gen_dir}}"
76 rel_out_dir = "{{source_gen_dir}}"
73 } 77 }
74 cc_dir = "$root_gen_dir/protoc_out/$proto_out_dir"
75 py_dir = "$root_gen_dir/pyproto/$proto_out_dir"
76 78
77 outputs = [ 79 outputs = [
78 "$py_dir/{{source_name_part}}_pb2.py", 80 "$out_dir/{{source_name_part}}_pb2.py",
79 "$cc_dir/{{source_name_part}}.pb.cc", 81 "$out_dir/{{source_name_part}}.pb.cc",
80 "$cc_dir/{{source_name_part}}.pb.h", 82 "$out_dir/{{source_name_part}}.pb.h",
81 ] 83 ]
82 84
83 args = [] 85 args = []
84 if (defined(invoker.cc_include)) { 86 if (defined(invoker.cc_include)) {
85 args += [ "--include", invoker.cc_include ] 87 args += [ "--include", invoker.cc_include ]
86 } 88 }
87 89
88 args += [ 90 args += [
89 "--protobuf", 91 "--protobuf", "$rel_out_dir/{{source_name_part}}.pb.h",
90 rebase_path("$cc_dir/{{source_name_part}}.pb.h", root_build_dir), 92 "--proto-in-dir", "{{source_dir}}",
91 ]
92
93 if (defined(invoker.proto_in_dir)) {
94 proto_in_dir = invoker.proto_in_dir
95 } else {
96 # Extract the current source dir.
97 proto_in_dir = get_label_info(":$target_name", "dir")
98 }
99 args += [
100 "--proto-in-dir",
101 rebase_path(proto_in_dir, root_build_dir),
102 "--proto-in-file", "{{source_file_part}}", 93 "--proto-in-file", "{{source_file_part}}",
103 # TODO(brettw) support system protobuf compiler. 94 # TODO(brettw) support system protobuf compiler.
104 "--use-system-protobuf=0", 95 "--use-system-protobuf=0",
105 ] 96 ]
106 97
107 protoc_label = "//third_party/protobuf:protoc($host_toolchain)" 98 protoc_label = "//third_party/protobuf:protoc($host_toolchain)"
108 args += [ 99 args += [
109 "--", 100 "--",
110 # Prepend with "./" so this will never pick up the system one (normally 101 # Prepend with "./" so this will never pick up the system one (normally
111 # when not cross-compiling, protoc's output directory will be the same 102 # when not cross-compiling, protoc's output directory will be the same
112 # as the build dir, so the relative location will be empty. 103 # as the build dir, so the relative location will be empty).
113 "./" + rebase_path(get_label_info(protoc_label, "root_out_dir") + 104 "./" + rebase_path(get_label_info(protoc_label, "root_out_dir") +
114 "/protoc", root_build_dir), 105 "/protoc", root_build_dir),
115 ] 106 ]
116 107
117 # If passed cc_generator_options should end in a colon, which will separate 108 # If passed cc_generator_options should end in a colon, which will separate
118 # it from the directory when we concatenate them. The proto compiler 109 # it from the directory when we concatenate them. The proto compiler
119 # understands this syntax. 110 # understands this syntax.
120 if (defined(invoker.cc_generator_options)) { 111 if (defined(invoker.cc_generator_options)) {
121 cc_generator_options = invoker.cc_generator_options 112 cc_generator_options = invoker.cc_generator_options
122 } else { 113 } else {
123 cc_generator_options = "" 114 cc_generator_options = ""
124 } 115 }
125 args += [ 116 args += [
126 "--cpp_out", cc_generator_options + rebase_path(cc_dir, root_build_dir), 117 # cc_generator_options is supposed to end in a colon if it's nonempty.
127 "--python_out", rebase_path(py_dir, root_build_dir), 118 "--cpp_out", "$cc_generator_options$rel_out_dir",
119 "--python_out", rel_out_dir,
128 ] 120 ]
129 121
130 deps = [ protoc_label ] 122 deps = [ protoc_label ]
131 123
132 if (defined(invoker.deps)) { 124 if (defined(invoker.deps)) {
133 deps += invoker.deps 125 deps += invoker.deps
134 } 126 }
135 } 127 }
136 128
137 source_set(target_name) { 129 source_set(target_name) {
(...skipping 15 matching lines...) Expand all
153 deps = [ 145 deps = [
154 ":$action_name", 146 ":$action_name",
155 "//third_party/protobuf:protobuf_lite", 147 "//third_party/protobuf:protobuf_lite",
156 ] 148 ]
157 149
158 # The generated headers reference headers within protobuf_lite, so 150 # The generated headers reference headers within protobuf_lite, so
159 # dependencies must be able to find those headers too. 151 # dependencies must be able to find those headers too.
160 forward_dependent_configs_from = [ "//third_party/protobuf:protobuf_lite" ] 152 forward_dependent_configs_from = [ "//third_party/protobuf:protobuf_lite" ]
161 } 153 }
162 } 154 }
OLDNEW
« no previous file with comments | « third_party/libphonenumber/BUILD.gn ('k') | tools/gn/file_template.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698