aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-07-19 08:25:00 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-19 08:25:00 -0700
commitf037d48e29000554abcd117445c4249071bb9fb3 (patch)
tree8492f6981c971f486cf29958620604aa6bcb2275
parent916e02a6d004af5b83a636d1507bfdf2da8543ce (diff)
GN: refactor third_party/gni
This fixes the build on Linux (dep on third_party:zlib -> third_party/zlib). I've moved declare_args() {} back to each .gn file... seems like args want to be as local as possible in GN land. Additionally, refactor all the common third_party config and warning flag changes into a template, third_party. This lets it all live together in a .gni: at head unwanted_configs can be in a .gni (it's just a variable) but config("no_warnings") (and thus third_party_configs) cannot, as configs cannot be part of .gni files. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2163653002 Review-Url: https://codereview.chromium.org/2163653002
-rw-r--r--third_party/BUILD.gn19
-rw-r--r--third_party/third_party.gni24
-rw-r--r--third_party/zlib/BUILD.gn8
3 files changed, 25 insertions, 26 deletions
diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn
index 96837d2b3a..1aca3ca9cb 100644
--- a/third_party/BUILD.gn
+++ b/third_party/BUILD.gn
@@ -3,24 +3,19 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("third_party.gni")
-
-# Most third_party code should disable warnings: if we don't maintain the code, warnings are noise.
-config("no_warnings") {
- cflags = [ "-w" ]
+declare_args() {
}
-third_party_configs = [ ":no_warnings" ]
+
+import("third_party.gni")
config("libpng_public") {
include_dirs = [ "libpng" ]
}
-source_set("libpng") {
+third_party("libpng") {
public_configs = [ ":libpng_public" ]
- configs += third_party_configs
- configs -= unwanted_configs
deps = [
- ":zlib",
+ "//third_party/zlib",
]
sources = [
"libpng/png.c",
@@ -44,10 +39,8 @@ source_set("libpng") {
config("libjpeg-turbo_config") {
include_dirs = [ "externals/libjpeg-turbo" ]
}
-source_set("libjpeg-turbo") {
+third_party("libjpeg-turbo") {
public_configs = [ ":libjpeg-turbo_config" ]
- configs += third_party_configs
- configs -= unwanted_configs
sources = [
"externals/libjpeg-turbo/jcapimin.c",
diff --git a/third_party/third_party.gni b/third_party/third_party.gni
index 813ee385f3..ede698c4af 100644
--- a/third_party/third_party.gni
+++ b/third_party/third_party.gni
@@ -3,13 +3,19 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-declare_args() {
-}
+template("third_party") {
+ source_set(target_name) {
+ forward_variables_from(invoker, "*")
+
+ # Warnings are just noise if we're not maintaining the code.
+ cflags = [ "-w" ]
-# Chrome's GN environment sets up a bunch of default configs we don't need/want here.
-unwanted_configs = [
- "//build/config/clang:extra_warnings",
- "//build/config/clang:find_bad_constructs",
- "//build/config/compiler:chromium_code",
- "//build/config:feature_flags",
-]
+ # Chrome's GN environment sets up a bunch of default configs we don't need/want here.
+ configs -= [
+ "//build/config/clang:extra_warnings",
+ "//build/config/clang:find_bad_constructs",
+ "//build/config/compiler:chromium_code",
+ "//build/config:feature_flags",
+ ]
+ }
+}
diff --git a/third_party/zlib/BUILD.gn b/third_party/zlib/BUILD.gn
index 0fff083a43..6338dba278 100644
--- a/third_party/zlib/BUILD.gn
+++ b/third_party/zlib/BUILD.gn
@@ -3,16 +3,16 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+declare_args() {
+}
+
import("../third_party.gni")
config("zlib_public") {
include_dirs = [ "../externals/zlib" ]
}
-source_set("zlib") {
+third_party("zlib") {
public_configs = [ ":zlib_public" ]
- configs -= unwanted_configs
-
- cflags = [ "-w" ]
sources = [
"../externals/zlib/adler32.c",