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 14 matching lines...) Expand all Loading... |
25 # | 25 # |
26 # The 'proto_in_dir' variable must be the relative path to the | 26 # The 'proto_in_dir' variable must be the relative path to the |
27 # directory containing the .proto files. If left out, it defaults to '.'. | 27 # directory containing the .proto files. If left out, it defaults to '.'. |
28 # | 28 # |
29 # The 'proto_out_dir' variable specifies the path suffix that output | 29 # The 'proto_out_dir' variable specifies the path suffix that output |
30 # files are generated under. Targets that gyp-depend on my_proto_lib | 30 # files are generated under. Targets that gyp-depend on my_proto_lib |
31 # will be able to include the resulting proto headers with an include | 31 # will be able to include the resulting proto headers with an include |
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 # If you need to add an EXPORT macro to a protobuf's c++ header, set the |
| 36 # 'cc_generator_options' variable with the value: 'dllexport_decl=FOO_EXPORT:' |
| 37 # e.g. 'dllexport_decl=BASE_EXPORT:' |
| 38 # |
| 39 # It is likely you also need to #include a file for the above EXPORT macro to |
| 40 # work. You can do so with the 'cc_include' variable. |
| 41 # e.g. 'base/base_export.h' |
| 42 # |
35 # Implementation notes: | 43 # Implementation notes: |
36 # A proto_out_dir of foo/bar produces | 44 # A proto_out_dir of foo/bar produces |
37 # <(SHARED_INTERMEDIATE_DIR)/protoc_out/foo/bar/{file1,file2}.pb.{cc,h} | 45 # <(SHARED_INTERMEDIATE_DIR)/protoc_out/foo/bar/{file1,file2}.pb.{cc,h} |
38 # <(SHARED_INTERMEDIATE_DIR)/pyproto/foo/bar/{file1,file2}_pb2.py | 46 # <(SHARED_INTERMEDIATE_DIR)/pyproto/foo/bar/{file1,file2}_pb2.py |
39 | 47 |
40 { | 48 { |
41 'variables': { | 49 'variables': { |
| 50 'protoc_wrapper': '<(DEPTH)/tools/protoc_wrapper/protoc_wrapper.py', |
42 'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)', | 51 'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)', |
43 'cc_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out/<(proto_out_dir)', | 52 'cc_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out/<(proto_out_dir)', |
44 'py_dir': '<(PRODUCT_DIR)/pyproto/<(proto_out_dir)', | 53 'py_dir': '<(PRODUCT_DIR)/pyproto/<(proto_out_dir)', |
| 54 'cc_generator_options%': '', |
| 55 'cc_include%': '', |
45 'proto_in_dir%': '.', | 56 'proto_in_dir%': '.', |
46 }, | 57 }, |
47 'rules': [ | 58 'rules': [ |
48 { | 59 { |
49 'rule_name': 'genproto', | 60 'rule_name': 'genproto', |
50 'extension': 'proto', | 61 'extension': 'proto', |
51 'inputs': [ | 62 'inputs': [ |
| 63 '<(protoc_wrapper)', |
52 '<(protoc)', | 64 '<(protoc)', |
53 ], | 65 ], |
54 'outputs': [ | 66 'outputs': [ |
55 '<(py_dir)/<(RULE_INPUT_ROOT)_pb2.py', | 67 '<(py_dir)/<(RULE_INPUT_ROOT)_pb2.py', |
56 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.cc', | 68 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.cc', |
57 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', | 69 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', |
58 ], | 70 ], |
59 'action': [ | 71 'action': [ |
| 72 'python', |
| 73 '<(protoc_wrapper)', |
| 74 '--include', |
| 75 '<(cc_include)', |
| 76 '--protobuf', |
| 77 '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', |
| 78 '--', |
60 '<(protoc)', | 79 '<(protoc)', |
61 # Using the --arg val form (instead of --arg=val) allows gyp's msvs rule | 80 # Using the --arg val form (instead of --arg=val) allows gyp's msvs rule |
62 # generation to correct 'val' which is a path. | 81 # generation to correct 'val' which is a path. |
63 '--proto_path','<(proto_in_dir)', | 82 '--proto_path','<(proto_in_dir)', |
64 # Naively you'd use <(RULE_INPUT_PATH) here, but protoc requires | 83 # 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. | 84 # --proto_path is a strict prefix of the path given as an argument. |
66 '<(proto_in_dir)/<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)', | 85 '<(proto_in_dir)/<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)', |
67 '--cpp_out','<(cc_dir)', | 86 '--cpp_out', '<(cc_generator_options)<(cc_dir)', |
68 '--python_out','<(py_dir)', | 87 '--python_out', '<(py_dir)', |
69 ], | 88 ], |
70 'msvs_cygwin_shell': 0, | 89 'msvs_cygwin_shell': 0, |
71 'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)', | 90 'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)', |
72 'process_outputs_as_sources': 1, | 91 'process_outputs_as_sources': 1, |
73 }, | 92 }, |
74 ], | 93 ], |
75 'dependencies': [ | 94 'dependencies': [ |
76 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host', | 95 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host', |
77 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | 96 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', |
78 ], | 97 ], |
79 'include_dirs': [ | 98 'include_dirs': [ |
80 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', | 99 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', |
| 100 '<(DEPTH)', |
81 ], | 101 ], |
82 'direct_dependent_settings': { | 102 'direct_dependent_settings': { |
83 'include_dirs': [ | 103 'include_dirs': [ |
84 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', | 104 '<(SHARED_INTERMEDIATE_DIR)/protoc_out', |
| 105 '<(DEPTH)', |
85 ] | 106 ] |
86 }, | 107 }, |
87 'export_dependent_settings': [ | 108 'export_dependent_settings': [ |
88 # The generated headers reference headers within protobuf_lite, | 109 # The generated headers reference headers within protobuf_lite, |
89 # so dependencies must be able to find those headers too. | 110 # so dependencies must be able to find those headers too. |
90 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', | 111 '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', |
91 ], | 112 ], |
92 # This target exports a hard dependency because it generates header | 113 # This target exports a hard dependency because it generates header |
93 # files. | 114 # files. |
94 'hard_dependency': 1, | 115 'hard_dependency': 1, |
95 } | 116 } |
OLD | NEW |