Skip to content

Commit

Permalink
Convert GN visibility variables to lists.
Browse files Browse the repository at this point in the history
Currently this is either a list or a string. However, this is causing some problems because templates can't add to the invoker's visibility list without knowing if the original is a string or a list.

In an effort to make this consistent, I'm converting all visibiltiy to be lists, and will remove support for strings in a future build.

This exempts cld from header checking since it was confusing GN's header checker. It adds a ppapi header target as well that will be used by libyuv (that requires a roll).

TBR=scottmg

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

Cr-Commit-Position: refs/heads/master@{#293638}
  • Loading branch information
brettw authored and Commit bot committed Sep 6, 2014
1 parent 0d9c774 commit 9af4262
Show file tree
Hide file tree
Showing 41 changed files with 73 additions and 48 deletions.
2 changes: 1 addition & 1 deletion base/allocator/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ if (!is_android) {
} # !is_android

source_set("allocator_extension_thunks") {
visibility = "//base/*"
visibility = [ "//base/*" ]
sources = [
"allocator_extension_thunks.cc",
"allocator_extension_thunks.h",
Expand Down
2 changes: 1 addition & 1 deletion base/third_party/nspr/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# found in the LICENSE file.

source_set("nspr") {
visibility = "//base/*"
visibility = [ "//base/*" ]
sources = [
"prtime.cc",
"prtime.h",
Expand Down
2 changes: 1 addition & 1 deletion base/third_party/symbolize/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# found in the LICENSE file.

source_set("symbolize") {
visibility = "//base/*"
visibility = [ "//base/*" ]
sources = [
"config.h",
"demangle.cc",
Expand Down
2 changes: 1 addition & 1 deletion base/third_party/xdg_mime/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# found in the LICENSE file.

source_set("xdg_mime") {
visibility = "//base/*"
visibility = [ "//base/*" ]
sources = [
"xdgmime.c",
"xdgmime.h",
Expand Down
2 changes: 1 addition & 1 deletion base/third_party/xdg_user_dirs/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# found in the LICENSE file.

source_set("xdg_user_dirs") {
visibility = "//base/*"
visibility = [ "//base/*" ]
sources = [
"xdg_user_dir_lookup.cc",
"xdg_user_dir_lookup.h",
Expand Down
2 changes: 1 addition & 1 deletion build/secondary/testing/gtest/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ config("gtest_config") {
}

config("gtest_direct_config") {
visibility = ":*"
visibility = [ ":*" ]
defines = [ "UNIT_TEST" ]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import("//third_party/protobuf/proto_library.gni")

proto_library("cacheinvalidation_proto_cpp") {
# Depend on cacheinvalidation instead.
visibility = "//third_party/cacheinvalidation/*"
visibility = [ "//third_party/cacheinvalidation/*" ]

sources = [
"client.proto",
Expand Down
2 changes: 1 addition & 1 deletion build/secondary/third_party/nss/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ if (is_linux) {
# TODO(rsleevi): http://crbug.com/128134 - Break the circular dependency
# without requiring nssckbi to be built as a shared library.
source_set("nssckbi") {
visibility = ":nss" # This target is internal implementation detail.
visibility = [ ":nss" ] # This target is internal implementation detail.

sources = [
"nss/lib/ckfw/builtins/anchor.c",
Expand Down
13 changes: 11 additions & 2 deletions build/secondary/tools/grit/grit_rule.gni
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ template("grit") {
# The config and the action below get this visibility son only the generated
# source set can depend on them. The variable "target_name" will get
# overwritten inside the inner classes so we need to compute it here.
target_visibility = ":$target_name"
target_visibility = [ ":$target_name" ]

# The current grit setup makes an file in $output_dir/grit/foo.h that
# the source code expects to include via "grit/foo.h". It would be nice to
Expand Down Expand Up @@ -301,7 +301,16 @@ template("grit") {

args += grit_flags + assert_files_flags

visibility = target_visibility
if (defined(invoker.visibility)) {
# This needs to include both what the invoker specified (since they
# probably include generated headers from this target), as well as the
# generated source set (since there's no guarantee that the visibility
# specified by the invoker includes our target).
#
# Only define visibility at all if the invoker specified it. Otherwise,
# we want to keep the public "no visibility specified" default.
visibility = target_visibility + invoker.visibility
}

deps = [ "//tools/grit:grit_sources" ]
if (defined(invoker.deps)) {
Expand Down
2 changes: 1 addition & 1 deletion build/toolchain/win/midl.gni
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ template("midl") {
type_library_file = "{{source_name_part}}.tlb"

action_foreach(action_name) {
visibility = ":$source_set_name"
visibility = [ ":$source_set_name" ]

# This functionality is handled by the win-tool because the GYP build has
# MIDL support built-in.
Expand Down
2 changes: 1 addition & 1 deletion chrome/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ group("packed_resources") {
}

repack("packed_extra_resources") {
visibility = ":*"
visibility = [ ":*" ]
sources = [
"$root_gen_dir/chrome/browser_resources.pak",
"$root_gen_dir/chrome/app/theme/chrome_unscaled_resources.pak",
Expand Down
2 changes: 1 addition & 1 deletion chrome/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ grit("generated_resources") {
# GYP version: chrome/chrome_resources.gyp:chrome_strings_map
action("make_generated_resources_map") {
# Targets should depend on generated_resources_map instead.
visibility = ":generated_resources_map"
visibility = [ ":generated_resources_map" ]

script = "//chrome/browser/metrics/variations/generate_resources_map.py"

Expand Down
2 changes: 1 addition & 1 deletion chrome/chrome_repack_locales.gni
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ template("chrome_repack_locales") {
locale_targets += [ ":$current_name" ]

_repack_one_locale(current_name) {
visibility = ":$group_target_name"
visibility = [ ":$group_target_name" ]
locale = input_locale

# Compute the output name. Mac uses a different location.
Expand Down
2 changes: 1 addition & 1 deletion chrome/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ if (is_linux) {
# Windows.
import("//chrome/version.gni")
process_version("version") {
visibility = ":common"
visibility = [ ":common" ]
source = "chrome_version_info_posix.h.version"
output = "$target_gen_dir/chrome_version_info_posix.h"
}
Expand Down
2 changes: 1 addition & 1 deletion components/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import("//build/config/features.gni")
# Collection of all components. You wouldn't link to this, but this is rather
# to reference the files so they can be compiled by the build system.
group("all_components") {
visibility = "//:*" # Only for the root targets to bring in.
visibility = [ "//:*" ] # Only for the root targets to bring in.

deps = [
"//components/auto_login_parser",
Expand Down
2 changes: 1 addition & 1 deletion components/autofill/core/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ config("autofill_browser_config") {

# GYP version: components/autofill.gyp:autofill_regexes
action("regexes") {
visibility = "//components/autofill/*"
visibility = [ "//components/autofill/*" ]
script = "//build/escape_unicode.py"

inputs = [
Expand Down
2 changes: 1 addition & 1 deletion components/domain_reliability/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# found in the LICENSE file.

action("bake_in_configs") {
visibility = ":*"
visibility = [ ":*" ]
script = "bake_in_configs.py"

inputs = [
Expand Down
2 changes: 1 addition & 1 deletion components/search_engines/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static_library("search_engines") {
}

json_to_struct("prepopulated_engines") {
visibility = ":*"
visibility = [ ":*" ]

source = "prepopulated_engines.json"
schema_file = "prepopulated_engines_schema.json"
Expand Down
2 changes: 1 addition & 1 deletion content/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ grit("resources") {
# This target exists to "hold" the content_export header so we can do proper
# inclusion testing of it.
source_set("export") {
visibility = "//content/*"
visibility = [ "//content/*" ]
sources = [
"content/common/content_export.h"
]
Expand Down
4 changes: 2 additions & 2 deletions content/browser/devtools/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ grit("devtools_resources") {
}

action("gen_devtools_protocol_constants") {
visibility = ":devtools_protocol_constants"
visibility = [ ":devtools_protocol_constants" ]

script = "//content/public/browser/devtools_protocol_constants_generator.py"

Expand All @@ -57,6 +57,6 @@ action("gen_devtools_protocol_constants") {
}

source_set("devtools_protocol_constants") {
visibility = ":resources"
visibility = [ ":resources" ]
sources = get_target_outputs(":gen_devtools_protocol_constants")
}
2 changes: 1 addition & 1 deletion content/browser/tracing/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tracing_gen_dir = "$root_gen_dir/content/browser/tracing"
tracing_grd = "$tracing_gen_dir/tracing_resources.grd"

action("generate_tracing_grd") {
visibility = ":*"
visibility = [ ":*" ]
script = "generate_trace_viewer_grd.py"

input_pages = [
Expand Down
2 changes: 1 addition & 1 deletion content/plugin/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import("//build/config/features.gni")
# This is the NPAPI plugin process. It isn't used on Linux.
if (enable_plugins && !is_linux) {
source_set("plugin") {
visibility = "//content/*"
visibility = [ "//content/*" ]
sources = [
"plugin_channel.cc",
"plugin_channel.h",
Expand Down
8 changes: 4 additions & 4 deletions content/shell/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ static_library("content_shell_lib") {
}

grit("content_shell_resources_grit") {
visibility = ":*"
visibility = [ ":*" ]
source = "shell_resources.grd"
outputs = [
"grit/shell_resources.h",
Expand All @@ -336,14 +336,14 @@ copy("copy_shell_resources") {
# Font copies.
if (!is_mac) {
copy("copy_ahem") {
visibility = ":*"
visibility = [ ":*" ]
sources = [ "renderer/test_runner/resources/fonts/AHEM____.TTF" ]
outputs = [ "$root_out_dir/AHEM____.TTF" ]
}
}
if (use_x11) {
copy("copy_x11_fonts") {
visibility = ":*"
visibility = [ ":*" ]
sources = [
"renderer/test_runner/resources/fonts/fonts.conf",
"//third_party/gardiner_mod/GardinerModBug.ttf",
Expand All @@ -354,7 +354,7 @@ if (use_x11) {
}
if (is_android) {
copy("copy_android_fonts") {
visibility = ":*"
visibility = [ ":*" ]
sources = [
"renderer/test_runner/resources/fonts/android_main_fonts.xml",
"renderer/test_runner/resources/fonts/android_fallback_fonts.xml",
Expand Down
2 changes: 1 addition & 1 deletion extensions/generated_extensions_api.gni
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ template("generated_extensions_api") {

# Keep a copy of the target_name here since it will be trampled
# in nested targets.
target_visibility = ":$target_name"
target_visibility = [ ":$target_name" ]

generated_config_name = target_name + "_generated_config"
config(generated_config_name) {
Expand Down
2 changes: 1 addition & 1 deletion google_apis/gcm/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ component("gcm") {
}

proto_library("proto") {
visibility = ":*"
visibility = [ ":*" ]
sources = [
"protocol/android_checkin.proto",
"protocol/checkin.proto",
Expand Down
2 changes: 1 addition & 1 deletion media/cast/logging/proto/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ source_set("proto") {
}

proto_library("cast_logging_proto") {
visibility = ":proto"
visibility = [ ":proto" ]
sources = [
"raw_events.proto",
]
Expand Down
2 changes: 1 addition & 1 deletion media/cast/test/proto/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ source_set("proto") {
}

proto_library("cast_network_simulation_proto") {
visibility = ":proto"
visibility = [ ":proto" ]
sources = [
"network_simulation_model.proto",
]
Expand Down
2 changes: 1 addition & 1 deletion mojo/environment/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ source_set("chromium") {
# GYP version: mojo_base.gyp:mojo_environment_chromium_impl
component("chromium_impl") {
output_name = "mojo_environment_impl"
visibility = "//mojo/*"
visibility = [ "//mojo/*" ]

sources = [
"default_async_waiter_impl.cc",
Expand Down
11 changes: 9 additions & 2 deletions mojo/public/tools/bindings/mojom.gni
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,18 @@ template("mojom") {
"{{source_gen_dir}}/{{source_name_part}}_mojom.py",
]

target_visibility = ":$target_name"
if (defined(invoker.visibility)) {
# Need to save this because the the target_name is overwritten inside the
# action to be that of the action itself. Only define this in the case the
# var is used to avoid unused var error.
target_visibility = [ ":$target_name" ]
}

generator_target_name = target_name + "_generator"
action_foreach(generator_target_name) {
visibility = target_visibility
if (defined(invoker.visibility)) {
visibility = target_visibility + invoker.visibility
}
script = generator_script
inputs = generator_sources
sources = invoker.sources
Expand Down
6 changes: 6 additions & 0 deletions ppapi/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ source_set("ppapi_c") {
sources = gypi_values.c_source_files
}

# Some targets need to depend on the PPAPI version only. This target exists so
# they can include this header without header check warnings.
source_set("ppapi_macros") {
sources = [ "c/pp_macros.h" ]
}

source_set("ppapi_cpp_objects") {
sources = gypi_values.cpp_source_files

Expand Down
2 changes: 1 addition & 1 deletion skia/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -699,5 +699,5 @@ source_set("skia_opts") {
"//base",
]

visibility = ":skia"
visibility = [ ":skia" ]
}
2 changes: 1 addition & 1 deletion third_party/boringssl/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ config("openssl_config") {

# Config internal to this build file.
config("openssl_internal_config") {
visibility = ":*" # Only targets in this file can depend on this.
visibility = [ ":*" ] # Only targets in this file can depend on this.
}

# The list of BoringSSL files is kept in boringssl.gypi.
Expand Down
4 changes: 4 additions & 0 deletions third_party/cld/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ config("cld_config") {
}

static_library("cld") {
# This target includes its own copy of "base" which confuses the header
# checker.
check_includes = false

sources = [
"encodings/compact_lang_det/cldutil.cc",
"encodings/compact_lang_det/cldutil.h",
Expand Down
2 changes: 1 addition & 1 deletion third_party/dom_distiller_js/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ source_set("proto") {
}

proto_library("dom_distiller_proto") {
visibility = ":*"
visibility = [ ":*" ]
sources = [ "package/proto/dom_distiller.proto" ]
proto_out_dir = "third_party/dom_distiller_js"
}
3 changes: 2 additions & 1 deletion third_party/protobuf/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ source_set("protobuf_lite") {
# into that category. Do not use in Chrome code.

source_set("protobuf_full") {
visibility = ":*" # Prevent people from depending on this outside our file.
# Prevent people from depending on this outside our file.
visibility = [ ":*" ]

sources = protobuf_lite_sources
sources += [
Expand Down
2 changes: 1 addition & 1 deletion third_party/protobuf/proto_library.gni
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ template("proto_library") {
action_name = "${target_name}_gen"
source_set_name = target_name
action_foreach(action_name) {
visibility = ":$source_set_name"
visibility = [ ":$source_set_name" ]

script = "//tools/protoc_wrapper/protoc_wrapper.py"

Expand Down
Loading

0 comments on commit 9af4262

Please sign in to comment.