| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 (host_os == "win") { | 69 if (host_os == "win") { |
| 70 _host_executable_suffix = ".exe" | 70 _host_executable_suffix = ".exe" |
| 71 } else { | 71 } else { |
| 72 _host_executable_suffix = "" | 72 _host_executable_suffix = "" |
| 73 } | 73 } |
| 74 | 74 |
| 75 _dart_root = rebase_path("..") |
| 76 |
| 75 template("compiled_action") { | 77 template("compiled_action") { |
| 76 assert(defined(invoker.tool), "tool must be defined for $target_name") | 78 assert(defined(invoker.tool), "tool must be defined for $target_name") |
| 77 assert(defined(invoker.outputs), "outputs must be defined for $target_name") | 79 assert(defined(invoker.outputs), "outputs must be defined for $target_name") |
| 78 assert(defined(invoker.args), "args must be defined for $target_name") | 80 assert(defined(invoker.args), "args must be defined for $target_name") |
| 79 | 81 |
| 80 assert(!defined(invoker.sources), | 82 assert(!defined(invoker.sources), |
| 81 "compiled_action doesn't take a sources arg. Use inputs instead.") | 83 "compiled_action doesn't take a sources arg. Use inputs instead.") |
| 82 | 84 |
| 83 action(target_name) { | 85 action(target_name) { |
| 84 if (defined(invoker.visibility)) { | 86 if (defined(invoker.visibility)) { |
| 85 visibility = invoker.visibility | 87 visibility = invoker.visibility |
| 86 } | 88 } |
| 87 | 89 |
| 88 script = "//build/gn_run_binary.py" | 90 script = "$_dart_root/build/gn_run_binary.py" |
| 89 | 91 |
| 90 if (defined(invoker.inputs)) { | 92 if (defined(invoker.inputs)) { |
| 91 inputs = invoker.inputs | 93 inputs = invoker.inputs |
| 92 } else { | 94 } else { |
| 93 inputs = [] | 95 inputs = [] |
| 94 } | 96 } |
| 95 outputs = invoker.outputs | 97 outputs = invoker.outputs |
| 96 | 98 |
| 97 # Constuct the host toolchain version of the tool. | 99 # Constuct the host toolchain version of the tool. |
| 98 host_tool = invoker.tool + "($host_toolchain)" | 100 host_tool = invoker.tool + "($host_toolchain)" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 111 | 113 |
| 112 deps = [ | 114 deps = [ |
| 113 host_tool, | 115 host_tool, |
| 114 ] | 116 ] |
| 115 if (defined(invoker.deps)) { | 117 if (defined(invoker.deps)) { |
| 116 deps += invoker.deps | 118 deps += invoker.deps |
| 117 } | 119 } |
| 118 | 120 |
| 119 # The script takes as arguments the binary to run, and then the arguments | 121 # The script takes as arguments the binary to run, and then the arguments |
| 120 # to pass it. | 122 # to pass it. |
| 121 args = [ rebase_path(host_executable, root_build_dir) ] + invoker.args | 123 args = [ |
| 124 "compiled_action", |
| 125 rebase_path(host_executable, root_build_dir) |
| 126 ] + invoker.args |
| 122 } | 127 } |
| 123 } | 128 } |
| 124 | 129 |
| 125 template("compiled_action_foreach") { | 130 template("compiled_action_foreach") { |
| 126 assert(defined(invoker.sources), "sources must be defined for $target_name") | 131 assert(defined(invoker.sources), "sources must be defined for $target_name") |
| 127 assert(defined(invoker.tool), "tool must be defined for $target_name") | 132 assert(defined(invoker.tool), "tool must be defined for $target_name") |
| 128 assert(defined(invoker.outputs), "outputs must be defined for $target_name") | 133 assert(defined(invoker.outputs), "outputs must be defined for $target_name") |
| 129 assert(defined(invoker.args), "args must be defined for $target_name") | 134 assert(defined(invoker.args), "args must be defined for $target_name") |
| 130 | 135 |
| 131 action_foreach(target_name) { | 136 action_foreach(target_name) { |
| 132 # Otherwise this is a standalone action, define visibility if requested. | 137 # Otherwise this is a standalone action, define visibility if requested. |
| 133 if (defined(invoker.visibility)) { | 138 if (defined(invoker.visibility)) { |
| 134 visibility = invoker.visibility | 139 visibility = invoker.visibility |
| 135 } | 140 } |
| 136 | 141 |
| 137 script = "//build/gn_run_binary.py" | 142 script = "$_dart_root/build/gn_run_binary.py" |
| 138 sources = invoker.sources | 143 sources = invoker.sources |
| 139 | 144 |
| 140 if (defined(invoker.inputs)) { | 145 if (defined(invoker.inputs)) { |
| 141 inputs = invoker.inputs | 146 inputs = invoker.inputs |
| 142 } else { | 147 } else { |
| 143 inputs = [] | 148 inputs = [] |
| 144 } | 149 } |
| 145 outputs = invoker.outputs | 150 outputs = invoker.outputs |
| 146 | 151 |
| 147 # Constuct the host toolchain version of the tool. | 152 # Constuct the host toolchain version of the tool. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 161 | 166 |
| 162 deps = [ | 167 deps = [ |
| 163 host_tool, | 168 host_tool, |
| 164 ] | 169 ] |
| 165 if (defined(invoker.deps)) { | 170 if (defined(invoker.deps)) { |
| 166 deps += invoker.deps | 171 deps += invoker.deps |
| 167 } | 172 } |
| 168 | 173 |
| 169 # The script takes as arguments the binary to run, and then the arguments | 174 # The script takes as arguments the binary to run, and then the arguments |
| 170 # to pass it. | 175 # to pass it. |
| 171 args = [ rebase_path(host_executable, root_build_dir) ] + invoker.args | 176 args = [ |
| 177 "compiled_action", |
| 178 rebase_path(host_executable, root_build_dir) |
| 179 ] + invoker.args |
| 172 } | 180 } |
| 173 } | 181 } |
| OLD | NEW |