XFA: Fix win8 gn build under chromium checkout (non-xfa)

The no nominmax config was lost when moving from master.
Fix a few other small differences along the way, and fully
conditionalize the build of tiff.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/1514633002 .
diff --git a/BUILD.gn b/BUILD.gn
index fdb022e..f72c3e4 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -609,10 +609,7 @@
       "core/src/fxge/win32/fx_win32_print.cpp",
       "core/src/fxge/win32/win32_int.h",
     ]
-    configs -= [
-      "//build/config/win:lean_and_mean",
-      "//build/config/win:nominmax",
-    ]
+    configs -= [ "//build/config/win:lean_and_mean" ]
   }
 }
 
diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn
index 16adbf7..11456b1 100644
--- a/third_party/BUILD.gn
+++ b/third_party/BUILD.gn
@@ -2,6 +2,8 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("../pdfium.gni")
+
 group("third_party") {
   deps = [
     ":bigint",
@@ -10,23 +12,23 @@
   ]
 }
 
-static_library("bigint") {
+source_set("bigint") {
   configs -= [ "//build/config/compiler:chromium_code" ]
   configs += [
     "//build/config/compiler:no_chromium_code",
     "//third_party/pdfium:pdfium_config",
   ]
   sources = [
+    "bigint/BigInteger.cc",
     "bigint/BigInteger.hh",
     "bigint/BigIntegerLibrary.hh",
-    "bigint/BigIntegerUtils.hh",
-    "bigint/BigUnsigned.hh",
-    "bigint/NumberlikeArray.hh",
-    "bigint/BigUnsignedInABase.hh",
-    "bigint/BigInteger.cc",
     "bigint/BigIntegerUtils.cc",
+    "bigint/BigIntegerUtils.hh",
     "bigint/BigUnsigned.cc",
+    "bigint/BigUnsigned.hh",
     "bigint/BigUnsignedInABase.cc",
+    "bigint/BigUnsignedInABase.hh",
+    "bigint/NumberlikeArray.hh",
   ]
 }
 
@@ -39,7 +41,9 @@
   }
 }
 
