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 'generator_plugin%': '', # generator_plugin_suffix is required if set. | |
|
Primiano Tucci (use gerrit)
2016/06/21 14:15:09
you want to add a comment here explaining that thi
| |
| 58 'generator_plugin_options%': '', | |
| 55 'cc_include%': '', | 59 'cc_include%': '', |
| 56 'proto_in_dir%': '.', | 60 'proto_in_dir%': '.', |
| 57 'conditions': [ | 61 'conditions': [ |
| 58 ['use_system_protobuf==0', { | 62 ['use_system_protobuf==0', { |
| 59 'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX) ', | 63 'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX) ', |
| 60 }, { # use_system_protobuf==1 | 64 }, { # use_system_protobuf==1 |
| 61 'protoc': '<!(which protoc)', | 65 'protoc': '<!(which protoc)', |
| 62 }], | 66 }], |
| 63 ], | 67 ], |
| 64 }, | 68 }, |
| 65 'rules': [ | 69 'rules': [ |
| 66 { | 70 { |
| 67 'rule_name': 'genproto', | 71 'rule_name': 'genproto', |
| 68 'extension': 'proto', | 72 'extension': 'proto', |
| 69 'inputs': [ | 73 'inputs': [ |
| 70 '<(protoc_wrapper)', | 74 '<(protoc_wrapper)', |
| 71 '<(protoc)', | 75 '<(protoc)', |
| 72 ], | 76 ], |
| 73 'outputs': [ | 77 'outputs': [ |
|
Primiano Tucci (use gerrit)
2016/06/21 14:15:09
IIRC in gyp, conversely to gn, the list doesn't ne
| |
| 74 '<(py_dir)/<(RULE_INPUT_ROOT)_pb2.py', | 78 # To be populated. |
| 75 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.cc', | |
| 76 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', | |
| 77 ], | 79 ], |
| 78 'action': [ | 80 'action': [ |
| 79 'python', | 81 'python', |
| 80 '<(protoc_wrapper)', | 82 '<(protoc_wrapper)', |
| 83 # If no cc_include specified --protobuf option will be ignored. | |
| 81 '--include', | 84 '--include', |
| 82 '<(cc_include)', | 85 '<(cc_include)', |
| 83 '--protobuf', | 86 '--protobuf', |
| 84 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', | 87 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', |
| 85 # Using the --arg val form (instead of --arg=val) allows gyp's msvs rule | 88 # Using the --arg val form (instead of --arg=val) allows gyp's msvs rule |
| 86 # generation to correct 'val' which is a path. | 89 # generation to correct 'val' which is a path. |
| 87 '--proto-in-dir','<(proto_in_dir)', | 90 '--proto-in-dir','<(proto_in_dir)', |
| 88 # Naively you'd use <(RULE_INPUT_PATH) here, but protoc requires | 91 # 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. | 92 # --proto_path is a strict prefix of the path given as an argument. |
| 90 '--proto-in-file','<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)', | 93 '--proto-in-file','<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)', |
| 91 '--use-system-protobuf=<(use_system_protobuf)', | 94 '--use-system-protobuf=<(use_system_protobuf)', |
| 92 '--', | 95 '--', |
| 93 '<(protoc)', | 96 '<(protoc)', |
| 94 '--cpp_out', '<(cc_generator_options)<(cc_dir)', | |
| 95 '--python_out', '<(py_dir)', | |
| 96 ], | 97 ], |
| 97 'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)', | 98 'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)', |
| 98 'process_outputs_as_sources': 1, | 99 'process_outputs_as_sources': 1, |
| 100 | |
| 101 'conditions': [ | |
| 102 ['generate_python==1', { | |
| 103 'outputs+': [ | |
|
Primiano Tucci (use gerrit)
2016/06/21 14:15:09
Looks like in gyp name+ means "prepend" which is N
| |
| 104 '<(py_dir)/<(RULE_INPUT_ROOT)_pb2.py', | |
| 105 ], | |
| 106 'action+': [ | |
| 107 '--python_out', | |
| 108 '<(py_dir)', | |
| 109 ], | |
| 110 }], | |
| 111 ['generate_cc==1', { | |
| 112 'outputs+': [ | |
| 113 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.cc', | |
| 114 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', | |
| 115 ], | |
| 116 'action+': [ | |
| 117 '--cpp_out', | |
| 118 '<(cc_generator_options)<(cc_dir)', | |
| 119 ], | |
| 120 }], | |
| 121 ['generator_plugin!=""', { | |
| 122 'outputs+': [ | |
| 123 '<(cc_dir)/<(RULE_INPUT_ROOT)<(generator_plugin_suffix).cc', | |
|
Primiano Tucci (use gerrit)
2016/06/21 14:15:09
I think you want this initialized in the variables
| |
| 124 '<(cc_dir)/<(RULE_INPUT_ROOT)<(generator_plugin_suffix).h', | |
| 125 ], | |
| 126 'action+': [ | |
| 127 '--plugin', | |
| 128 'protoc-gen-plugin=<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)<(generator_pl ugin)<(EXECUTABLE_SUFFIX)', | |
|
Primiano Tucci (use gerrit)
2016/06/21 14:15:09
I think here you should add a dependencies: <(gene
kraynov
2016/06/21 14:50:12
As discussed in offline chat, target name is not s
| |
| 129 '--plugin_out', | |
| 130 '<(generator_plugin_options)<(cc_dir)', | |
| 131 ], | |
| 132 }], | |
| 133 ], | |
| 99 }, | 134 }, |
| 100 ], | 135 ], |
| 101 'dependencies': [ | 136 'dependencies': [ |
| 102 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host', | 137 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host', |
| 103 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | |
| 104 ], | 138 ], |
| 105 'include_dirs': [ | 139 'include_dirs': [ |
| 106 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', | 140 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', |
| 107 '<(DEPTH)', | 141 '<(DEPTH)', |
| 108 ], | 142 ], |
| 109 'direct_dependent_settings': { | 143 'direct_dependent_settings': { |
| 110 'include_dirs': [ | 144 'include_dirs': [ |
| 111 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', | 145 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', |
| 112 '<(DEPTH)', | 146 '<(DEPTH)', |
| 113 ] | 147 ] |
| 114 }, | 148 }, |
| 115 'export_dependent_settings': [ | 149 |
| 116 # The generated headers reference headers within protobuf_lite, | 150 # If using built-in cc generator the resulting headers reference headers |
| 117 # so dependencies must be able to find those headers too. | 151 # within protobuf_lite, hence dependencies require those headers too. |
| 118 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | 152 # In case of generator plugin such issues should be resolved by invoker. |
| 153 'conditions': [ | |
| 154 ['generate_cc==1', { | |
| 155 'hard_dependency': 1, | |
| 156 'dependencies+': [ | |
| 157 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | |
| 158 ], | |
| 159 'export_dependent_settings': [ | |
| 160 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | |
| 161 ], | |
| 162 }], | |
| 119 ], | 163 ], |
| 120 # This target exports a hard dependency because it generates header | |
| 121 # files. | |
| 122 'hard_dependency': 1, | |
|
Primiano Tucci (use gerrit)
2016/06/21 14:15:09
why are you moving this and removing its comment?
| |
| 123 } | 164 } |
| OLD | NEW |