Reland "Build SkRawCodec in GN"

Add BUILD.gn files for dng_sdk and piex and updated BUILD.gn to
build SkRawCodec.

We stopped testing raw images when we switched to GN, so this will
bring back our testing.

Leave SkRawCodec disabled on Windows, where we've had problems in the
past.

Originally landed in issue 4603. Reverted due to build errors.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2463433002

Review-Url: https://codereview.chromium.org/2463433002
diff --git a/BUILD.gn b/BUILD.gn
index 96ee628..d5a6ad0 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -20,6 +20,7 @@
   skia_use_libpng = true
   skia_use_libwebp = !is_fuchsia
   skia_use_mesa = false
+  skia_use_raw = !is_win
   skia_use_sfntly = !is_fuchsia && !is_win  # TODO: icu on Windows, re-enable this.
   skia_use_zlib = true
 
@@ -284,9 +285,13 @@
                              [
                                "public_defines",
                                "sources_when_disabled",
+                               "configs_to_remove",
                              ])
       all_dependent_configs = [ ":" + target_name + "_public" ]
       configs += skia_library_configs
+      if (defined(invoker.configs_to_remove)) {
+        configs -= invoker.configs_to_remove
+      }
     }
   } else {
     source_set(target_name) {
@@ -298,6 +303,7 @@
                                "libs",
                                "sources",
                                "sources_when_disabled",
+                               "configs_to_remove",
                              ])
       if (defined(invoker.sources_when_disabled)) {
         sources = invoker.sources_when_disabled
@@ -442,6 +448,26 @@
   ]
 }
 
+optional("raw") {
+  enabled = skia_use_raw && skia_use_libjpeg_turbo && skia_use_zlib
+  public_defines = [ "SK_CODEC_DECODES_RAW" ]
+
+  deps = [
+    "//third_party/dng_sdk",
+    "//third_party/libjpeg-turbo:libjpeg",
+    "//third_party/piex",
+  ]
+
+  # SkRawCodec catches any exceptions thrown by dng_sdk, insulating the rest of
+  # Skia.
+  configs_to_remove = [ "//gn:no_exceptions" ]
+
+  sources = [
+    "src/codec/SkRawAdapterCodec.cpp",
+    "src/codec/SkRawCodec.cpp",
+  ]
+}
+
 optional("typeface_freetype") {
   enabled = skia_use_freetype
 
@@ -501,6 +527,7 @@
     ":none",
     ":pdf",
     ":png",
+    ":raw",
     ":sse2",
     ":sse41",
     ":sse42",