Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Unified Diff: BUILD.gn

Issue 2270833003: GN: extract optional() as a template and use for giflib-dependent code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: BUILD.gn
diff --git a/BUILD.gn b/BUILD.gn
index 692d0ba1be2c1d00f2de68689218ff55fe821399..5d53ad3c204999b7edb7ec336f482f07f1413aaf 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -4,6 +4,7 @@
# found in the LICENSE file.
declare_args() {
+ skia_use_giflib = !is_fuchsia
skia_use_libwebp = !is_fuchsia
}
@@ -62,7 +63,6 @@ config("skia_private") {
defines = [
"SK_GAMMA_APPLY_TO_A8",
- "SK_HAS_GIF_LIBRARY",
"SK_HAS_JPEG_LIBRARY",
"SK_HAS_PNG_LIBRARY",
@@ -179,35 +179,69 @@ if (is_x86) {
}
}
-if (skia_use_libwebp) {
- config("webp_config") {
- defines = [ "SK_HAS_WEBP_LIBRARY" ]
- }
- source_set("webp") {
- configs += skia_library_configs
- all_dependent_configs = [ ":webp_config" ]
- deps = [
- "//third_party/libwebp",
- ]
- sources = [
- "src/codec/SkWebpAdapterCodec.cpp",
- "src/codec/SkWebpCodec.cpp",
- "src/images/SkWEBPImageEncoder.cpp",
- ]
- }
-} else {
- source_set("webp") {
+template("optional") {
+ if (invoker.enabled) {
+ config(target_name + "_public") {
+ defines = invoker.public_defines
+ }
+ source_set(target_name) {
+ forward_variables_from(invoker, "*", [ "public_defines" ])
+ all_dependent_configs = [ ":" + target_name + "_public" ]
+ }
+ } else {
+ # If not enabled, a phony empty target that swallows all otherwise unused variables.
+ source_set(target_name) {
+ forward_variables_from(invoker,
+ "*",
+ [
+ "public_defines",
+ "configs",
+ "deps",
+ "sources",
+ ])
+ }
}
}
+set_defaults("optional") {
+ configs = default_configs
+}
+
+optional("gif") {
+ enabled = skia_use_giflib
+ public_defines = [ "SK_HAS_GIF_LIBRARY" ]
+
+ configs += skia_library_configs
+ deps = [
+ "//third_party/giflib",
+ ]
+ sources = [
+ "src/codec/SkGifCodec.cpp",
+ ]
+}
+
+optional("webp") {
+ enabled = skia_use_libwebp
+ public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
+
+ configs += skia_library_configs
+ deps = [
+ "//third_party/libwebp",
+ ]
+ sources = [
+ "src/codec/SkWebpAdapterCodec.cpp",
+ "src/codec/SkWebpCodec.cpp",
+ "src/images/SkWEBPImageEncoder.cpp",
+ ]
+}
component("skia") {
public_configs = [ ":skia_public" ]
configs += skia_library_configs
deps = [
+ ":gif",
":webp",
"//third_party/expat",
- "//third_party/giflib",
"//third_party/libjpeg-turbo:libjpeg",
"//third_party/libpng",
"//third_party/sfntly",
@@ -245,7 +279,6 @@ component("skia") {
"src/codec/SkBmpStandardCodec.cpp",
"src/codec/SkCodec.cpp",
"src/codec/SkCodecImageGenerator.cpp",
- "src/codec/SkGifCodec.cpp",
"src/codec/SkIcoCodec.cpp",
"src/codec/SkJpegCodec.cpp",
"src/codec/SkJpegDecoderMgr.cpp",
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698