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%': '', | |
47 # protoc.gypi will place generated files into subdirectories based on the | |
Ryan Sleevi
2012/02/17 00:31:21
As per my previous comment, this should be placed
| |
48 # relative path between proto_in_dir and the source protos. This is | |
49 # shown by the --proto_path usage below. | |
50 # | |
51 # proto_relpath exists because there are some protos which import | |
52 # using qualified paths, rather than the more common relative import. | |
53 # By using proto_relpath, projects can continue to use qualified imports | |
54 # instead of enforcing an import style through this gypi. | |
55 # | |
56 # For an example of such a proto implementation, see: | |
57 # third_party/cacheinvalidation/ | |
58 # | |
59 # If provided, 'proto_relpath' must have a trailing slash, otherwise | |
60 # it will be concatenated with RULE_INPUT_ROOT in 'outputs' and | |
Ryan Sleevi
2012/02/17 00:31:21
You don't need the "otherwise" - it's an error to
| |
61 # 'action' below. | |
46 }, | 62 }, |
47 'rules': [ | 63 'rules': [ |
48 { | 64 { |
49 'rule_name': 'genproto', | 65 'rule_name': 'genproto', |
50 'extension': 'proto', | 66 'extension': 'proto', |
51 'inputs': [ | 67 'inputs': [ |
52 '<(protoc)', | 68 '<(protoc)', |
53 ], | 69 ], |
54 'outputs': [ | 70 'outputs': [ |
55 '<(py_dir)/<(RULE_INPUT_ROOT)_pb2.py', | 71 '<(py_dir)/<(proto_relpath)<(RULE_INPUT_ROOT)_pb2.py', |
56 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.cc', | 72 '<(cc_dir)/<(proto_relpath)<(RULE_INPUT_ROOT).pb.cc', |
57 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', | 73 '<(cc_dir)/<(proto_relpath)<(RULE_INPUT_ROOT).pb.h', |
58 ], | 74 ], |
59 'action': [ | 75 'action': [ |
60 '<(protoc)', | 76 '<(protoc)', |
61 '--proto_path=<(proto_in_dir)', | 77 '--proto_path=<(proto_in_dir)', |
62 # Naively you'd use <(RULE_INPUT_PATH) here, but protoc requires | 78 # 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. | 79 # --proto_path is a strict prefix of the path given as an argument. |
64 '<(proto_in_dir)/<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)', | 80 '<(proto_in_dir)/<(proto_relpath)<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)', |
65 '--cpp_out=<(cc_dir)', | 81 '--cpp_out=<(cc_dir)', |
66 '--python_out=<(py_dir)', | 82 '--python_out=<(py_dir)', |
67 ], | 83 ], |
68 'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)', | 84 'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)', |
69 'process_outputs_as_sources': 1, | 85 'process_outputs_as_sources': 1, |
70 }, | 86 }, |
71 ], | 87 ], |
72 'dependencies': [ | 88 'dependencies': [ |
73 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host', | 89 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host', |
74 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | 90 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', |
75 ], | 91 ], |
76 'include_dirs': [ | 92 'include_dirs': [ |
77 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', | 93 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', |
78 ], | 94 ], |
79 'direct_dependent_settings': { | 95 'direct_dependent_settings': { |
80 'include_dirs': [ | 96 'include_dirs': [ |
81 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', | 97 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', |
82 ] | 98 ] |
83 }, | 99 }, |
84 'export_dependent_settings': [ | 100 'export_dependent_settings': [ |
85 # The generated headers reference headers within protobuf_lite, | 101 # The generated headers reference headers within protobuf_lite, |
86 # so dependencies must be able to find those headers too. | 102 # so dependencies must be able to find those headers too. |
87 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | 103 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', |
88 ], | 104 ], |
89 # This target exports a hard dependency because it generates header | 105 # This target exports a hard dependency because it generates header |
90 # files. | 106 # files. |
91 'hard_dependency': 1, | 107 'hard_dependency': 1, |
92 } | 108 } |
OLD | NEW |