-source_set("fx_freetype") {
+# Tests may link against this even if the production library doesn't,
+# so it needs to be separate from it.
+static_library("fx_freetype") {
   configs -= [ "//build/config/compiler:chromium_code" ]
   configs += [
     "//build/config/compiler:no_chromium_code",
@@ -119,6 +123,7 @@
 }
 
 config("fx_lcms2_warnings") {
+  visibility = [ ":*" ]
   if (is_clang) {
     cflags = [
       # cmslut.cc is sloppy with aggregate initialization. Version 2.7 of this
@@ -292,50 +297,52 @@
   ]
 }
 
-source_set("fx_tiff") {
-  configs -= [ "//build/config/compiler:chromium_code" ]
-  configs += [
-    "//build/config/compiler:no_chromium_code",
-    "//third_party/pdfium:pdfium_config",
-  ]
-  sources = [
-    "tiff_v403/tiffiop.h",
-    "tiff_v403/tif_aux.c",
-    "tiff_v403/tif_close.c",
-    "tiff_v403/tif_codec.c",
-    "tiff_v403/tif_color.c",
-    "tiff_v403/tif_compress.c",
-    "tiff_v403/tif_dir.c",
-    "tiff_v403/tif_dirinfo.c",
-    "tiff_v403/tif_dirread.c",
-    "tiff_v403/tif_dirwrite.c",
-    "tiff_v403/tif_dumpmode.c",
-    "tiff_v403/tif_error.c",
-    "tiff_v403/tif_extension.c",
-    "tiff_v403/tif_fax3.c",
-    "tiff_v403/tif_fax3sm.c",
-    "tiff_v403/tif_flush.c",
-    "tiff_v403/tif_getimage.c",
-    "tiff_v403/tif_jpeg.c",
-    "tiff_v403/tif_luv.c",
-    "tiff_v403/tif_lzw.c",
-    "tiff_v403/tif_next.c",
-    "tiff_v403/tif_ojpeg.c",
-    "tiff_v403/tif_open.c",
-    "tiff_v403/tif_packbits.c",
-    "tiff_v403/tif_pixarlog.c",
-    "tiff_v403/tif_predict.c",
-    "tiff_v403/tif_print.c",
-    "tiff_v403/tif_read.c",
-    "tiff_v403/tif_strip.c",
-    "tiff_v403/tif_swab.c",
-    "tiff_v403/tif_thunder.c",
-    "tiff_v403/tif_tile.c",
-    "tiff_v403/tif_version.c",
-    "tiff_v403/tif_warning.c",
-    "tiff_v403/tif_write.c",
-    "tiff_v403/tif_zip.c",
-  ]
+if (pdf_enable_xfa) {
+  source_set("fx_tiff") {
+    configs -= [ "//build/config/compiler:chromium_code" ]
+    configs += [
+      "//build/config/compiler:no_chromium_code",
+      "//third_party/pdfium:pdfium_config",
+    ]
+    sources = [
+      "tiff_v403/tiffiop.h",
+      "tiff_v403/tif_aux.c",
+      "tiff_v403/tif_close.c",
+      "tiff_v403/tif_codec.c",
+      "tiff_v403/tif_color.c",
+      "tiff_v403/tif_compress.c",
+      "tiff_v403/tif_dir.c",
+      "tiff_v403/tif_dirinfo.c",
+      "tiff_v403/tif_dirread.c",
+      "tiff_v403/tif_dirwrite.c",
+      "tiff_v403/tif_dumpmode.c",
+      "tiff_v403/tif_error.c",
+      "tiff_v403/tif_extension.c",
+      "tiff_v403/tif_fax3.c",
+      "tiff_v403/tif_fax3sm.c",
+      "tiff_v403/tif_flush.c",
+      "tiff_v403/tif_getimage.c",
+      "tiff_v403/tif_jpeg.c",
+      "tiff_v403/tif_luv.c",
+      "tiff_v403/tif_lzw.c",
+      "tiff_v403/tif_next.c",
+      "tiff_v403/tif_ojpeg.c",
+      "tiff_v403/tif_open.c",
+      "tiff_v403/tif_packbits.c",
+      "tiff_v403/tif_pixarlog.c",
+      "tiff_v403/tif_predict.c",
+      "tiff_v403/tif_print.c",
+      "tiff_v403/tif_read.c",
+      "tiff_v403/tif_strip.c",
+      "tiff_v403/tif_swab.c",
+      "tiff_v403/tif_thunder.c",
+      "tiff_v403/tif_tile.c",
+      "tiff_v403/tif_version.c",
+      "tiff_v403/tif_warning.c",
+      "tiff_v403/tif_write.c",
+      "tiff_v403/tif_zip.c",
+    ]
+  }
 }
 
 source_set("fx_zlib") {
diff --git a/third_party/base/logging.h b/third_party/base/logging.h
index d24f93b..98ed9c5 100644
--- a/third_party/base/logging.h
+++ b/third_party/base/logging.h
@@ -5,6 +5,7 @@
 #ifndef PDFIUM_THIRD_PARTY_BASE_LOGGING_H_
 #define PDFIUM_THIRD_PARTY_BASE_LOGGING_H_
 
+#include <assert.h>
 #include <stdlib.h>
 
 #define CHECK(condition)                                                \
@@ -13,6 +14,6 @@
     *(reinterpret_cast<volatile char*>(NULL) + 42) = 0x42;              \
   }
 
-#define NOTREACHED() abort()
+#define NOTREACHED() assert(false)
 
 #endif  // PDFIUM_THIRD_PARTY_BASE_LOGGING_H_
diff --git a/third_party/bigint/BigIntegerUtils.cc b/third_party/bigint/BigIntegerUtils.cc
index 2629028..f48334d 100644
--- a/third_party/bigint/BigIntegerUtils.cc
+++ b/third_party/bigint/BigIntegerUtils.cc
@@ -43,6 +43,7 @@
 			os << '0';
 	} else
         abort();
+
 	std::string s = std::string(BigUnsignedInABase(x, base));
 	os << s;
 	return os;
diff --git a/third_party/third_party.gyp b/third_party/third_party.gyp
index 25e7050..639b9af 100644
--- a/third_party/third_party.gyp
+++ b/third_party/third_party.gyp
@@ -3,6 +3,9 @@
 # found in the LICENSE file.
 
 {
+  'variables': {
+    'pdf_enable_xfa%': 0,  # Set to 1 by standalone.gypi in standalone builds.
+  },
   'target_defaults': {
     'defines': [
       'OPJ_STATIC',
@@ -58,6 +61,7 @@
         'freetype/include/freetype/tttables.h',
         'freetype/include/ft2build.h',
         'freetype/src/base/ftbase.c',
+        'freetype/src/base/ftbase.h',
         'freetype/src/base/ftbitmap.c',
         'freetype/src/base/ftglyph.c',
         'freetype/src/base/ftinit.c',
@@ -77,6 +81,13 @@
         'freetype/src/truetype/truetype.c',
         'freetype/src/type1/type1.c',
       ],
+      'variables': {
+        'clang_warning_flags': [
+          # open_face_PS_from_sfnt_stream() and open_face_from_buffer() in
+          # ftbase.h are unused.
+          '-Wno-unused-function',
+        ],
+      },
     },
     {
       'target_name': 'fx_agg',
@@ -104,6 +115,12 @@
           'cflags': [ '-Wno-extra', ],
         }],
       ],
+      'variables': {
+        'clang_warning_flags': [
+          # calc_butt_cap() in agg_vcgen_stroke.cpp is unused.
+          '-Wno-unused-function',
+        ],
+      },
     },
     {
       'target_name': 'fx_lcms2',
@@ -149,6 +166,8 @@
       'variables': {
         'clang_warning_flags': [
           '-Wno-missing-braces',
+          # FindPrev() in cmsplugin.c is unused.
+          '-Wno-unused-function',
         ],
       },
     },
@@ -269,48 +288,6 @@
       ],
     },
     {
-      'target_name': 'fx_tiff',
-      'type': 'static_library',
-      'sources': [
-        'tiff_v403/tiffiop.h',
-        'tiff_v403/tif_aux.c',
-        'tiff_v403/tif_close.c',
-        'tiff_v403/tif_codec.c',
-        'tiff_v403/tif_color.c',
-        'tiff_v403/tif_compress.c',
-        'tiff_v403/tif_dir.c',
-        'tiff_v403/tif_dirinfo.c',
-        'tiff_v403/tif_dirread.c',
-        'tiff_v403/tif_dirwrite.c',
-        'tiff_v403/tif_dumpmode.c',
-        'tiff_v403/tif_error.c',
-        'tiff_v403/tif_extension.c',
-        'tiff_v403/tif_fax3.c',
-        'tiff_v403/tif_fax3sm.c',
-        'tiff_v403/tif_flush.c',
-        'tiff_v403/tif_getimage.c',
-        'tiff_v403/tif_jpeg.c',
-        'tiff_v403/tif_luv.c',
-        'tiff_v403/tif_lzw.c',
-        'tiff_v403/tif_next.c',
-        'tiff_v403/tif_ojpeg.c',
-        'tiff_v403/tif_open.c',
-        'tiff_v403/tif_packbits.c',
-        'tiff_v403/tif_pixarlog.c',
-        'tiff_v403/tif_predict.c',
-        'tiff_v403/tif_print.c',
-        'tiff_v403/tif_read.c',
-        'tiff_v403/tif_strip.c',
-        'tiff_v403/tif_swab.c',
-        'tiff_v403/tif_thunder.c',
-        'tiff_v403/tif_tile.c',
-        'tiff_v403/tif_version.c',
-        'tiff_v403/tif_warning.c',
-        'tiff_v403/tif_write.c',
-        'tiff_v403/tif_zip.c',
-      ],
-    },
-    {
       'target_name': 'fx_zlib',
       'type': 'static_library',
       'sources': [
@@ -347,4 +324,52 @@
       ],
     },
   ],
