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>
This commit is contained in:
Mike Klein 2016-10-26 13:32:07 -04:00
parent 62e7b5fd79
commit 552cd1335f
5 changed files with 88 additions and 65 deletions

47
gn/pdf.gni Normal file
View File

@ -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",
]

View File

@ -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") ],

View File

@ -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 \

View File

@ -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',
],
}

38
gyp/read_gni.py Normal file
View File

@ -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