skia2/gyp/read_gni.py
Mike Klein 552cd1335f 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>
2016-10-26 17:47:00 +00:00

39 lines
988 B
Python

#!/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