Commit 4b04efb4 authored by Brett Wilson's avatar Brett Wilson

Fix compiled action dependencies in GN.

The yasm uses of compiled action used sources instead of inputs. Sources applies to the _foreach version but not the plain "compiled_action". These did not trigger an unused variable warning because the declarations themselves dereferenced the sources variable for computing args to the script.

This adds some extra documentation and assertion to the compiled action template. It also adds the binary itself as an input. This should be strictly unnecessary since there should be an implicit dependency on the target, but I like this since it makes things more explicit.

R=ajwong@chromium.org

Review URL: https://codereview.chromium.org/505403002

Cr-Commit-Position: refs/heads/master@{#292447}
parent c0be2791
......@@ -23,8 +23,12 @@
# args (required)
# [list of strings] Same meaning as action/action_foreach.
#
# inputs (optional)
# Files the binary takes as input. The step will be re-run whenever any
# of these change. If inputs is empty, the step will run only when the
# binary itself changes.
#
# visibility
# inputs
# deps
# args (all optional)
# Same meaning as action/action_foreach.
......@@ -67,6 +71,9 @@ template("compiled_action") {
assert(defined(invoker.outputs), "outputs must be defined for $target_name")
assert(defined(invoker.args), "args must be defined for $target_name")
assert(!defined(invoker.sources),
"compiled_action doesn't take a sources arg. Use inputs instead.")
action(target_name) {
if (defined(invoker.visibility)) {
visibility = invoker.visibility
......@@ -76,6 +83,8 @@ template("compiled_action") {
if (defined(invoker.inputs)) {
inputs = invoker.inputs
} else {
inputs = []
}
outputs = invoker.outputs
......@@ -90,6 +99,9 @@ template("compiled_action") {
host_executable = get_label_info(host_tool, "root_out_dir") + "/" +
get_label_info(host_tool, "name")
# Add the executable itself as an input.
inputs += [ host_executable ]
deps = [ host_tool ]
if (defined(invoker.deps)) {
deps += invoker.deps
......@@ -120,6 +132,8 @@ template("compiled_action_foreach") {
if (defined(invoker.inputs)) {
inputs = invoker.inputs
} else {
inputs = []
}
outputs = invoker.outputs
......@@ -134,6 +148,9 @@ template("compiled_action_foreach") {
host_executable = get_label_info(host_tool, "root_out_dir") + "/" +
get_label_info(host_tool, "name")
# Add the executable itself as an input.
inputs += [ host_executable ]
deps = [ host_tool ]
if (defined(invoker.deps)) {
deps += invoker.deps
......
......@@ -292,12 +292,12 @@ if (current_toolchain == host_toolchain) {
compiled_action(target_name) {
tool = ":genmacro"
# Output #included by source/patched-yasm/frontends/yasm/yasm.c.
sources = invoker.sources
inputs = invoker.sources
outputs = invoker.outputs
args = [
rebase_path(outputs[0], root_build_dir),
invoker.macro_varname,
rebase_path(sources[0], root_build_dir),
rebase_path(inputs[0], root_build_dir),
]
if (defined(invoker.deps)) {
deps = invoker.deps
......@@ -354,35 +354,37 @@ if (current_toolchain == host_toolchain) {
# This call doesn't fit into the re2c template above.
compiled_action("compile_re2c_lc3b") {
tool = ":re2c"
sources = [ "source/patched-yasm/modules/arch/lc3b/lc3bid.re" ]
inputs = [ "source/patched-yasm/modules/arch/lc3b/lc3bid.re" ]
outputs = [ "$target_gen_dir/lc3bid.c" ]
args = [
"-s",
"-o",
rebase_path(outputs[0], root_build_dir),
rebase_path(sources[0], root_build_dir),
rebase_path(inputs[0], root_build_dir),
]
}
compiled_action("generate_license") {
tool = ":genstring"
# Output #included by source/patched-yasm/frontends/yasm/yasm.c.
sources = [ "source/patched-yasm/COPYING" ]
inputs = [ "source/patched-yasm/COPYING" ]
outputs = [ "$yasm_gen_include_dir/license.c" ]
args = [
"license_msg",
rebase_path(outputs[0], root_build_dir),
rebase_path(sources[0], root_build_dir),
rebase_path(inputs[0], root_build_dir),
]
}
compiled_action("generate_module") {
tool = ":genmodule"
inputs = [ config_makefile ]
sources = [ "source/patched-yasm/libyasm/module.in" ]
inputs = [
"source/patched-yasm/libyasm/module.in",
config_makefile,
]
outputs = [ "$target_gen_dir/module.c" ]
args = [
rebase_path(sources[0], root_build_dir),
rebase_path(inputs[0], root_build_dir),
rebase_path(config_makefile, root_build_dir),
rebase_path(outputs[0], root_build_dir),
]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment