OLD | NEW |
---|---|
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 # This file is meant to be included into an target to provide a rule | 5 # This file is meant to be included into an target to provide a rule |
6 # to invoke protoc in a consistent manner. | 6 # to invoke protoc in a consistent manner. |
7 # | 7 # |
8 # To use this, create a gyp target with the following form: | 8 # To use this, create a gyp target with the following form: |
9 # { | 9 # { |
10 # 'target_name': 'my_proto_lib', | 10 # 'target_name': 'my_proto_lib', |
(...skipping 25 matching lines...) Expand all Loading... | |
36 # A proto_out_dir of foo/bar produces | 36 # A proto_out_dir of foo/bar produces |
37 # <(SHARED_INTERMEDIATE_DIR)/protoc_out/foo/bar/{file1,file2}.pb.{cc,h} | 37 # <(SHARED_INTERMEDIATE_DIR)/protoc_out/foo/bar/{file1,file2}.pb.{cc,h} |
38 # <(SHARED_INTERMEDIATE_DIR)/pyproto/foo/bar/{file1,file2}_pb2.py | 38 # <(SHARED_INTERMEDIATE_DIR)/pyproto/foo/bar/{file1,file2}_pb2.py |
39 | 39 |
40 { | 40 { |
41 'variables': { | 41 'variables': { |
42 'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)', | 42 'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)', |
43 'cc_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out/<(proto_out_dir)', | 43 'cc_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out/<(proto_out_dir)', |
44 'py_dir': '<(PRODUCT_DIR)/pyproto/<(proto_out_dir)', | 44 'py_dir': '<(PRODUCT_DIR)/pyproto/<(proto_out_dir)', |
45 'proto_in_dir%': '.', | 45 'proto_in_dir%': '.', |
46 'proto_relpath%': '.', | |
Ryan Sleevi
2012/02/15 20:15:29
Can you please add examples to the documentation a
Evan Martin
2012/02/15 20:19:51
If you define this as "must have a trailing slash
Ryan Sleevi
2012/02/16 09:23:49
This comment had not been addressed. The explanati
| |
46 }, | 47 }, |
47 'rules': [ | 48 'rules': [ |
48 { | 49 { |
49 'rule_name': 'genproto', | 50 'rule_name': 'genproto', |
50 'extension': 'proto', | 51 'extension': 'proto', |
51 'inputs': [ | 52 'inputs': [ |
52 '<(protoc)', | 53 '<(protoc)', |
53 ], | 54 ], |
54 'outputs': [ | 55 'outputs': [ |
55 '<(py_dir)/<(RULE_INPUT_ROOT)_pb2.py', | 56 '<(py_dir)/<(proto_relpath)/<(RULE_INPUT_ROOT)_pb2.py', |
56 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.cc', | 57 '<(cc_dir)/<(proto_relpath)/<(RULE_INPUT_ROOT).pb.cc', |
57 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', | 58 '<(cc_dir)/<(proto_relpath)/<(RULE_INPUT_ROOT).pb.h', |
58 ], | 59 ], |
59 'action': [ | 60 'action': [ |
60 '<(protoc)', | 61 '<(protoc)', |
61 '--proto_path=<(proto_in_dir)', | 62 '--proto_path=<(proto_in_dir)', |
62 # Naively you'd use <(RULE_INPUT_PATH) here, but protoc requires | 63 # Naively you'd use <(RULE_INPUT_PATH) here, but protoc requires |
63 # --proto_path is a strict prefix of the path given as an argument. | 64 # --proto_path is a strict prefix of the path given as an argument. |
64 '<(proto_in_dir)/<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)', | 65 '<(proto_in_dir)/<(proto_relpath)/<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)', |
65 '--cpp_out=<(cc_dir)', | 66 '--cpp_out=<(cc_dir)', |
66 '--python_out=<(py_dir)', | 67 '--python_out=<(py_dir)', |
67 ], | 68 ], |
68 'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)', | 69 'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)', |
69 'process_outputs_as_sources': 1, | 70 'process_outputs_as_sources': 1, |
70 }, | 71 }, |
71 ], | 72 ], |
72 'dependencies': [ | 73 'dependencies': [ |
73 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host', | 74 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host', |
74 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | 75 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', |
75 ], | 76 ], |
76 'include_dirs': [ | 77 'include_dirs': [ |
77 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', | 78 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', |
78 ], | 79 ], |
79 'direct_dependent_settings': { | 80 'direct_dependent_settings': { |
80 'include_dirs': [ | 81 'include_dirs': [ |
81 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', | 82 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', |
82 ] | 83 ] |
83 }, | 84 }, |
84 'export_dependent_settings': [ | 85 'export_dependent_settings': [ |
85 # The generated headers reference headers within protobuf_lite, | 86 # The generated headers reference headers within protobuf_lite, |
86 # so dependencies must be able to find those headers too. | 87 # so dependencies must be able to find those headers too. |
87 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | 88 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', |
88 ], | 89 ], |
89 # This target exports a hard dependency because it generates header | 90 # This target exports a hard dependency because it generates header |
90 # files. | 91 # files. |
91 'hard_dependency': 1, | 92 'hard_dependency': 1, |
92 } | 93 } |
OLD | NEW |