OLD | NEW |
---|---|
(Empty) | |
1 # Copyright (c) 2011 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 # This file is meant to be included into an target to provide a rule | |
6 # to invoke protoc in a consistent manner. | |
7 # | |
8 # To use this, create a gyp target with the following form: | |
9 # { | |
10 # 'target_name': 'my_proto_lib', | |
11 # 'sources': [ | |
12 # 'foo.proto', | |
13 # 'bar.proto', | |
14 # ], | |
15 # 'variables': { | |
16 # 'proto_in_dir': '.' | |
17 # 'proto_out_dir': 'dir/for/my_proto_lib' | |
18 # }, | |
19 # 'includes': ['path/to/this/gypi/file'], | |
20 # } | |
21 # If necessary, you may add normal .cc files to the sources list or other gyp | |
22 # dependencies. The proto headers are guaranteed to be generated before any | |
23 # source files, even within this target, are compiled. | |
24 # | |
25 # The 'proto_in_dir' variable must be the relative path to the | |
26 # directory containing the .proto files. | |
27 # | |
28 # The 'proto_out_dir' variable specifies the path suffix that output | |
29 # files are generated under. Targets that gyp-depend on my_proto_lib | |
30 # will be able to include the resulting proto headers with an include | |
31 # like: | |
32 # #include "dir/for/my_proto_lib/foo.pb.h" | |
33 # | |
34 # Implementation notes: | |
35 # A proto_out_dir of foo/bar produces | |
36 # <(SHARED_INTERMEDIATE_DIR)/protoc_out/foo/bar/{file1,file2}.pb.{cc,h} | |
37 # <(SHARED_INTERMEDIATE_DIR)/pyproto/foo/bar/{file1,file2}_pb2.py | |
38 | |
39 { | |
40 'variables': { | |
41 'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)', | |
42 'cc_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out/<(proto_out_dir)', | |
43 'py_dir': '<(PRODUCT_DIR)/pyproto/<(proto_out_dir)', | |
TVL
2011/08/18 20:56:50
'proto_in_dir?': '.'
if it's common?
Evan Martin
2011/08/18 21:12:43
Did you mean %? The only use of '?' I could find
TVL
2011/08/19 13:18:27
Yes, sorry.
| |
44 }, | |
45 'rules': [ | |
46 { | |
47 'rule_name': 'genproto', | |
48 'extension': 'proto', | |
49 'inputs': [ | |
50 '<(protoc)', | |
51 ], | |
52 'outputs': [ | |
53 '<(py_dir)/<(RULE_INPUT_ROOT)_pb2.py', | |
54 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.cc', | |
55 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', | |
56 ], | |
57 'action': [ | |
58 '<(protoc)', | |
59 '--proto_path=<(proto_in_dir)', | |
60 # Naively you'd use <(RULE_INPUT_PATH) here, but protoc requires | |
61 # --proto_path is a strict prefix of the path given as an argument. | |
62 '<(proto_in_dir)/<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)', | |
63 '--cpp_out=<(cc_dir)', | |
64 '--python_out=<(py_dir)', | |
65 ], | |
66 'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)', | |
67 'process_outputs_as_sources': 1, | |
68 }, | |
69 ], | |
70 'dependencies': [ | |
71 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host', | |
72 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | |
73 ], | |
74 'include_dirs': [ | |
75 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', | |
76 ], | |
77 'direct_dependent_settings': { | |
78 'include_dirs': [ | |
79 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', | |
80 ] | |
81 }, | |
82 # This target exports a hard dependency because it generates header | |
83 # files. | |
84 'hard_dependency': 1, | |
85 } | |
OLD | NEW |