OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 introduces two related templates that act like action and | 5 # This file introduces two related templates that act like action and |
6 # action_foreach but instead of running a Python script, it will compile a | 6 # action_foreach but instead of running a Python script, it will compile a |
7 # given tool in the host toolchain and run that (either once or over the list | 7 # given tool in the host toolchain and run that (either once or over the list |
8 # of inputs, depending on the variant). | 8 # of inputs, depending on the variant). |
9 # | 9 # |
10 # Parameters | 10 # Parameters |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 # if (host_toolchain == current_toolchain) { | 59 # if (host_toolchain == current_toolchain) { |
60 # executable("mytool") { | 60 # executable("mytool") { |
61 # ... | 61 # ... |
62 # } | 62 # } |
63 # } | 63 # } |
64 # The if statement around the executable is optional. That says "I only care | 64 # The if statement around the executable is optional. That says "I only care |
65 # about this target in the host toolchain". Usually this is what you want, and | 65 # about this target in the host toolchain". Usually this is what you want, and |
66 # saves unnecessarily compiling your tool for the target platform. But if you | 66 # saves unnecessarily compiling your tool for the target platform. But if you |
67 # need a target build of your tool as well, just leave off the if statement. | 67 # need a target build of your tool as well, just leave off the if statement. |
68 | 68 |
| 69 if (build_os == "win") { |
| 70 _host_executable_suffix = ".exe" |
| 71 } else { |
| 72 _host_executable_suffix = "" |
| 73 } |
| 74 |
69 template("compiled_action") { | 75 template("compiled_action") { |
70 assert(defined(invoker.tool), "tool must be defined for $target_name") | 76 assert(defined(invoker.tool), "tool must be defined for $target_name") |
71 assert(defined(invoker.outputs), "outputs must be defined for $target_name") | 77 assert(defined(invoker.outputs), "outputs must be defined for $target_name") |
72 assert(defined(invoker.args), "args must be defined for $target_name") | 78 assert(defined(invoker.args), "args must be defined for $target_name") |
73 | 79 |
74 assert(!defined(invoker.sources), | 80 assert(!defined(invoker.sources), |
75 "compiled_action doesn't take a sources arg. Use inputs instead.") | 81 "compiled_action doesn't take a sources arg. Use inputs instead.") |
76 | 82 |
77 action(target_name) { | 83 action(target_name) { |
78 if (defined(invoker.visibility)) { | 84 if (defined(invoker.visibility)) { |
(...skipping 11 matching lines...) Expand all Loading... |
90 | 96 |
91 # Constuct the host toolchain version of the tool. | 97 # Constuct the host toolchain version of the tool. |
92 host_tool = invoker.tool + "($host_toolchain)" | 98 host_tool = invoker.tool + "($host_toolchain)" |
93 | 99 |
94 # Get the path to the executable. Currently, this assumes that the tool | 100 # Get the path to the executable. Currently, this assumes that the tool |
95 # does not specify output_name so that the target name is the name to use. | 101 # does not specify output_name so that the target name is the name to use. |
96 # If that's not the case, we'll need another argument to the script to | 102 # If that's not the case, we'll need another argument to the script to |
97 # specify this, since we can't know what the output name is (it might be in | 103 # specify this, since we can't know what the output name is (it might be in |
98 # another file not processed yet). | 104 # another file not processed yet). |
99 host_executable = get_label_info(host_tool, "root_out_dir") + "/" + | 105 host_executable = get_label_info(host_tool, "root_out_dir") + "/" + |
100 get_label_info(host_tool, "name") | 106 get_label_info(host_tool, "name") + _host_executable_suffix |
101 | 107 |
102 # Add the executable itself as an input. | 108 # Add the executable itself as an input. |
103 inputs += [ host_executable ] | 109 inputs += [ host_executable ] |
104 | 110 |
105 deps = [ host_tool ] | 111 deps = [ host_tool ] |
106 if (defined(invoker.deps)) { | 112 if (defined(invoker.deps)) { |
107 deps += invoker.deps | 113 deps += invoker.deps |
108 } | 114 } |
109 | 115 |
110 # The script takes as arguments the binary to run, and then the arguments | 116 # The script takes as arguments the binary to run, and then the arguments |
(...skipping 28 matching lines...) Expand all Loading... |
139 | 145 |
140 # Constuct the host toolchain version of the tool. | 146 # Constuct the host toolchain version of the tool. |
141 host_tool = invoker.tool + "($host_toolchain)" | 147 host_tool = invoker.tool + "($host_toolchain)" |
142 | 148 |
143 # Get the path to the executable. Currently, this assumes that the tool | 149 # Get the path to the executable. Currently, this assumes that the tool |
144 # does not specify output_name so that the target name is the name to use. | 150 # does not specify output_name so that the target name is the name to use. |
145 # If that's not the case, we'll need another argument to the script to | 151 # If that's not the case, we'll need another argument to the script to |
146 # specify this, since we can't know what the output name is (it might be in | 152 # specify this, since we can't know what the output name is (it might be in |
147 # another file not processed yet). | 153 # another file not processed yet). |
148 host_executable = get_label_info(host_tool, "root_out_dir") + "/" + | 154 host_executable = get_label_info(host_tool, "root_out_dir") + "/" + |
149 get_label_info(host_tool, "name") | 155 get_label_info(host_tool, "name") + _host_executable_suffix |
150 | 156 |
151 # Add the executable itself as an input. | 157 # Add the executable itself as an input. |
152 inputs += [ host_executable ] | 158 inputs += [ host_executable ] |
153 | 159 |
154 deps = [ host_tool ] | 160 deps = [ host_tool ] |
155 if (defined(invoker.deps)) { | 161 if (defined(invoker.deps)) { |
156 deps += invoker.deps | 162 deps += invoker.deps |
157 } | 163 } |
158 | 164 |
159 # The script takes as arguments the binary to run, and then the arguments | 165 # The script takes as arguments the binary to run, and then the arguments |
160 # to pass it. | 166 # to pass it. |
161 args = [ | 167 args = [ |
162 rebase_path(host_executable, root_build_dir) | 168 rebase_path(host_executable, root_build_dir) |
163 ] + invoker.args | 169 ] + invoker.args |
164 } | 170 } |
165 } | 171 } |
OLD | NEW |