Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: build/compiled_action.gni

Issue 505403002: Fix compiled action dependencies in GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix module.c compilation Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/yasm/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 # 11 #
12 # tool (required) 12 # tool (required)
13 # [label] Label of the tool to run. This should be an executable, and 13 # [label] Label of the tool to run. This should be an executable, and
14 # this label should not include a toolchain (anything in parens). The 14 # this label should not include a toolchain (anything in parens). The
15 # host compile of this tool will be used. 15 # host compile of this tool will be used.
16 # 16 #
17 # outputs (required) 17 # outputs (required)
18 # [list of files] Like the outputs of action (if using "compiled_action", 18 # [list of files] Like the outputs of action (if using "compiled_action",
19 # this would be just the list of outputs), or action_foreach (if using 19 # this would be just the list of outputs), or action_foreach (if using
20 # "compiled_action_foreach", this would contain source expansions mapping 20 # "compiled_action_foreach", this would contain source expansions mapping
21 # input to output files). 21 # input to output files).
22 # 22 #
23 # args (required) 23 # args (required)
24 # [list of strings] Same meaning as action/action_foreach. 24 # [list of strings] Same meaning as action/action_foreach.
25 # 25 #
26 # inputs (optional)
27 # Files the binary takes as input. The step will be re-run whenever any
28 # of these change. If inputs is empty, the step will run only when the
29 # binary itself changes.
30 #
26 # visibility 31 # visibility
27 # inputs
28 # deps 32 # deps
29 # args (all optional) 33 # args (all optional)
30 # Same meaning as action/action_foreach. 34 # Same meaning as action/action_foreach.
31 # 35 #
32 # 36 #
33 # Example of usage: 37 # Example of usage:
34 # 38 #
35 # compiled_action("run_my_tool") { 39 # compiled_action("run_my_tool") {
36 # tool = "//tools/something:mytool" 40 # tool = "//tools/something:mytool"
37 # outputs = [ 41 # outputs = [
(...skipping 22 matching lines...) Expand all
60 # 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
61 # 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
62 # 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
63 # 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.
64 68
65 template("compiled_action") { 69 template("compiled_action") {
66 assert(defined(invoker.tool), "tool must be defined for $target_name") 70 assert(defined(invoker.tool), "tool must be defined for $target_name")
67 assert(defined(invoker.outputs), "outputs must be defined for $target_name") 71 assert(defined(invoker.outputs), "outputs must be defined for $target_name")
68 assert(defined(invoker.args), "args must be defined for $target_name") 72 assert(defined(invoker.args), "args must be defined for $target_name")
69 73
74 assert(!defined(invoker.sources),
75 "compiled_action doesn't take a sources arg. Use inputs instead.")
76
70 action(target_name) { 77 action(target_name) {
71 if (defined(invoker.visibility)) { 78 if (defined(invoker.visibility)) {
72 visibility = invoker.visibility 79 visibility = invoker.visibility
73 } 80 }
74 81
75 script = "//build/gn_run_binary.py" 82 script = "//build/gn_run_binary.py"
76 83
77 if (defined(invoker.inputs)) { 84 if (defined(invoker.inputs)) {
78 inputs = invoker.inputs 85 inputs = invoker.inputs
86 } else {
87 inputs = []
79 } 88 }
80 outputs = invoker.outputs 89 outputs = invoker.outputs
81 90
82 # Constuct the host toolchain version of the tool. 91 # Constuct the host toolchain version of the tool.
83 host_tool = invoker.tool + "($host_toolchain)" 92 host_tool = invoker.tool + "($host_toolchain)"
84 93
85 # Get the path to the executable. Currently, this assumes that the tool 94 # Get the path to the executable. Currently, this assumes that the tool
86 # does not specify output_name so that the target name is the name to use. 95 # does not specify output_name so that the target name is the name to use.
87 # If that's not the case, we'll need another argument to the script to 96 # If that's not the case, we'll need another argument to the script to
88 # specify this, since we can't know what the output name is (it might be in 97 # specify this, since we can't know what the output name is (it might be in
89 # another file not processed yet). 98 # another file not processed yet).
90 host_executable = get_label_info(host_tool, "root_out_dir") + "/" + 99 host_executable = get_label_info(host_tool, "root_out_dir") + "/" +
91 get_label_info(host_tool, "name") 100 get_label_info(host_tool, "name")
92 101
102 # Add the executable itself as an input.
103 inputs += [ host_executable ]
104
93 deps = [ host_tool ] 105 deps = [ host_tool ]
94 if (defined(invoker.deps)) { 106 if (defined(invoker.deps)) {
95 deps += invoker.deps 107 deps += invoker.deps
96 } 108 }
97 109
98 # The script takes as arguments the binary to run, and then the arguments 110 # The script takes as arguments the binary to run, and then the arguments
99 # to pass it. 111 # to pass it.
100 args = [ 112 args = [
101 rebase_path(host_executable, root_build_dir) 113 rebase_path(host_executable, root_build_dir)
102 ] + invoker.args 114 ] + invoker.args
(...skipping 10 matching lines...) Expand all
113 # Otherwise this is a standalone action, define visibility if requested. 125 # Otherwise this is a standalone action, define visibility if requested.
114 if (defined(invoker.visibility)) { 126 if (defined(invoker.visibility)) {
115 visibility = invoker.visibility 127 visibility = invoker.visibility
116 } 128 }
117 129
118 script = "//build/gn_run_binary.py" 130 script = "//build/gn_run_binary.py"
119 sources = invoker.sources 131 sources = invoker.sources
120 132
121 if (defined(invoker.inputs)) { 133 if (defined(invoker.inputs)) {
122 inputs = invoker.inputs 134 inputs = invoker.inputs
135 } else {
136 inputs = []
123 } 137 }
124 outputs = invoker.outputs 138 outputs = invoker.outputs
125 139
126 # Constuct the host toolchain version of the tool. 140 # Constuct the host toolchain version of the tool.
127 host_tool = invoker.tool + "($host_toolchain)" 141 host_tool = invoker.tool + "($host_toolchain)"
128 142
129 # Get the path to the executable. Currently, this assumes that the tool 143 # Get the path to the executable. Currently, this assumes that the tool
130 # does not specify output_name so that the target name is the name to use. 144 # does not specify output_name so that the target name is the name to use.
131 # If that's not the case, we'll need another argument to the script to 145 # If that's not the case, we'll need another argument to the script to
132 # specify this, since we can't know what the output name is (it might be in 146 # specify this, since we can't know what the output name is (it might be in
133 # another file not processed yet). 147 # another file not processed yet).
134 host_executable = get_label_info(host_tool, "root_out_dir") + "/" + 148 host_executable = get_label_info(host_tool, "root_out_dir") + "/" +
135 get_label_info(host_tool, "name") 149 get_label_info(host_tool, "name")
136 150
151 # Add the executable itself as an input.
152 inputs += [ host_executable ]
153
137 deps = [ host_tool ] 154 deps = [ host_tool ]
138 if (defined(invoker.deps)) { 155 if (defined(invoker.deps)) {
139 deps += invoker.deps 156 deps += invoker.deps
140 } 157 }
141 158
142 # The script takes as arguments the binary to run, and then the arguments 159 # The script takes as arguments the binary to run, and then the arguments
143 # to pass it. 160 # to pass it.
144 args = [ 161 args = [
145 rebase_path(host_executable, root_build_dir) 162 rebase_path(host_executable, root_build_dir)
146 ] + invoker.args 163 ] + invoker.args
147 } 164 }
148 } 165 }
OLDNEW
« no previous file with comments | « no previous file | third_party/yasm/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698