refactor gyp to isolate freetype usage

R=bungeman@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@10229 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gyp/common_conditions.gypi b/gyp/common_conditions.gypi
index a39756b..1ff70f5 100644
--- a/gyp/common_conditions.gypi
+++ b/gyp/common_conditions.gypi
@@ -240,10 +240,6 @@
                 '-pthread',
               ],
             },
-          }, { # skia_os != "nacl"
-            'include_dirs' : [
-              '/usr/include/freetype2',
-            ],
           }],
           [ 'skia_os == "chromeos"', {
             'ldflags': [
diff --git a/gyp/core.gyp b/gyp/core.gyp
index bebcad6..28f5111 100644
--- a/gyp/core.gyp
+++ b/gyp/core.gyp
@@ -39,7 +39,6 @@
         [ 'skia_os == "mac"', {
           'include_dirs': [
             '../include/utils/mac',
-            '../third_party/freetype/include/**',
           ],
           'sources': [
             '../include/utils/mac/SkCGUtils.h',
@@ -110,7 +109,6 @@
           [ 'skia_os == "mac"', {
             'include_dirs': [
               '../include/utils/mac',
-              '../third_party/freetype/include/**',
             ],
           }],
           [ 'skia_os == "ios"', {
diff --git a/gyp/freetype.gyp b/gyp/freetype.gyp
index f72c29c..91fc0b3 100644
--- a/gyp/freetype.gyp
+++ b/gyp/freetype.gyp
@@ -2,6 +2,44 @@
   'targets': [
     {
       'target_name': 'freetype',
+      'type': 'none',
+      'conditions': [
+        [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "chromeos"]', {
+          'direct_dependent_settings': {
+            'include_dirs' : [
+              '/usr/include/freetype2',
+            ],
+            'link_settings': {
+              'libraries': [
+                '-lfreetype',
+              ],
+              'defines': [
+                #The font host requires at least FreeType 2.3.0 at runtime.
+                'SK_FONTHOST_FREETYPE_RUNTIME_VERSION=0x020300',\
+                'SK_CAN_USE_DLOPEN=1',
+              ],
+            }
+          },
+        }],
+        [ 'skia_os in ["android", "nacl"]', {
+          'dependencies': [
+            'freetype_static'
+          ],
+          'export_dependent_settings': [
+            'freetype_static'
+          ],
+          'direct_dependent_settings': {
+            'defines': [
+              # Both Android and NaCl provide at least FreeType 2.4.0
+              'SK_FONTHOST_FREETYPE_RUNTIME_VERSION=0x020400',
+              'SK_CAN_USE_DLOPEN=0',
+            ],
+          },
+        }],
+      ],
+    },
+    {
+      'target_name': 'freetype_static',
       'type': 'static_library',
       'standalone_static_library': 1,
       'sources': [
diff --git a/gyp/ports.gyp b/gyp/ports.gyp
index 0e57985..3fe8331 100644
--- a/gyp/ports.gyp
+++ b/gyp/ports.gyp
@@ -43,44 +43,30 @@
         '../src/ports/SkXMLParser_empty.cpp',
       ],
       'conditions': [
-        [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "chromeos"]', {
-          'defines': [
-            #The font host requires at least FreeType 2.3.0 at runtime.
-            'SK_FONTHOST_FREETYPE_RUNTIME_VERSION=0x020300',\
-            'SK_CAN_USE_DLOPEN=1',
+        [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "chromeos", "nacl", "android"]', {
+          'sources': [
+            '../src/ports/SkFontHost_FreeType.cpp',
+            '../src/ports/SkFontHost_FreeType_common.cpp',
           ],
+          'dependencies': [
+            'freetype.gyp:freetype',
+          ],
+        }],
+        [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "chromeos"]', {
           'link_settings': {
             'libraries': [
-              '-lfreetype',
               '-lfontconfig',
               '-ldl',
             ],
           },
           'sources': [
             '../src/fonts/SkFontMgr_fontconfig.cpp',
-            '../src/ports/SkFontHost_FreeType.cpp',
-            '../src/ports/SkFontHost_FreeType_common.cpp',
             '../src/ports/SkFontHost_fontconfig.cpp',
             '../src/ports/SkFontConfigInterface_direct.cpp',
           ],
         }],
         [ 'skia_os == "nacl"', {
-          'dependencies': [
-            # On other OS, we can dynamically link against freetype.  For nacl,
-            # we have to include our own version since the naclports version is
-            # too old (<0x020300) to provide the functionality we need.
-            'freetype.gyp:freetype',
-          ],
-          'export_dependent_settings': [
-            'freetype.gyp:freetype',
-          ],
-          'defines': [
-            # We use Android's repo, which provides at least FreeType 2.4.0
-            'SK_FONTHOST_FREETYPE_RUNTIME_VERSION=0x020400',\
-          ],
           'sources': [
-            '../src/ports/SkFontHost_FreeType.cpp',
-            '../src/ports/SkFontHost_FreeType_common.cpp',
             '../src/ports/SkFontHost_linux.cpp',
           ],
           'sources!': [
@@ -94,12 +80,9 @@
         [ 'skia_os == "mac"', {
           'include_dirs': [
             '../include/utils/mac',
-            '../third_party/freetype/include/**',
           ],
           'sources': [
             '../src/ports/SkFontHost_mac.cpp',
-#            '../src/ports/SkFontHost_FreeType.cpp',
-#            '../src/ports/SkFontHost_FreeType_common.cpp',
             '../src/ports/SkPurgeableMemoryBlock_mac.cpp',
             '../src/utils/mac/SkStream_mac.cpp',
           ],
@@ -158,12 +141,6 @@
           ],
         }],
         [ 'skia_os == "android"', {
-          'defines': [
-            #Android provides at least FreeType 2.4.0 at runtime.
-            'SK_FONTHOST_FREETYPE_RUNTIME_VERSION=0x020400',
-            #Skia should not use dlopen on Android.
-            'SK_CAN_USE_DLOPEN=0',
-          ],
           'sources!': [
             '../src/ports/SkDebug_stdio.cpp',
             '../src/ports/SkPurgeableMemoryBlock_none.cpp',
@@ -172,13 +149,10 @@
             '../src/ports/SkDebug_android.cpp',
             '../src/ports/SkFontConfigInterface_android.cpp',
             '../src/ports/SkFontConfigParser_android.cpp',
-            '../src/ports/SkFontHost_FreeType.cpp',
-            '../src/ports/SkFontHost_FreeType_common.cpp',
             '../src/ports/SkFontHost_fontconfig.cpp',
             '../src/ports/SkPurgeableMemoryBlock_android.cpp',
           ],
           'dependencies': [
-             'freetype.gyp:freetype',
              'android_deps.gyp:expat',
           ],
         }],
diff --git a/gyp/skia_lib.gyp b/gyp/skia_lib.gyp
index d4cd00e..6f8e9cf 100644
--- a/gyp/skia_lib.gyp
+++ b/gyp/skia_lib.gyp
@@ -27,11 +27,6 @@
           'gpu.gyp:skgpu',
         ],
       }],
-      [ 'skia_os == "nacl"', {
-        'component_libs': [
-          'freetype.gyp:freetype',
-        ],
-      }],
     ],
   },
   'targets': [