| OLD | NEW |
| (Empty) |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 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 | |
| 7 # protoc_java.gypi. | |
| 8 # | |
| 9 # To use this, create a gyp target with the following form: | |
| 10 # { | |
| 11 # 'target_name': 'my_proto_lib', | |
| 12 # 'type': 'static_library', | |
| 13 # 'sources': [ | |
| 14 # 'foo.proto', | |
| 15 # 'bar.proto', | |
| 16 # ], | |
| 17 # 'variables': { | |
| 18 # # Optional, see below: 'proto_in_dir': '.' | |
| 19 # 'proto_out_dir': 'dir/for/my_proto_lib' | |
| 20 # }, | |
| 21 # 'includes': ['path/to/this/gypi/file'], | |
| 22 # } | |
| 23 # If necessary, you may add normal .cc files to the sources list or other gyp | |
| 24 # dependencies. The proto headers are guaranteed to be generated before any | |
| 25 # source files, even within this target, are compiled. | |
| 26 # | |
| 27 # The 'proto_in_dir' variable must be the relative path to the | |
| 28 # directory containing the .proto files. If left out, it defaults to '.'. | |
| 29 # | |
| 30 # The 'proto_out_dir' variable specifies the path suffix that output | |
| 31 # files are generated under. Targets that gyp-depend on my_proto_lib | |
| 32 # will be able to include the resulting proto headers with an include | |
| 33 # like: | |
| 34 # #include "dir/for/my_proto_lib/foo.pb.h" | |
| 35 # | |
| 36 # If you need to add an EXPORT macro to a protobuf's c++ header, set the | |
| 37 # 'cc_generator_options' variable with the value: 'dllexport_decl=FOO_EXPORT:' | |
| 38 # e.g. 'dllexport_decl=BASE_EXPORT:' | |
| 39 # | |
| 40 # It is likely you also need to #include a file for the above EXPORT macro to | |
| 41 # work. You can do so with the 'cc_include' variable. | |
| 42 # e.g. 'base/base_export.h' | |
| 43 # | |
| 44 # Implementation notes: | |
| 45 # A proto_out_dir of foo/bar produces | |
| 46 # <(SHARED_INTERMEDIATE_DIR)/protoc_out/foo/bar/{file1,file2}.pb.{cc,h} | |
| 47 # <(SHARED_INTERMEDIATE_DIR)/pyproto/foo/bar/{file1,file2}_pb2.py | |
| 48 | |
| 49 { | |
| 50 'variables': { | |
| 51 'protoc_wrapper': '<(DEPTH)/tools/protoc_wrapper/protoc_wrapper.py', | |
| 52 'cc_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out/<(proto_out_dir)', | |
| 53 'py_dir': '<(PRODUCT_DIR)/pyproto/<(proto_out_dir)', | |
| 54 'cc_generator_options%': '', | |
| 55 'generate_python%': 1, | |
| 56 'generate_cc%': 1, | |
| 57 # Name of plugin executable which generates custom cc stubs. | |
| 58 # If passed, generator_plugin_suffix (before .cc and .h) is also required. | |
| 59 'generator_plugin%': '', | |
| 60 'generator_plugin_options%': '', | |
| 61 'cc_include%': '', | |
| 62 'proto_in_dir%': '.', | |
| 63 'conditions': [ | |
| 64 ['use_system_protobuf==0', { | |
| 65 'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)
', | |
| 66 }, { # use_system_protobuf==1 | |
| 67 'protoc': '<!(which protoc)', | |
| 68 }], | |
| 69 ], | |
| 70 }, | |
| 71 'rules': [ | |
| 72 { | |
| 73 'rule_name': 'genproto', | |
| 74 'extension': 'proto', | |
| 75 'inputs': [ | |
| 76 '<(protoc_wrapper)', | |
| 77 '<(protoc)', | |
| 78 ], | |
| 79 'action': [ | |
| 80 'python', | |
| 81 '<(protoc_wrapper)', | |
| 82 # If no cc_include specified --protobuf option will be ignored. | |
| 83 '--include', | |
| 84 '<(cc_include)', | |
| 85 '--protobuf', | |
| 86 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', | |
| 87 # Using the --arg val form (instead of --arg=val) allows gyp's msvs rule | |
| 88 # generation to correct 'val' which is a path. | |
| 89 '--proto-in-dir','<(proto_in_dir)', | |
| 90 # Naively you'd use <(RULE_INPUT_PATH) here, but protoc requires | |
| 91 # --proto_path is a strict prefix of the path given as an argument. | |
| 92 '--proto-in-file','<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)', | |
| 93 '--use-system-protobuf=<(use_system_protobuf)', | |
| 94 '--', | |
| 95 '<(protoc)', | |
| 96 ], | |
| 97 'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)', | |
| 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 ], | |
| 133 }, | |
| 134 ], | |
| 135 'dependencies': [ | |
| 136 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host', | |
| 137 ], | |
| 138 'include_dirs': [ | |
| 139 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', | |
| 140 '<(DEPTH)', | |
| 141 ], | |
| 142 'direct_dependent_settings': { | |
| 143 'include_dirs': [ | |
| 144 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', | |
| 145 '<(DEPTH)', | |
| 146 ] | |
| 147 }, | |
| 148 # This target exports a hard dependency because it generates header files. | |
| 149 'hard_dependency': 1, | |
| 150 | |
| 151 # If using built-in cc generator the resulting headers reference headers | |
| 152 # within protobuf_lite, hence dependencies require those headers too. | |
| 153 # In case of generator plugin such issues should be resolved by invoker. | |
| 154 'conditions': [ | |
| 155 ['generate_cc==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 }], | |
| 163 ], | |
| 164 } | |
| OLD | NEW |