Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 a target to provide a rule | 5 # This file is meant to be included into a target to provide a rule |
| 6 # to invoke protoc in a consistent manner. For Java-targets, see | 6 # to invoke protoc in a consistent manner. For Java-targets, see |
| 7 # protoc_java.gypi. | 7 # protoc_java.gypi. |
| 8 # | 8 # |
| 9 # To use this, create a gyp target with the following form: | 9 # To use this, create a gyp target with the following form: |
| 10 # { | 10 # { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 # A proto_out_dir of foo/bar produces | 45 # A proto_out_dir of foo/bar produces |
| 46 # <(SHARED_INTERMEDIATE_DIR)/protoc_out/foo/bar/{file1,file2}.pb.{cc,h} | 46 # <(SHARED_INTERMEDIATE_DIR)/protoc_out/foo/bar/{file1,file2}.pb.{cc,h} |
| 47 # <(SHARED_INTERMEDIATE_DIR)/pyproto/foo/bar/{file1,file2}_pb2.py | 47 # <(SHARED_INTERMEDIATE_DIR)/pyproto/foo/bar/{file1,file2}_pb2.py |
| 48 | 48 |
| 49 { | 49 { |
| 50 'variables': { | 50 'variables': { |
| 51 'protoc_wrapper': '<(DEPTH)/tools/protoc_wrapper/protoc_wrapper.py', | 51 'protoc_wrapper': '<(DEPTH)/tools/protoc_wrapper/protoc_wrapper.py', |
| 52 'cc_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out/<(proto_out_dir)', | 52 'cc_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out/<(proto_out_dir)', |
| 53 'py_dir': '<(PRODUCT_DIR)/pyproto/<(proto_out_dir)', | 53 'py_dir': '<(PRODUCT_DIR)/pyproto/<(proto_out_dir)', |
| 54 'cc_generator_options%': '', | 54 'cc_generator_options%': '', |
| 55 'generate_python%': 1, | |
| 56 'generate_cc%': 1, | |
| 57 # Custom plugin target name. | |
| 58 # If passed, generator_plugin_suffix (before .cc and .h) is also required. | |
| 59 'generator_plugin%': '', | |
|
xyzzyz
2016/06/21 20:29:44
Could you rename it to "cc_generator_plugin" to ma
| |
| 60 'generator_plugin_options%': '', | |
| 55 'cc_include%': '', | 61 'cc_include%': '', |
| 56 'proto_in_dir%': '.', | 62 'proto_in_dir%': '.', |
| 57 'conditions': [ | 63 'conditions': [ |
| 58 ['use_system_protobuf==0', { | 64 ['use_system_protobuf==0', { |
| 59 'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX) ', | 65 'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX) ', |
| 60 }, { # use_system_protobuf==1 | 66 }, { # use_system_protobuf==1 |
| 61 'protoc': '<!(which protoc)', | 67 'protoc': '<!(which protoc)', |
| 62 }], | 68 }], |
| 63 ], | 69 ], |
| 64 }, | 70 }, |
| 65 'rules': [ | 71 'rules': [ |
| 66 { | 72 { |
| 67 'rule_name': 'genproto', | 73 'rule_name': 'genproto', |
| 68 'extension': 'proto', | 74 'extension': 'proto', |
| 69 'inputs': [ | 75 'inputs': [ |
| 70 '<(protoc_wrapper)', | 76 '<(protoc_wrapper)', |
| 71 '<(protoc)', | 77 '<(protoc)', |
| 72 ], | 78 ], |
| 73 'outputs': [ | |
| 74 '<(py_dir)/<(RULE_INPUT_ROOT)_pb2.py', | |
| 75 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.cc', | |
| 76 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', | |
| 77 ], | |
| 78 'action': [ | 79 'action': [ |
| 79 'python', | 80 'python', |
| 80 '<(protoc_wrapper)', | 81 '<(protoc_wrapper)', |
| 82 # If no cc_include specified --protobuf option will be ignored. | |
| 81 '--include', | 83 '--include', |
| 82 '<(cc_include)', | 84 '<(cc_include)', |
| 83 '--protobuf', | 85 '--protobuf', |
| 84 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', | 86 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', |
| 85 # Using the --arg val form (instead of --arg=val) allows gyp's msvs rule | 87 # Using the --arg val form (instead of --arg=val) allows gyp's msvs rule |
| 86 # generation to correct 'val' which is a path. | 88 # generation to correct 'val' which is a path. |
| 87 '--proto-in-dir','<(proto_in_dir)', | 89 '--proto-in-dir','<(proto_in_dir)', |
| 88 # Naively you'd use <(RULE_INPUT_PATH) here, but protoc requires | 90 # Naively you'd use <(RULE_INPUT_PATH) here, but protoc requires |
| 89 # --proto_path is a strict prefix of the path given as an argument. | 91 # --proto_path is a strict prefix of the path given as an argument. |
| 90 '--proto-in-file','<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)', | 92 '--proto-in-file','<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)', |
| 91 '--use-system-protobuf=<(use_system_protobuf)', | 93 '--use-system-protobuf=<(use_system_protobuf)', |
| 92 '--', | 94 '--', |
| 93 '<(protoc)', | 95 '<(protoc)', |
| 94 '--cpp_out', '<(cc_generator_options)<(cc_dir)', | |
| 95 '--python_out', '<(py_dir)', | |
| 96 ], | 96 ], |
| 97 'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)', | 97 'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)', |
| 98 'process_outputs_as_sources': 1, | 98 'process_outputs_as_sources': 1, |
| 99 | |
| 100 'conditions': [ | |
| 101 ['generate_python==1', { | |
| 102 'outputs': [ | |
| 103 '<(py_dir)/<(RULE_INPUT_ROOT)_pb2.py', | |
| 104 ], | |
| 105 'action': [ | |
| 106 '--python_out', | |
| 107 '<(py_dir)', | |
| 108 ], | |
| 109 }], | |
| 110 ['generate_cc==1', { | |
| 111 'outputs': [ | |
| 112 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.cc', | |
| 113 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', | |
| 114 ], | |
| 115 'action': [ | |
| 116 '--cpp_out', | |
| 117 '<(cc_generator_options)<(cc_dir)', | |
| 118 ], | |
| 119 }], | |
| 120 ['generator_plugin!=""', { | |
| 121 'outputs': [ | |
| 122 '<(cc_dir)/<(RULE_INPUT_ROOT)<(generator_plugin_suffix).cc', | |
| 123 '<(cc_dir)/<(RULE_INPUT_ROOT)<(generator_plugin_suffix).h', | |
| 124 ], | |
| 125 'action': [ | |
| 126 '--plugin', | |
| 127 'protoc-gen-plugin=<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)<(generator_pl ugin)<(EXECUTABLE_SUFFIX)', | |
| 128 '--plugin_out', | |
| 129 '<(generator_plugin_options)<(cc_dir)', | |
| 130 ], | |
| 131 }], | |
| 132 ], | |
| 99 }, | 133 }, |
| 100 ], | 134 ], |
| 101 'dependencies': [ | 135 'dependencies': [ |
| 102 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host', | 136 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host', |
| 103 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | |
| 104 ], | 137 ], |
| 105 'include_dirs': [ | 138 'include_dirs': [ |
| 106 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', | 139 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', |
| 107 '<(DEPTH)', | 140 '<(DEPTH)', |
| 108 ], | 141 ], |
| 109 'direct_dependent_settings': { | 142 'direct_dependent_settings': { |
| 110 'include_dirs': [ | 143 'include_dirs': [ |
| 111 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', | 144 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', |
| 112 '<(DEPTH)', | 145 '<(DEPTH)', |
| 113 ] | 146 ] |
| 114 }, | 147 }, |
| 115 'export_dependent_settings': [ | 148 |
| 116 # The generated headers reference headers within protobuf_lite, | 149 # If using built-in cc generator the resulting headers reference headers |
| 117 # so dependencies must be able to find those headers too. | 150 # within protobuf_lite, hence dependencies require those headers too. |
| 118 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | 151 # In case of generator plugin such issues should be resolved by invoker. |
| 152 'conditions': [ | |
| 153 ['generate_cc==1', { | |
| 154 'hard_dependency': 1, | |
| 155 'dependencies': [ | |
| 156 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | |
| 157 ], | |
| 158 'export_dependent_settings': [ | |
| 159 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | |
| 160 ], | |
| 161 }], | |
| 119 ], | 162 ], |
| 120 # This target exports a hard dependency because it generates header | |
| 121 # files. | |
| 122 'hard_dependency': 1, | |
| 123 } | 163 } |
| OLD | NEW |