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

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

Issue 289953004: Add GPU command buffer sevice and protobuf to GN build (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/protobuf/BUILD.gn ('k') | ui/gfx/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 # Compile a protocol buffer.
6 #
7 # The 'proto_in_dir' variable must be the relative path to the
8 # directory containing the .proto files. If left out, it defaults to '.'.
9 #
10 # The 'proto_out_dir' variable specifies the path suffix that output files are
11 # generated under. Targets that gyp-depend on my_proto_lib will be able to
12 # include the resulting proto headers with an include like:
13 # #include "dir/for/my_proto_lib/foo.pb.h"
14 # If undefined, this defaults to matching the input directory.
15 #
16 # If you need to add an EXPORT macro to a protobuf's C++ header, set the
17 # 'cc_generator_options' variable with the value: 'dllexport_decl=FOO_EXPORT:'
18 # e.g. 'dllexport_decl=BASE_EXPORT:'
19 #
20 # It is likely you also need to #include a file for the above EXPORT macro to
21 # work. You can do so with the 'cc_include' variable.
22 # e.g. 'base/base_export.h'
23 #
24 # Example:
25 # proto_library("mylib") {
26 # sources = [
27 # "foo.proto",
28 # ]
29 # }
30
31 template("proto_library") {
32 assert(defined(invoker.sources), "Need sources for proto_library")
33
34 action_name = "${target_name}_gen"
35 source_set_name = target_name
36 action_foreach(action_name) {
37 visibility = ":$source_set_name"
38
39 script = "//tools/protoc_wrapper/protoc_wrapper.py"
40
41 sources = invoker.sources
42
43 # TODO(brettw) it would be better if this used the target gen dir.
44 if (defined(invoker.proto_out_dir)) {
45 proto_out_dir = invoker.proto_out_dir
46 } else {
47 # This computes the relative path inside the target_gen_dir that
48 # we'd put the files in, which maps to the current directory path.
49 # We'll insert "protoc_out" at the beginning for compatibility with GYP.
50 proto_out_dir = rebase_path(target_gen_dir, root_gen_dir)
51 }
52 cc_dir = "$root_gen_dir/protoc_out/$proto_out_dir"
53 py_dir = "$root_gen_dir/pyproto/$proto_out_dir"
54
55 outputs = [
56 "$py_dir/{{source_name_part}}_pb2.py",
57 "$cc_dir/{{source_name_part}}.pb.cc",
58 "$cc_dir/{{source_name_part}}.pb.h",
59 ]
60
61 args = []
62 if (defined(invoker.cc_include)) {
63 args += [ "--include", invoker.cc_include ]
64 }
65
66 args += [
67 "--protobuf",
68 rebase_path("$cc_dir/{{source_name_part}}.pb.h", root_build_dir),
69 ]
70
71 if (defined(invoker.proto_in_dir)) {
72 proto_in_dir = invoker.proto_in_dir
73 } else {
74 # Extract the current source dir.
75 proto_in_dir = get_label_info(":$target_name", "dir")
76 }
77 args += [
78 "--proto-in-dir",
79 rebase_path(proto_in_dir, root_build_dir),
80 "--proto-in-file", "{{source_file_part}}",
81 # TODO(brettw) support system protobuf compiler.
82 "--use-system-protobuf=0",
83 ]
84
85 protoc_label = "//third_party/protobuf:protoc($host_toolchain)"
86 args += [
87 "--",
88 # Prepend with "./" so this will never pick up the system one (normally
89 # when not cross-compiling, protoc's output directory will be the same
90 # as the build dir, so the relative location will be empty.
91 "./" + rebase_path(get_label_info(protoc_label, "root_out_dir") +
92 "/protoc", root_build_dir),
93 ]
94
95 # If passed cc_generator_options should end in a colon, which will separate
96 # it from the directory when we concatenate them. The proto compiler
97 # understands this syntax.
98 if (defined(invoker.cc_generator_options)) {
99 cc_generator_options = invoker.cc_generator_options
100 } else {
101 cc_generator_options = ""
102 }
103 args += [
104 "--cpp_out", cc_generator_options + rebase_path(cc_dir, root_build_dir),
105 "--python_out", rebase_path(py_dir, root_build_dir),
106 ]
107
108 deps = [ protoc_label ]
109 }
110
111 source_set(target_name) {
112 if (defined(invoker.visibility)) {
113 visibility = invoker.visibility
114 }
115
116 sources = get_target_outputs(":$action_name")
117
118 direct_dependent_configs = [ "//third_party/protobuf:using_proto" ]
119
120 deps = [
121 ":$action_name",
122 "//third_party/protobuf:protobuf_lite",
123 ]
124 }
125 }
OLDNEW
« no previous file with comments | « third_party/protobuf/BUILD.gn ('k') | ui/gfx/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698