Add public_deps support to the GN repack template |
|||
Issue description
Version: Chromium master revision 318e6f54 (#400326)
OS: All
What steps will reproduce the problem?
(1) Create a repack target that specifies public_deps (see below).
What is the expected output?
The `gn gen` step should succeed.
What do you see instead?
The `gn gen` step fails because repack() does not support public_deps.
Please use labels and text to provide additional information.
In order to find grit headers a executable/library target must depend on the grit target that generates the headers. This leads to redundant deps entries that can quickly become out of sync as grit targets change. For example:
grit("foo_resources") {
source = "foo_resources.grd"
outputs = [
"grit/foo_resources.h",
"grit/foo_resources_map.cc",
"grit/foo_resources_map.h",
"foo_resources.pak",
]
}
repack("pak") {
sources = [
"$root_gen_dir/blink/public/resources/blink_resources.pak",
"$root_gen_dir/components/components_resources.pak",
"$root_gen_dir/foo/foo_resources.pak",
]
deps = [
# These targets all have unique grit include paths that we need to know about.
"//third_party/WebKit/public:resources_grit",
"//components/resources:components_resources",
":foo_resources",
]
output = "$root_out_dir/foo.pak"
}
static_library("foo") {
sources = [ ... ]
deps = [
":pak"
# Duplicate the deps from the "pak" target. Otherwise grit headers
# won't be found and foo_resources_map.cc won't be linked.
"//third_party/WebKit/public:resources_grit",
"//components/resources:components_resources",
":foo_resources",
]
}
Once the repack() template supports public_deps we can rewrite the "pak" and "foo" targets as follows:
repack("pak") {
sources = [
"$root_gen_dir/blink/public/resources/blink_resources.pak",
"$root_gen_dir/components/components_resources.pak",
"$root_gen_dir/foo/foo_resources.pak",
]
public_deps = [
# Most of these targets now only need to be listed one time.
"//third_party/WebKit/public:resources_grit",
"//components/resources:components_resources",
":foo_resources",
]
output = "$root_out_dir/foo.pak"
}
static_library("foo") {
sources = [ ... ]
deps = [
# This will now also bring in the grit include paths from "pak"'s deps.
":pak"
# Still need to list this target to link foo_resources_map.cc
":foo_resources",
]
}
And here is the necessary change to tools/grit/repack.gni:
diff --git a/tools/grit/repack.gni b/tools/grit/repack.gni
index 42087f9..7dd1520 100644
--- a/tools/grit/repack.gni
+++ b/tools/grit/repack.gni
@@ -18,6 +18,7 @@ declare_args() {
# File name (single string) of the output file.
#
# deps [optional]
+# public_deps [optional]
# visibility [optional]
# Normal meaning.
template("repack") {
@@ -25,6 +26,7 @@ template("repack") {
forward_variables_from(invoker,
[
"deps",
+ "public_deps",
"testonly",
"visibility",
])
,
Jul 7 2016
CL: https://codereview.chromium.org/2134433002/
,
Jul 8 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/db06b8bc9bdc791699a827c381e6db34309563b9 commit db06b8bc9bdc791699a827c381e6db34309563b9 Author: marshall <marshall@chromium.org> Date: Fri Jul 08 17:16:39 2016 Add public_deps support to the GN repack template BUG= 623085 Review-Url: https://codereview.chromium.org/2134433002 Cr-Commit-Position: refs/heads/master@{#404422} [modify] https://crrev.com/db06b8bc9bdc791699a827c381e6db34309563b9/tools/grit/repack.gni
,
Jul 11 2016
|
|||
►
Sign in to add a comment |
|||
Comment 1 by marshall@chromium.org
, Jun 25 2016