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

Issue 732993 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Last visit 26 days ago
Closed: Apr 2018
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Feature



Sign in to add a comment

GN needs some concept of "friend" for exposing private headers

Project Member Reported by brettw@chromium.org, Jun 13 2017

Issue description

Currently if you list sources in public, the non-public sources become private. This is useful because you can control what your component's public API is.

But doing this also prevents things like tests from including private headers. In practice, attempting to define some headers as private seems to hit this issue very quickly, and private headers are almost unusable in Chrome.

I propose a "friend" concept to bypass checks on private headers. I'm thinking it will be like visibility, and the most common annotation would be:
  friend = [ ":*" ]

This would allow unit tests to use whatever headers they want without having to do awkward things with shared targets of only headers, or duplicating lists.
 
Components: Build
Owner: brettw@chromium.org
Status: Started (was: Available)
Project Member

Comment 3 by bugdroid1@chromium.org, Apr 5 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/28f3c4987aacf447643a4f36e4553cc830508b0b

commit 28f3c4987aacf447643a4f36e4553cc830508b0b
Author: Brett Wilson <brettw@chromium.org>
Date: Thu Apr 05 01:14:20 2018

Implement "friend" for GN header checking.

This allows a target to include private headers it wouldn't otherwise be
able to include. A target can provide a list of patterns of friend
targets that allow dependent targets to bypass public header checking.

A proper dependency path is still required, this applies only to the
concept of public/private headers on a target. Without this, it's
difficult to make a target be explicit about its public headers while
also allowing that target's own tests to use internal headers.

BUG= 732993 

Change-Id: I1cb94c7ac0db6f74cdcd49d08bcabedf70ea3eb0
Reviewed-on: https://chromium-review.googlesource.com/994453
Commit-Queue: Brett Wilson <brettw@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548279}
[modify] https://crrev.com/28f3c4987aacf447643a4f36e4553cc830508b0b/tools/gn/binary_target_generator.cc
[modify] https://crrev.com/28f3c4987aacf447643a4f36e4553cc830508b0b/tools/gn/binary_target_generator.h
[modify] https://crrev.com/28f3c4987aacf447643a4f36e4553cc830508b0b/tools/gn/functions_target.cc
[modify] https://crrev.com/28f3c4987aacf447643a4f36e4553cc830508b0b/tools/gn/header_checker.cc
[modify] https://crrev.com/28f3c4987aacf447643a4f36e4553cc830508b0b/tools/gn/header_checker.h
[modify] https://crrev.com/28f3c4987aacf447643a4f36e4553cc830508b0b/tools/gn/header_checker_unittest.cc
[modify] https://crrev.com/28f3c4987aacf447643a4f36e4553cc830508b0b/tools/gn/label_pattern.cc
[modify] https://crrev.com/28f3c4987aacf447643a4f36e4553cc830508b0b/tools/gn/label_pattern.h
[modify] https://crrev.com/28f3c4987aacf447643a4f36e4553cc830508b0b/tools/gn/target.h
[modify] https://crrev.com/28f3c4987aacf447643a4f36e4553cc830508b0b/tools/gn/variables.cc
[modify] https://crrev.com/28f3c4987aacf447643a4f36e4553cc830508b0b/tools/gn/variables.h
[modify] https://crrev.com/28f3c4987aacf447643a4f36e4553cc830508b0b/tools/gn/visibility.cc

Comment 4 by brettw@chromium.org, Apr 11 2018

Status: Fixed (was: Started)

Sign in to add a comment