diff options
author | Mike Klein <mtklein@chromium.org> | 2016-10-26 13:32:07 -0400 |
---|---|---|
committer | Mike Klein <mtklein@chromium.org> | 2016-10-26 17:47:00 +0000 |
commit | 552cd1335fb4f4cd87aa418cc99f484d186ba046 (patch) | |
tree | 979464faefc2f842fd494ef4a4d30cc2a585b778 | |
parent | 62e7b5fd79d3d61e9821ecd6123a3588d94893cc (diff) |
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>
-rw-r--r-- | gn/pdf.gni | 47 | ||||
-rw-r--r-- | gn/shared_sources.gni | 10 | ||||
-rw-r--r-- | gyp/pdf.gyp | 6 | ||||
-rw-r--r-- | gyp/pdf.gypi | 52 | ||||
-rw-r--r-- | gyp/read_gni.py | 38 |
5 files changed, 88 insertions, 65 deletions
diff --git a/gn/pdf.gni b/gn/pdf.gni new file mode 100644 index 0000000000..f7de23d613 --- /dev/null +++ b/gn/pdf.gni @@ -0,0 +1,47 @@ +# Copyright 2016 Google Inc. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Things are easiest for everyone if these source paths are absolute. +_src = get_path_info("../src", "abspath") + +skia_pdf_sources = [ + "$_src/pdf/SkBitmapKey.h", + "$_src/pdf/SkDeflate.cpp", + "$_src/pdf/SkDeflate.h", + "$_src/pdf/SkJpegInfo.cpp", + "$_src/pdf/SkJpegInfo.h", + "$_src/pdf/SkPDFBitmap.cpp", + "$_src/pdf/SkPDFBitmap.h", + "$_src/pdf/SkPDFCanon.cpp", + "$_src/pdf/SkPDFCanon.h", + "$_src/pdf/SkPDFCanvas.cpp", + "$_src/pdf/SkPDFCanvas.h", + "$_src/pdf/SkPDFConvertType1FontStream.cpp", + "$_src/pdf/SkPDFConvertType1FontStream.h", + "$_src/pdf/SkPDFDevice.cpp", + "$_src/pdf/SkPDFDevice.h", + "$_src/pdf/SkPDFDocument.cpp", + "$_src/pdf/SkPDFDocument.h", + "$_src/pdf/SkPDFFont.cpp", + "$_src/pdf/SkPDFFont.h", + "$_src/pdf/SkPDFFormXObject.cpp", + "$_src/pdf/SkPDFFormXObject.h", + "$_src/pdf/SkPDFGraphicState.cpp", + "$_src/pdf/SkPDFGraphicState.h", + "$_src/pdf/SkPDFMakeCIDGlyphWidthsArray.cpp", + "$_src/pdf/SkPDFMakeCIDGlyphWidthsArray.h", + "$_src/pdf/SkPDFMakeToUnicodeCmap.cpp", + "$_src/pdf/SkPDFMakeToUnicodeCmap.h", + "$_src/pdf/SkPDFMetadata.cpp", + "$_src/pdf/SkPDFMetadata.h", + "$_src/pdf/SkPDFResourceDict.cpp", + "$_src/pdf/SkPDFResourceDict.h", + "$_src/pdf/SkPDFShader.cpp", + "$_src/pdf/SkPDFShader.h", + "$_src/pdf/SkPDFTypes.cpp", + "$_src/pdf/SkPDFTypes.h", + "$_src/pdf/SkPDFUtils.cpp", + "$_src/pdf/SkPDFUtils.h", +] diff --git a/gn/shared_sources.gni b/gn/shared_sources.gni index 2da3d2cb79..1f1184e6df 100644 --- a/gn/shared_sources.gni +++ b/gn/shared_sources.gni @@ -60,15 +60,7 @@ skia_opts = exec_script("gypi_to_gn.py", [ "../gyp/opts.gypi" ]) # PDF. -_pdf_gypi = exec_script("gypi_to_gn.py", - [ - rebase_path("../gyp/pdf.gypi"), - "--replace=<(skia_include_path)=$_path_to_include", - "--replace=<(skia_src_path)=$_path_to_src", - ], - "scope", - [ "../gyp/pdf.gypi" ]) -skia_pdf_sources = _pdf_gypi.sources +import("pdf.gni") _sources_gypi = exec_script("gypi_to_gn.py", [ rebase_path("../gyp/skia_sources.gypi") ], diff --git a/gyp/pdf.gyp b/gyp/pdf.gyp index be3ac4d12a..78209fb1b6 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 7b15b33885..0000000000 --- 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 0000000000..b8a7b39de8 --- /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 |