OLD | NEW |
| (Empty) |
1 # Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | |
2 # | |
3 # Use of this source code is governed by a BSD-style license | |
4 # that can be found in the LICENSE file in the root of the source | |
5 # tree. An additional intellectual property rights grant can be found | |
6 # in the file PATENTS. All contributing project authors may | |
7 # be found in the AUTHORS file in the root of the source tree. | |
8 | |
9 # Copied from Chromium's src/build/protoc.gypi | |
10 # | |
11 # It was necessary to copy this file to WebRTC, because the path to | |
12 # build/common.gypi is different for the standalone and Chromium builds. Gyp | |
13 # doesn't permit conditional inclusion or variable expansion in include paths. | |
14 # http://code.google.com/p/gyp/wiki/InputFormatReference#Including_Other_Files | |
15 # | |
16 # Local changes: | |
17 # * Removed <(DEPTH) from include_dir due to difficulties with generated | |
18 # downstream code. | |
19 | |
20 | |
21 # This file is meant to be included into a target to provide a rule | |
22 # to invoke protoc in a consistent manner. For Java-targets, see | |
23 # protoc_java.gypi. | |
24 # | |
25 # To use this, create a gyp target with the following form: | |
26 # { | |
27 # 'target_name': 'my_proto_lib', | |
28 # 'type': 'static_library', | |
29 # 'sources': [ | |
30 # 'foo.proto', | |
31 # 'bar.proto', | |
32 # ], | |
33 # 'variables': { | |
34 # # Optional, see below: 'proto_in_dir': '.' | |
35 # 'proto_out_dir': 'dir/for/my_proto_lib' | |
36 # }, | |
37 # 'includes': ['path/to/this/gypi/file'], | |
38 # } | |
39 # If necessary, you may add normal .cc files to the sources list or other gyp | |
40 # dependencies. The proto headers are guaranteed to be generated before any | |
41 # source files, even within this target, are compiled. | |
42 # | |
43 # The 'proto_in_dir' variable must be the relative path to the | |
44 # directory containing the .proto files. If left out, it defaults to '.'. | |
45 # | |
46 # The 'proto_out_dir' variable specifies the path suffix that output | |
47 # files are generated under. Targets that gyp-depend on my_proto_lib | |
48 # will be able to include the resulting proto headers with an include | |
49 # like: | |
50 # #include "dir/for/my_proto_lib/foo.pb.h" | |
51 # | |
52 # If you need to add an EXPORT macro to a protobuf's c++ header, set the | |
53 # 'cc_generator_options' variable with the value: 'dllexport_decl=FOO_EXPORT:' | |
54 # e.g. 'dllexport_decl=BASE_EXPORT:' | |
55 # | |
56 # It is likely you also need to #include a file for the above EXPORT macro to | |
57 # work. You can do so with the 'cc_include' variable. | |
58 # e.g. 'base/base_export.h' | |
59 # | |
60 # Implementation notes: | |
61 # A proto_out_dir of foo/bar produces | |
62 # <(SHARED_INTERMEDIATE_DIR)/protoc_out/foo/bar/{file1,file2}.pb.{cc,h} | |
63 # <(SHARED_INTERMEDIATE_DIR)/pyproto/foo/bar/{file1,file2}_pb2.py | |
64 | |
65 { | |
66 'variables': { | |
67 'protoc_wrapper': '<(DEPTH)/tools/protoc_wrapper/protoc_wrapper.py', | |
68 'cc_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out/<(proto_out_dir)', | |
69 'py_dir': '<(PRODUCT_DIR)/pyproto/<(proto_out_dir)', | |
70 'cc_generator_options%': '', | |
71 'cc_include%': '', | |
72 'proto_in_dir%': '.', | |
73 'conditions': [ | |
74 ['use_system_protobuf==0', { | |
75 'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)
', | |
76 }, { # use_system_protobuf==1 | |
77 'protoc': '<!(which protoc)', | |
78 }], | |
79 ], | |
80 }, | |
81 'rules': [ | |
82 { | |
83 'rule_name': 'genproto', | |
84 'extension': 'proto', | |
85 'inputs': [ | |
86 '<(protoc_wrapper)', | |
87 '<(protoc)', | |
88 ], | |
89 'outputs': [ | |
90 '<(py_dir)/<(RULE_INPUT_ROOT)_pb2.py', | |
91 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.cc', | |
92 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', | |
93 ], | |
94 'action': [ | |
95 'python', | |
96 '<(protoc_wrapper)', | |
97 '--protoc', | |
98 '<(protoc)', | |
99 # Using the --arg val form (instead of --arg=val) allows gyp's msvs rule | |
100 # generation to correct 'val' which is a path. | |
101 '--proto-in-dir','<(proto_in_dir)', | |
102 # Naively you'd use <(RULE_INPUT_PATH) here, but protoc requires | |
103 # --proto_path is a strict prefix of the path given as an argument. | |
104 '--cc-out-dir', '<(cc_generator_options)<(cc_dir)', | |
105 '--py-out-dir', '<(py_dir)', | |
106 '<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)', | |
107 ], | |
108 'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)', | |
109 'process_outputs_as_sources': 1, | |
110 }, | |
111 ], | |
112 'include_dirs': [ | |
113 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', | |
114 ], | |
115 'direct_dependent_settings': { | |
116 'include_dirs': [ | |
117 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', | |
118 ] | |
119 }, | |
120 # This target exports a hard dependency because it generates header | |
121 # files. | |
122 'hard_dependency': 1, | |
123 'conditions': [ | |
124 ['build_protobuf==1', { | |
125 'dependencies': [ | |
126 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host', | |
127 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | |
128 ], | |
129 'export_dependent_settings': [ | |
130 # The generated headers reference headers within protobuf_lite, | |
131 # so dependencies must be able to find those headers too. | |
132 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | |
133 ], | |
134 }], | |
135 ], | |
136 } | |
OLD | NEW |