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. | 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 21 matching lines...) Expand all Loading... | |
| 32 # like: | 32 # like: |
| 33 # #include "dir/for/my_proto_lib/foo.pb.h" | 33 # #include "dir/for/my_proto_lib/foo.pb.h" |
| 34 # | 34 # |
| 35 # Implementation notes: | 35 # Implementation notes: |
| 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_wrapper': '<(DEPTH)/tools/protoc_wrapper/protoc_wrapper.py', | |
| 42 'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)', | 43 'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)', |
| 43 'cc_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out/<(proto_out_dir)', | 44 'cc_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out/<(proto_out_dir)', |
| 44 'py_dir': '<(PRODUCT_DIR)/pyproto/<(proto_out_dir)', | 45 'py_dir': '<(PRODUCT_DIR)/pyproto/<(proto_out_dir)', |
| 46 'cc_extra%': '', | |
|
Ryan Sleevi
2012/09/12 19:47:32
Please add documentation about cc_extra and cc_inc
| |
| 47 'cc_include%': '', | |
| 45 'proto_in_dir%': '.', | 48 'proto_in_dir%': '.', |
| 46 }, | 49 }, |
| 47 'rules': [ | 50 'rules': [ |
| 48 { | 51 { |
| 49 'rule_name': 'genproto', | 52 'rule_name': 'genproto', |
| 50 'extension': 'proto', | 53 'extension': 'proto', |
| 51 'inputs': [ | 54 'inputs': [ |
| 55 '<(protoc_wrapper)', | |
| 52 '<(protoc)', | 56 '<(protoc)', |
| 53 ], | 57 ], |
| 54 'outputs': [ | 58 'outputs': [ |
| 55 '<(py_dir)/<(RULE_INPUT_ROOT)_pb2.py', | 59 '<(py_dir)/<(RULE_INPUT_ROOT)_pb2.py', |
| 56 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.cc', | 60 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.cc', |
| 57 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', | 61 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', |
| 58 ], | 62 ], |
| 59 'action': [ | 63 'action': [ |
| 64 'python', | |
| 65 '<(protoc_wrapper)', | |
| 66 '<(cc_include)' ':' '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', | |
|
Ryan Sleevi
2012/09/12 19:47:32
If no 'cc_include' is specified, this expands to a
| |
| 60 '<(protoc)', | 67 '<(protoc)', |
| 61 # Using the --arg val form (instead of --arg=val) allows gyp's msvs rule | 68 # Using the --arg val form (instead of --arg=val) allows gyp's msvs rule |
| 62 # generation to correct 'val' which is a path. | 69 # generation to correct 'val' which is a path. |
| 63 '--proto_path','<(proto_in_dir)', | 70 '--proto_path','<(proto_in_dir)', |
| 64 # Naively you'd use <(RULE_INPUT_PATH) here, but protoc requires | 71 # Naively you'd use <(RULE_INPUT_PATH) here, but protoc requires |
| 65 # --proto_path is a strict prefix of the path given as an argument. | 72 # --proto_path is a strict prefix of the path given as an argument. |
| 66 '<(proto_in_dir)/<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)', | 73 '<(proto_in_dir)/<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)', |
| 67 '--cpp_out','<(cc_dir)', | 74 '--cpp_out', '<(cc_extra)' '<(cc_dir)', |
| 68 '--python_out','<(py_dir)', | 75 '--python_out', '<(py_dir)', |
| 69 ], | 76 ], |
| 70 'msvs_cygwin_shell': 0, | 77 'msvs_cygwin_shell': 0, |
| 71 'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)', | 78 'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)', |
| 72 'process_outputs_as_sources': 1, | 79 'process_outputs_as_sources': 1, |
| 73 }, | 80 }, |
| 74 ], | 81 ], |
| 75 'dependencies': [ | 82 'dependencies': [ |
| 76 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host', | 83 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host', |
| 77 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | 84 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', |
| 78 ], | 85 ], |
| 79 'include_dirs': [ | 86 'include_dirs': [ |
| 80 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', | 87 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', |
| 88 '<(DEPTH)', | |
| 81 ], | 89 ], |
| 82 'direct_dependent_settings': { | 90 'direct_dependent_settings': { |
| 83 'include_dirs': [ | 91 'include_dirs': [ |
| 84 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', | 92 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', |
| 85 ] | 93 ] |
| 86 }, | 94 }, |
| 87 'export_dependent_settings': [ | 95 'export_dependent_settings': [ |
| 88 # The generated headers reference headers within protobuf_lite, | 96 # The generated headers reference headers within protobuf_lite, |
| 89 # so dependencies must be able to find those headers too. | 97 # so dependencies must be able to find those headers too. |
| 90 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | 98 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', |
| 91 ], | 99 ], |
| 92 # This target exports a hard dependency because it generates header | 100 # This target exports a hard dependency because it generates header |
| 93 # files. | 101 # files. |
| 94 'hard_dependency': 1, | 102 'hard_dependency': 1, |
| 95 } | 103 } |
| OLD | NEW |