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 # Declspec to add to the generated protobuf c++ headers. | |
|
Ryan Sleevi
2012/09/12 22:21:25
nit: declspec is Windows only, but presumably the
Lei Zhang
2012/09/12 23:33:59
Done.
| |
| 47 # e.g. 'dllexport_decl=BASE_EXPORT:' | |
| 48 'cc_declspec%': '', | |
| 49 # File to #include for the declspec in the generated protobuf c++ headers. | |
| 50 # e.g. 'base/base_export.h' | |
|
Ryan Sleevi
2012/09/12 22:21:25
nit: For consistency with the proto_in_dir/proto_o
Lei Zhang
2012/09/12 23:33:59
Done.
| |
| 51 'cc_declspec_include%': '', | |
| 45 'proto_in_dir%': '.', | 52 'proto_in_dir%': '.', |
| 46 }, | 53 }, |
| 47 'rules': [ | 54 'rules': [ |
| 48 { | 55 { |
| 49 'rule_name': 'genproto', | 56 'rule_name': 'genproto', |
| 50 'extension': 'proto', | 57 'extension': 'proto', |
| 51 'inputs': [ | 58 'inputs': [ |
| 59 '<(protoc_wrapper)', | |
| 52 '<(protoc)', | 60 '<(protoc)', |
| 53 ], | 61 ], |
| 54 'outputs': [ | 62 'outputs': [ |
| 55 '<(py_dir)/<(RULE_INPUT_ROOT)_pb2.py', | 63 '<(py_dir)/<(RULE_INPUT_ROOT)_pb2.py', |
| 56 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.cc', | 64 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.cc', |
| 57 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', | 65 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', |
| 58 ], | 66 ], |
| 59 'action': [ | 67 'action': [ |
| 68 'python', | |
| 69 '<(protoc_wrapper)', | |
| 70 '--include', | |
| 71 '<(cc_declspec_include)', | |
| 72 '--protobuf', | |
| 73 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', | |
| 74 '--', | |
| 60 '<(protoc)', | 75 '<(protoc)', |
| 61 # Using the --arg val form (instead of --arg=val) allows gyp's msvs rule | 76 # Using the --arg val form (instead of --arg=val) allows gyp's msvs rule |
| 62 # generation to correct 'val' which is a path. | 77 # generation to correct 'val' which is a path. |
| 63 '--proto_path','<(proto_in_dir)', | 78 '--proto_path','<(proto_in_dir)', |
| 64 # Naively you'd use <(RULE_INPUT_PATH) here, but protoc requires | 79 # 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. | 80 # --proto_path is a strict prefix of the path given as an argument. |
| 66 '<(proto_in_dir)/<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)', | 81 '<(proto_in_dir)/<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)', |
| 67 '--cpp_out','<(cc_dir)', | 82 '--cpp_out', '<(cc_declspec)<(cc_dir)', |
| 68 '--python_out','<(py_dir)', | 83 '--python_out', '<(py_dir)', |
| 69 ], | 84 ], |
| 70 'msvs_cygwin_shell': 0, | 85 'msvs_cygwin_shell': 0, |
| 71 'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)', | 86 'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)', |
| 72 'process_outputs_as_sources': 1, | 87 'process_outputs_as_sources': 1, |
| 73 }, | 88 }, |
| 74 ], | 89 ], |
| 75 'dependencies': [ | 90 'dependencies': [ |
| 76 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host', | 91 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host', |
| 77 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | 92 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', |
| 78 ], | 93 ], |
| 79 'include_dirs': [ | 94 'include_dirs': [ |
| 80 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', | 95 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', |
| 96 '<(DEPTH)', | |
|
Ryan Sleevi
2012/09/12 22:21:25
BUG? Seems like this should also be propagated in
Lei Zhang
2012/09/12 23:33:59
Done.
| |
| 81 ], | 97 ], |
| 82 'direct_dependent_settings': { | 98 'direct_dependent_settings': { |
| 83 'include_dirs': [ | 99 'include_dirs': [ |
| 84 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', | 100 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', |
| 85 ] | 101 ] |
| 86 }, | 102 }, |
| 87 'export_dependent_settings': [ | 103 'export_dependent_settings': [ |
| 88 # The generated headers reference headers within protobuf_lite, | 104 # The generated headers reference headers within protobuf_lite, |
| 89 # so dependencies must be able to find those headers too. | 105 # so dependencies must be able to find those headers too. |
| 90 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | 106 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', |
| 91 ], | 107 ], |
| 92 # This target exports a hard dependency because it generates header | 108 # This target exports a hard dependency because it generates header |
| 93 # files. | 109 # files. |
| 94 'hard_dependency': 1, | 110 'hard_dependency': 1, |
| 95 } | 111 } |
| OLD | NEW |