Start inverting GN reading .gypis to GYP reading .gnis.

This canaries the idea by converting gyp/pdf.gypi to gn/pdf.gni.
If this lands and rolls quietly, I'll flesh out the rest.

BUG=skia:

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3972

Change-Id: Iecaf1ccce7891679904c585946272bfb25eea299
Reviewed-on: https://skia-review.googlesource.com/3972
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
diff --git a/gyp/pdf.gyp b/gyp/pdf.gyp
index be3ac4d..78209fb 100644
--- a/gyp/pdf.gyp
+++ b/gyp/pdf.gyp
@@ -23,9 +23,6 @@
         'skia_lib.gyp:skia_lib',
         'zlib.gyp:zlib',
       ],
-      'includes': [
-        'pdf.gypi',
-      ],
       'include_dirs': [
         '../include/private',
         '../src/core', # needed to get SkGlyphCache.h and SkTextFormatParams.h
@@ -33,7 +30,8 @@
         '../src/utils', # needed to get SkBitSet.h
       ],
       'sources': [
-        'pdf.gypi', # Makes the gypi appear in IDEs (but does not modify the build).
+        '../gn/pdf.gni', # Makes the .gni appear in IDEs.
+        '<!@(python read_gni.py ../gn/pdf.gni skia_pdf_sources)',
       ],
       'conditions': [
         [ 'skia_pdf_use_sfntly and not skia_android_framework and \
diff --git a/gyp/pdf.gypi b/gyp/pdf.gypi
deleted file mode 100644
index 7b15b33..0000000
--- a/gyp/pdf.gypi
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright 2015 Google Inc.
-#
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-# Include this gypi to include all 'pdf' files
-# The parent gyp/gypi file must define
-#       'skia_src_path'     e.g. skia/trunk/src
-#       'skia_include_path' e.g. skia/trunk/include
-#
-# The skia build defines these in common_variables.gypi
-#
-{
-    'sources': [
-        '<(skia_src_path)/pdf/SkBitmapKey.h',
-        '<(skia_src_path)/pdf/SkDeflate.cpp',
-        '<(skia_src_path)/pdf/SkDeflate.h',
-        '<(skia_src_path)/pdf/SkJpegInfo.cpp',
-        '<(skia_src_path)/pdf/SkJpegInfo.h',
-        '<(skia_src_path)/pdf/SkPDFBitmap.cpp',
-        '<(skia_src_path)/pdf/SkPDFBitmap.h',
-        '<(skia_src_path)/pdf/SkPDFCanon.cpp',
-        '<(skia_src_path)/pdf/SkPDFCanon.h',
-        '<(skia_src_path)/pdf/SkPDFCanvas.cpp',
-        '<(skia_src_path)/pdf/SkPDFCanvas.h',
-        '<(skia_src_path)/pdf/SkPDFConvertType1FontStream.cpp',
-        '<(skia_src_path)/pdf/SkPDFConvertType1FontStream.h',
-        '<(skia_src_path)/pdf/SkPDFDevice.cpp',
-        '<(skia_src_path)/pdf/SkPDFDevice.h',
-        '<(skia_src_path)/pdf/SkPDFDocument.cpp',
-        '<(skia_src_path)/pdf/SkPDFDocument.h',
-        '<(skia_src_path)/pdf/SkPDFFont.cpp',
-        '<(skia_src_path)/pdf/SkPDFFont.h',
-        '<(skia_src_path)/pdf/SkPDFFormXObject.cpp',
-        '<(skia_src_path)/pdf/SkPDFFormXObject.h',
-        '<(skia_src_path)/pdf/SkPDFGraphicState.cpp',
-        '<(skia_src_path)/pdf/SkPDFGraphicState.h',
-        '<(skia_src_path)/pdf/SkPDFMakeCIDGlyphWidthsArray.cpp',
-        '<(skia_src_path)/pdf/SkPDFMakeCIDGlyphWidthsArray.h',
-        '<(skia_src_path)/pdf/SkPDFMakeToUnicodeCmap.cpp',
-        '<(skia_src_path)/pdf/SkPDFMakeToUnicodeCmap.h',
-        '<(skia_src_path)/pdf/SkPDFMetadata.cpp',
-        '<(skia_src_path)/pdf/SkPDFMetadata.h',
-        '<(skia_src_path)/pdf/SkPDFResourceDict.cpp',
-        '<(skia_src_path)/pdf/SkPDFResourceDict.h',
-        '<(skia_src_path)/pdf/SkPDFShader.cpp',
-        '<(skia_src_path)/pdf/SkPDFShader.h',
-        '<(skia_src_path)/pdf/SkPDFTypes.cpp',
-        '<(skia_src_path)/pdf/SkPDFTypes.h',
-        '<(skia_src_path)/pdf/SkPDFUtils.cpp',
-        '<(skia_src_path)/pdf/SkPDFUtils.h',
-    ],
-}
diff --git a/gyp/read_gni.py b/gyp/read_gni.py
new file mode 100644
index 0000000..b8a7b39
--- /dev/null
+++ b/gyp/read_gni.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+#
+# Copyright 2016 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import sys
+
+# We'll read a single named list of paths from a .gni file.
+gni, name = sys.argv[1:]
+
+# The .gni files we want to read are close enough to Python syntax
+# that we can use execfile() if we supply definitions for GN builtins.
+
+def get_path_info(path, kind):
+  assert kind == "abspath"
+  # While we want absolute paths in GN, GYP prefers relative paths.
+  return path
+
+builtins = {
+  'get_path_info': get_path_info,
+}
+definitions = {}
+execfile(gni, builtins, definitions)
+
+# definitions now holds all the values defined in the .gni.
+paths = definitions[name]
+
+# Perform any string substitutions.
+for var in definitions:
+  if type(definitions[var]) is str:
+    paths = [ p.replace('$'+var, definitions[var]) for p in paths ]
+
+# Print the path list, to be received by <!@ syntax in GYP.
+for p in paths:
+  print p