New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 623085 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Jul 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Feature



Sign in to add a comment

Add public_deps support to the GN repack template

Project Member Reported by marshall@chromium.org, Jun 24 2016

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",
                            ])

 
The only benefit currently from adding public_deps to grit() is the inheritance of include_dirs via public_configs (e.g. "gen/foo" is added to include_dirs). Based on comments in tools/grit/grit_rule.gni and the use of use_qualified_include = true by some grit() targets it seems like we're transitioning to the use absolute include paths relative to the "gen" directory (e.g. "foo/grit/foo_resources.h" instead of "grit/foo_resources.h"). Therefore it seems that this change will be unnecessary once we've finished that transition and all include paths are relative to the "gen" directory.
Owner: marshall@chromium.org
Status: Started (was: Untriaged)
CL: https://codereview.chromium.org/2134433002/
Project Member

Comment 3 by bugdroid1@chromium.org, 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

Status: Fixed (was: Started)

Sign in to add a comment