Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Un-nest configs in GN files.
Browse files Browse the repository at this point in the history
People sometimes nest targets or configs, usually with the assumption that this limits the visibility of a config to within a target. But this nesting provides no visibility restrictions over declaring it outside of a block.

Un-nest for clarity.

Re-land of http://crrev.com/1318823008 while preserving config ordering.

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

Cr-Commit-Position: refs/heads/master@{#346964}
  • Loading branch information
brettw authored and Commit bot committed Sep 2, 2015
1 parent 5698e42 commit 6dd952c
Show file tree
Hide file tree
Showing 18 changed files with 334 additions and 256 deletions.
26 changes: 15 additions & 11 deletions build/secondary/testing/gtest/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ config("gtest_direct_config") {
defines = [ "UNIT_TEST" ]
}

config("gtest_warnings") {
if (is_win && is_clang) {
# The Mutex constructor initializer list in gtest-port.cc is incorrectly
# ordered. See
# https://groups.google.com/d/msg/googletestframework/S5uSV8L2TX8/U1FaTDa6J6sJ.
cflags = [ "-Wno-reorder" ]
}
}

static_library("gtest") {
# TODO http://crbug.com/412064 enable this flag all the time.
testonly = !is_component_build
Expand Down Expand Up @@ -121,17 +130,12 @@ static_library("gtest") {
public_configs = [ ":gtest_direct_config" ]

configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]

config("gtest_warnings") {
if (is_win && is_clang) {
# The Mutex constructor initializer list in gtest-port.cc is incorrectly
# ordered. See
# https://groups.google.com/d/msg/googletestframework/S5uSV8L2TX8/U1FaTDa6J6sJ.
cflags = [ "-Wno-reorder" ]
}
}
configs += [ ":gtest_warnings" ]
configs += [
"//build/config/compiler:no_chromium_code",

# Must be after no_chromium_code for warning flags to be ordered correctly.
":gtest_warnings",
]
}

source_set("gtest_main") {
Expand Down
24 changes: 12 additions & 12 deletions sdch/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ config("sdch_config") {
include_dirs = [ "open-vcdiff/src" ]
}

# gn orders flags on a target before flags from configs. The default config
# adds -Wall, and these flags have to be after -Wall -- so they need to come
# from a config and can't be on the target directly.
config("sdch_warnings") {
cflags = []
if (is_linux) {
# TODO(mostynb): remove this if open-vcdiff is ever updated for c++11:
cflags += [ "-Wno-deprecated-declarations" ]
}
}

static_library("sdch") {
sources = [
"logging_forward.h",
Expand Down Expand Up @@ -42,25 +53,14 @@ static_library("sdch") {
"open-vcdiff/vsprojects/stdint.h",
]

configs += [ ":sdch_warnings" ]
public_configs = [ ":sdch_config" ]

deps = [
"//base",
"//third_party/zlib",
]

# gn orders flags on a target before flags from configs. The default config
# adds -Wall, and these flags have to be after -Wall -- so they need to come
# from a config and can't be on the target directly.
config("sdch_warnings") {
cflags = []
if (is_linux) {
# TODO(mostynb): remove this if open-vcdiff is ever updated for c++11:
cflags += [ "-Wno-deprecated-declarations" ]
}
}
configs += [ ":sdch_warnings" ]

if (is_linux || is_android) {
include_dirs = [ "linux" ]
} else if (is_ios) {
Expand Down
25 changes: 15 additions & 10 deletions third_party/brotli/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

config("brotli_warnings") {
if (is_clang) {
# IncrementalCopyFastPath in decode.c can be unused.
# (The file looks very different upstream, this is probably no longer
# needed after rolling brotli the next time.)
cflags = [ "-Wno-unused-function" ]
}
}

source_set("brotli") {
sources = [
"dec/bit_reader.c",
Expand All @@ -23,17 +32,13 @@ source_set("brotli") {
"dec/types.h",
]

config("brotli_warnings") {
if (is_clang) {
# IncrementalCopyFastPath in decode.c can be unused.
# (The file looks very different upstream, this is probably no longer
# needed after rolling brotli the next time.)
cflags = [ "-Wno-unused-function" ]
}
}
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
configs += [ ":brotli_warnings" ]
configs += [
"//build/config/compiler:no_chromium_code",

# Must be after no_chromium_code for warning flags to be ordered correctly.
":brotli_warnings",
]

# Since we are never debug brotli, freeze the optimizations to -O2.
if (is_debug) {
Expand Down
22 changes: 14 additions & 8 deletions third_party/cld_2/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ cld2_platform_support = "static"

cld2_table_size = 2

config("cld2_data_warnings") {
visibility = [ ":*" ]
if (is_clang) {
# The generated files don't have braces around subobject initializers.
cflags = [ "-Wno-missing-braces" ]
}
}

source_set("cld2_data") {
sources = gypi_values.cld2_data_sources
if (cld2_table_size == 0) {
Expand All @@ -46,15 +54,13 @@ source_set("cld2_data") {
"src/public",
]

config("cld2_data_warnings") {
if (is_clang) {
# The generated files don't have braces around subobject initializers.
cflags = [ "-Wno-missing-braces" ]
}
}
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
configs += [ ":cld2_data_warnings" ]
configs += [
"//build/config/compiler:no_chromium_code",

# Must be after no_chromium_code for warning flags to be ordered correctly.
":cld2_data_warnings",
]
}

# As in the corresponding gyp file, this just builds the core interfaces for
Expand Down
66 changes: 36 additions & 30 deletions third_party/harfbuzz-ng/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,36 @@ if (use_system_harfbuzz) {
include_dirs = [ "src" ]
}

config("harfbuzz_warnings") {
cflags = []
if (is_clang) {
cflags += [
"-Wno-unused-value",

# Harfbuzz uses unused typedefs for its static asserts (and its
# static asserts are strange enough that they can't be replaced
# by static_assert).
"-Wno-unused-local-typedef",
]
}
if (is_win) {
# Result of 32-bit shift implicitly converted to 64 bits.
cflags += [ "/wd4334" ]
}
}

# See also chrome/browser/ui/libgtk2ui/BUILD.gn which pulls this.
config("pangoft2_link_hack") {
if (is_linux && use_pango && !is_chromeos && !is_official_build &&
current_cpu != "arm" && current_cpu != "mipsel" &&
!is_component_build) {
# These symbols are referenced from libpangoft2, which will be
# dynamically linked later.
ldflags =
[ "-Wl,-uhb_ft_face_create_cached,-uhb_glib_get_unicode_funcs" ]
}
}

static_library("harfbuzz-ng") {
sources = [
"src/hb-atomic-private.hh",
Expand Down Expand Up @@ -146,26 +176,13 @@ if (use_system_harfbuzz) {
]

configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]

config("harfbuzz_warnings") {
cflags = []
if (is_clang) {
cflags += [
"-Wno-unused-value",

# Harfbuzz uses unused typedefs for its static asserts (and its
# static asserts are strange enough that they can't be replaced
# by static_assert).
"-Wno-unused-local-typedef",
]
}
if (is_win) {
cflags += [ "/wd4334" ] # Result of 32-bit shift implicitly converted to 64 bits.
}
}
configs += [ ":harfbuzz_warnings" ]
configs += [
"//build/config/compiler:no_chromium_code",

# Must be after no_chromium_code for warning flags to be ordered
# correctly.
":harfbuzz_warnings",
]
public_configs = [ ":harfbuzz-ng_config" ]

deps = [
Expand Down Expand Up @@ -199,16 +216,5 @@ if (use_system_harfbuzz) {
]
}

# See also chrome/browser/ui/libgtk2ui/BUILD.gn which pulls this.
config("pangoft2_link_hack") {
if (is_linux && use_pango && !is_chromeos && !is_official_build &&
current_cpu != "arm" && current_cpu != "mipsel" &&
!is_component_build) {
# These symbols are referenced from libpangoft2, which will be
# dynamically linked later.
ldflags =
[ "-Wl,-uhb_ft_face_create_cached,-uhb_glib_get_unicode_funcs" ]
}
}
}
}
14 changes: 8 additions & 6 deletions third_party/hunspell/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ config("hunspell_config") {
]
}

config("hunspell_warnings") {
if (is_clang) {
cflags = [ "-Wno-unused-private-field" ]
}
}

source_set("hunspell") {
sources = [
"google/bdict.cc",
Expand Down Expand Up @@ -51,15 +57,11 @@ source_set("hunspell") {
"src/parsers/textparser.hxx",
]

config("hunspell_warnings") {
if (is_clang) {
cflags = [ "-Wno-unused-private-field" ]
}
}

configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
"//build/config/compiler:no_chromium_code",

# Must be after no_chromium_code for warning flags to be ordered correctly.
":hunspell_warnings",
]
public_configs = [ ":hunspell_config" ]
Expand Down
17 changes: 9 additions & 8 deletions third_party/libpng/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ config("libpng_config") {
}
}

# Must be in a config because of how GN orders flags (otherwise -Wall will
# appear after this, and turn it back on).
config("clang_warnings") {
if (is_clang) {
# Upstream uses self-assignment to avoid warnings.
cflags = [ "-Wno-self-assign" ]
}
}

source_set("libpng_sources") {
sources = [
"png.c",
Expand Down Expand Up @@ -62,14 +71,6 @@ source_set("libpng_sources") {
"//third_party/zlib",
]

# Must be in a config because of how GN orders flags (otherwise -Wall will
# appear after this, and turn it back on).
config("clang_warnings") {
if (is_clang) {
# Upstream uses self-assignment to avoid warnings.
cflags = [ "-Wno-self-assign" ]
}
}
configs += [ ":clang_warnings" ]
}

Expand Down
28 changes: 17 additions & 11 deletions third_party/libusb/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ config("libusb_config") {
include_dirs = [ "src/libusb" ]
}

config("libusb_warnings") {
visibility = [ ":*" ]
if (is_clang) {
# guid_eq in windows_usb.c is unused.
cflags = [ "-Wno-unused-function" ]
if (is_linux && !use_udev) {
cflags += [ "-Wno-pointer-sign" ]
}
}
}

static_library("libusb") {
sources = [
"src/config.h",
Expand Down Expand Up @@ -46,18 +57,13 @@ static_library("libusb") {
deps = []
include_dirs = [ "src/libusb/os" ]

config("libusb_warnings") {
if (is_clang) {
# guid_eq in windows_usb.c is unused.
cflags = [ "-Wno-unused-function" ]
if (is_linux && !use_udev) {
cflags += [ "-Wno-pointer-sign" ]
}
}
}
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
configs += [ ":libusb_warnings" ]
configs += [
"//build/config/compiler:no_chromium_code",

# Must be after no_chromium_code for warning flags to be ordered correctly.
":libusb_warnings",
]

public_configs = [ ":libusb_config" ]

Expand Down
13 changes: 7 additions & 6 deletions third_party/libwebp/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ source_set("libwebp_enc") {
]
}

config("libwebp_utils_warnings") {
if (is_clang) {
# See https://code.google.com/p/webp/issues/detail?id=253.
cflags = [ "-Wno-incompatible-pointer-types" ]
}
}

source_set("libwebp_utils") {
sources = [
"utils/bit_reader.c",
Expand All @@ -182,12 +189,6 @@ source_set("libwebp_utils") {

all_dependent_configs = [ ":libwebp_config" ]

config("libwebp_utils_warnings") {
if (is_clang) {
# See https://code.google.com/p/webp/issues/detail?id=253.
cflags = [ "-Wno-incompatible-pointer-types" ]
}
}
public_configs = [ ":libwebp_utils_warnings" ]
}

Expand Down
Loading

0 comments on commit 6dd952c

Please sign in to comment.