OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 assert(is_win, "This only runs on Windows.") | 5 assert(is_win, "This only runs on Windows.") |
6 | 6 |
7 # Runs mc.exe over a list of sources. The outputs (a header and rc file) are | 7 # Runs mc.exe over a list of sources. The outputs (a header and rc file) are |
8 # placed in the target gen dir, and compiled. | 8 # placed in the target gen dir, and compiled. |
9 # | 9 # |
10 # sources | 10 # sources |
11 # List of message files to process. | 11 # List of message files to process. |
12 # | 12 # |
13 # user_mode_logging (optional bool) | 13 # user_mode_logging (optional bool) |
14 # Generates user-mode logging code. Defaults to false (no logging code). | 14 # Generates user-mode logging code. Defaults to false (no logging code). |
15 # | 15 # |
| 16 # compile_generated_code (optional, deafults = true) |
| 17 # If unset or true, the generated code will be compiled and linked into |
| 18 # targets that depend on it. If set to false, the .h and .rc files will only |
| 19 # be generated. |
| 20 # |
16 # deps, public_deps, visibility | 21 # deps, public_deps, visibility |
17 # Normal meaning. | 22 # Normal meaning. |
18 template("message_compiler") { | 23 template("message_compiler") { |
19 action_name = "${target_name}_mc" | 24 if (defined(invoker.compile_generated_code) && |
20 source_set_name = target_name | 25 !invoker.compile_generated_code) { |
| 26 compile_generated_code = false |
| 27 action_name = target_name |
| 28 } else { |
| 29 compile_generated_code = true |
| 30 action_name = "${target_name}_mc" |
| 31 source_set_name = target_name |
| 32 } |
21 | 33 |
22 action_foreach(action_name) { | 34 action_foreach(action_name) { |
23 visibility = [ ":$source_set_name" ] | 35 if (compile_generated_code) { |
| 36 visibility = [ ":$source_set_name" ] |
| 37 } else { |
| 38 forward_variables_from(invoker, [ "visibility" ]) |
| 39 } |
24 | 40 |
25 script = "//build/win/message_compiler.py" | 41 script = "//build/win/message_compiler.py" |
26 | 42 |
27 outputs = [ | 43 outputs = [ |
28 "$target_gen_dir/{{source_name_part}}.h", | 44 "$target_gen_dir/{{source_name_part}}.h", |
29 "$target_gen_dir/{{source_name_part}}.rc", | 45 "$target_gen_dir/{{source_name_part}}.rc", |
30 ] | 46 ] |
31 | 47 |
32 args = [ | 48 args = [ |
33 # The first argument is the environment file saved to the build | 49 # The first argument is the environment file saved to the build |
(...skipping 19 matching lines...) Expand all Loading... |
53 args += [ "{{source}}" ] | 69 args += [ "{{source}}" ] |
54 | 70 |
55 forward_variables_from(invoker, | 71 forward_variables_from(invoker, |
56 [ | 72 [ |
57 "deps", | 73 "deps", |
58 "public_deps", | 74 "public_deps", |
59 "sources", | 75 "sources", |
60 ]) | 76 ]) |
61 } | 77 } |
62 | 78 |
63 # Compile the generated rc file. | 79 if (compile_generated_code) { |
64 source_set(source_set_name) { | 80 # Compile the generated rc file. |
65 forward_variables_from(invoker, [ "visibility" ]) | 81 source_set(source_set_name) { |
66 sources = get_target_outputs(":$action_name") | 82 forward_variables_from(invoker, [ "visibility" ]) |
67 deps = [ | 83 sources = get_target_outputs(":$action_name") |
68 ":$action_name", | 84 deps = [ |
69 ] | 85 ":$action_name", |
| 86 ] |
| 87 } |
70 } | 88 } |
71 } | 89 } |
OLD | NEW |