skia2/third_party/fontconfig/process-template.py
commit-bot@chromium.org 83f56922e2 Fix Mac fontconfig build (try 2)
The Mac fontconfig just #defines the cache directory, which works fine if fontconfig never has to look up any fonts (the case until now). If it has to actually find fonts from the disk, the cache directory and config directory need to be properly defined as well as running fc-cache to populate the cache directory.

Populating the cache directory can take some time, but should only happen on a clean build. To remove this extra time, we have to not build poppler on Mac, which can now be accomplished with GYP_DEFINES="skia_mac_poppler=0"

R=epoger@google.com

Author: vandebo@chromium.org

Review URL: https://codereview.chromium.org/132333002

git-svn-id: http://skia.googlecode.com/svn/trunk@13007 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-01-09 22:54:26 +00:00

52 lines
1.2 KiB
Python
Executable File

#!/usr/bin/python
# Copyright 2014 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# A simple template processing script.
import optparse
import os
import sys
parser = optparse.OptionParser()
parser.add_option('-i', '--input')
parser.add_option('-o', '--output')
parser.add_option(
'-k', '--keyword_substitution', action='append', nargs=2,
metavar=('KEY', 'VALUE'), help='Changes KEY to VALUE in the template.')
parser.add_option(
'-p', '--path_substitution', action='append', nargs=2,
metavar=('KEY', 'PATH'),
help='Makes PATH absolute then changes KEY to PATH in the template.')
(args, _) = parser.parse_args()
input = sys.stdin
if args.input:
input = open(args.input, 'r')
output = sys.stdout
if args.output:
output = open(args.output, 'w')
path_subs = None
if args.path_substitution:
path_subs = [
[sub[0], os.path.abspath(sub[1])] for sub in args.path_substitution
]
for line in input:
if args.keyword_substitution:
for (key, value) in args.keyword_substitution:
line = line.replace(key, value)
if path_subs:
for (key, path) in path_subs:
line = line.replace(key, path)
output.write(line)
input.close()
output.close()