+  'conditions': [
+    ['pdf_enable_xfa==1', {
+      'targets': [
+        {
+          'target_name': 'fx_tiff',
+          'type': 'static_library',
+          'sources': [
+            'tiff_v403/tiffiop.h',
+            'tiff_v403/tif_aux.c',
+            'tiff_v403/tif_close.c',
+            'tiff_v403/tif_codec.c',
+            'tiff_v403/tif_color.c',
+            'tiff_v403/tif_compress.c',
+            'tiff_v403/tif_dir.c',
+            'tiff_v403/tif_dirinfo.c',
+            'tiff_v403/tif_dirread.c',
+            'tiff_v403/tif_dirwrite.c',
+            'tiff_v403/tif_dumpmode.c',
+            'tiff_v403/tif_error.c',
+            'tiff_v403/tif_extension.c',
+            'tiff_v403/tif_fax3.c',
+            'tiff_v403/tif_fax3sm.c',
+            'tiff_v403/tif_flush.c',
+            'tiff_v403/tif_getimage.c',
+            'tiff_v403/tif_jpeg.c',
+            'tiff_v403/tif_luv.c',
+            'tiff_v403/tif_lzw.c',
+            'tiff_v403/tif_next.c',
+            'tiff_v403/tif_ojpeg.c',
+            'tiff_v403/tif_open.c',
+            'tiff_v403/tif_packbits.c',
+            'tiff_v403/tif_pixarlog.c',
+            'tiff_v403/tif_predict.c',
+            'tiff_v403/tif_print.c',
+            'tiff_v403/tif_read.c',
+            'tiff_v403/tif_strip.c',
+            'tiff_v403/tif_swab.c',
+            'tiff_v403/tif_thunder.c',
+            'tiff_v403/tif_tile.c',
+            'tiff_v403/tif_version.c',
+            'tiff_v403/tif_warning.c',
+            'tiff_v403/tif_write.c',
+            'tiff_v403/tif_zip.c',
+          ],
+        },
+      ],
+    }],
+  ],
 }