diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-01-09 22:54:26 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-01-09 22:54:26 +0000 |
commit | 83f56922e278d58a4c9172c6b45eff824368ce7d (patch) | |
tree | de95e1a1b1b130ba9a26a48093850a7ca18c57ed | |
parent | 6f0f5b4aad40fbdcbadcbbc32a38bd4c7d8998bc (diff) |
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
-rw-r--r-- | gyp/common_variables.gypi | 6 | ||||
-rw-r--r-- | gyp/fontconfig.gyp | 107 | ||||
-rw-r--r-- | gyp/gm.gyp | 2 | ||||
-rw-r--r-- | third_party/fontconfig/README.chromium | 11 | ||||
-rw-r--r-- | third_party/fontconfig/config/mac/config.h.template (renamed from third_party/fontconfig/config/mac/config.h) | 6 | ||||
-rwxr-xr-x | third_party/fontconfig/process-template.py | 51 |
6 files changed, 174 insertions, 9 deletions
diff --git a/gyp/common_variables.gypi b/gyp/common_variables.gypi index 74e596cf19..1c6111ac4a 100644 --- a/gyp/common_variables.gypi +++ b/gyp/common_variables.gypi @@ -57,6 +57,11 @@ }, { 'os_posix%': 1, }], + [ 'skia_os in ["linux", "win", "mac"]', { + 'skia_poppler_enabled%': 1, + }, { + 'skia_poppler_enabled%': 0, + }], [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', { 'skia_arch_width%': 64, }, { @@ -146,6 +151,7 @@ 'skia_resource_cache_mb_limit%': '<(skia_resource_cache_mb_limit)', 'skia_resource_cache_count_limit%': '<(skia_resource_cache_count_limit)', 'skia_angle%': '<(skia_angle)', + 'skia_poppler_enabled%': '<(skia_poppler_enabled)', 'skia_arch_width%': '<(skia_arch_width)', 'skia_arch_type%': '<(skia_arch_type)', 'skia_chrome_utils%': '<(skia_chrome_utils)', diff --git a/gyp/fontconfig.gyp b/gyp/fontconfig.gyp index 35f699faae..0a4a09899a 100644 --- a/gyp/fontconfig.gyp +++ b/gyp/fontconfig.gyp @@ -13,13 +13,31 @@ 'targets': [ { 'target_name': 'fontconfig', + 'type': 'none', + 'dependencies': [ + 'libfontconfig', + ], + 'direct_dependent_settings': { + 'include_dirs': [ + '../third_party/externals/fontconfig', + ], + }, + 'conditions': [ + ['skia_os == "mac"', { + 'dependencies': [ + 'fontconfig_setup', + ], + }], + ], + }, + { + 'target_name': 'libfontconfig', 'type': 'static_library', 'dependencies': [ 'freetype.gyp:freetype_poppler', ], 'include_dirs' : [ '../third_party/externals/fontconfig', - '../third_party/fontconfig/config', '../third_party/fontconfig/config/src', ], @@ -66,12 +84,12 @@ 'conditions': [ ['skia_os == "mac"', { 'include_dirs': [ + '<(SHARED_INTERMEDIATE_DIR)/fontconfig_config', '../third_party/fontconfig/config/mac', '../third_party/fontconfig/config/mac/src', ], - 'defines': [ - 'FC_CACHEDIR', - 'FONTCONFIG_PATH', + 'dependencies': [ + 'fontconfig_config_template', ], 'libraries': [ '$(SDKROOT)/usr/lib/libexpat.dylib', @@ -97,4 +115,85 @@ ], }, ], + 'conditions': [ + ['skia_os == "mac"', { + 'variables': { + 'cachedir': '<(PRODUCT_DIR)/fontconfig/cache', + 'configdir': '<(PRODUCT_DIR)/fontconfig/etc', + }, + 'targets': [ + { + 'target_name': 'fontconfig_config_template', + 'type': 'none', + 'actions': [{ + 'action_name': 'fontconfig_config_template', + 'message': 'Generating fontconfig header', + 'inputs': [ + '../third_party/fontconfig/process-template.py', + '../third_party/fontconfig/config/mac/config.h.template', + ], + 'outputs': [ + '<(SHARED_INTERMEDIATE_DIR)/fontconfig_config/config.h', + ], + 'action': [ + 'python', '../third_party/fontconfig/process-template.py', + '-i', '../third_party/fontconfig/config/mac/config.h.template', + '-o', '<@(_outputs)', + '-p', '@FC_CACHEDIR@', '<(cachedir)', + '-p', '@FONTCONFIG_PATH@', '<(configdir)', + ], + }], + }, { + 'target_name': 'fontconfig_setup', + 'type': 'none', + 'dependencies': [ + 'fc-cache', + ], + 'actions': [{ + 'action_name': 'fontconfig_config_file', + 'message': 'Generating font.conf', + 'inputs': [ + '../third_party/fontconfig/process-template.py', + '../third_party/externals/fontconfig/fonts.conf.in', + ], + 'outputs': [ '<(configdir)/fonts.conf', ], + 'action': [ + 'python', '../third_party/fontconfig/process-template.py', + '-i', '../third_party/externals/fontconfig/fonts.conf.in', + '-o', '<(configdir)/fonts.conf', + '-p', '@FC_CACHEDIR@', '<(cachedir)', + '-k', '@FC_DEFAULT_FONTS@', '/System/Library/Fonts', + '-k', '@FC_FONTPATH@', '<dir>/Library/Fonts</dir>', + '-p', '@CONFIGDIR@', '<(configdir)/conf.d', + '-k', '@PACKAGE@', 'fontconfig', + '-k', '@VERSION@', '2.10.93', + ], + }, { + 'action_name': 'populate_fontconfig_cache', + 'message': + 'Generating fontconfig cache (this will take a few minutes).', + 'inputs': [ + '<(PRODUCT_DIR)/fc-cache', + '<(configdir)/fonts.conf', + ], + 'outputs': [ '<(cachedir)/CACHEDIR.TAG', ], + 'action': [ '<(PRODUCT_DIR)/fc-cache', '-s', '-f', '-v', ], + }], + }, + { + 'target_name': 'fc-cache', + 'type': 'executable', + 'dependencies': [ + 'libfontconfig', + ], + 'libraries':[ + '$(SDKROOT)/usr/lib/libexpat.dylib', + ], + 'sources': [ + '../third_party/externals/fontconfig/fc-cache/fc-cache.c', + ], + }, + ], + }], + ], } diff --git a/gyp/gm.gyp b/gyp/gm.gyp index a543aca4db..657bc560ea 100644 --- a/gyp/gm.gyp +++ b/gyp/gm.gyp @@ -73,7 +73,7 @@ 'pdfviewer_lib.gyp:pdfviewer_lib', ], }], - ['skia_os in ["linux", "mac", "win"]', { + ['skia_poppler_enabled', { 'dependencies': [ 'poppler.gyp:libpoppler-cpp-gpl', ], diff --git a/third_party/fontconfig/README.chromium b/third_party/fontconfig/README.chromium index f9ea5b62b3..07bc5f59f8 100644 --- a/third_party/fontconfig/README.chromium +++ b/third_party/fontconfig/README.chromium @@ -33,9 +33,14 @@ third_party/fontconfig/config: fc-lang/fclang.h src/fcobjshash.h -On Linux and Mac, these are the files generated by ./configure, with no -additional flags. +On Mac, these are the files generated by + ./configure --with-add-fonts=/System/Library/Fonts,/Library/Fonts +config/mac/config.h.template then has a section added to the top: + ++/* Manually added template defines */ ++#define FC_CACHEDIR "@FC_CACHEDIR@" ++#define FONTCONFIG_PATH "@FONTCONFIG_PATH@" + On Windows, the configuration files were from http://comments.gmane.org/gmane.comp.fonts.fontconfig/4438 (fontconfig development list). - diff --git a/third_party/fontconfig/config/mac/config.h b/third_party/fontconfig/config/mac/config.h.template index 963ede8494..3eea946a19 100644 --- a/third_party/fontconfig/config/mac/config.h +++ b/third_party/fontconfig/config/mac/config.h.template @@ -1,6 +1,10 @@ /* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ +/* Manually added template defines */ +#define FC_CACHEDIR "@FC_CACHEDIR@" +#define FONTCONFIG_PATH "@FONTCONFIG_PATH@" + /* Define if building universal (internal helper macro) */ /* #undef AC_APPLE_UNIVERSAL_BUILD */ @@ -11,7 +15,7 @@ /* #undef ENABLE_LIBXML2 */ /* Additional font directories */ -#define FC_ADD_FONTS "yes" +#define FC_ADD_FONTS "/System/Library/Fonts,/Library/Fonts" /* Architecture prefix to use for cache file names */ /* #undef FC_ARCHITECTURE */ diff --git a/third_party/fontconfig/process-template.py b/third_party/fontconfig/process-template.py new file mode 100755 index 0000000000..6c91402701 --- /dev/null +++ b/third_party/fontconfig/process-template.py @@ -0,0 +1,51 @@ +#!/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() |