Reland "Gyp file changes for the android framework."
authorscroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 5 Feb 2014 16:35:12 +0000 (16:35 +0000)
committerscroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 5 Feb 2014 16:35:12 +0000 (16:35 +0000)
Relands https://codereview.chromium.org/153093003/, which was reverted
with https://skia.googlesource.com/skia.git/+/eb6295044b97db05ec40625dcebc2459b2a38a98

This reverts commit 6b32be1402eb6c549d5ba1db71860e24f9de2991.

BUG=skia:1975
R=djsollen@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@13321 2bbb7eff-a529-9590-31e7-b0007b416f81

12 files changed:
gyp/android_deps.gyp
gyp/android_framework_lib.gyp [new file with mode: 0644]
gyp/common.gypi
gyp/common_conditions.gypi
gyp/common_variables.gypi
gyp/core.gyp
gyp/freetype.gyp
gyp/images.gyp
gyp/libwebp.gyp
gyp/opts.gyp
gyp/pdf.gyp
gyp/zlib.gyp

index cd5b1b0..1669b2b 100644 (file)
 # This is due to the fact that we cannot use variables in an includes as the
 # variable expansion step for gyp happens after the includes are processed.
 {
-  'includes': [
-    '../platform_tools/android/gyp/dependencies.gypi',
+  'conditions': [
+    [ 'skia_android_framework == 0',
+      {
+        'includes': [
+          '../platform_tools/android/gyp/dependencies.gypi',
+        ],
+      }, { # else skia_android_framework
+        'cflags': [
+          '-Wno-error'
+        ],
+        'targets': [
+          {
+            'target_name': 'expat',
+            'type': 'none',
+            'direct_dependent_settings': {
+              'libraries' : [
+                '-lexpat',
+              ],
+            },
+          },
+          {
+            'target_name': 'gif',
+            'type': 'none',
+            'direct_dependent_settings': {
+              'libraries' : [
+                'libgif.a',
+              ],
+              'include_dirs': [
+                'external/giflib',
+              ],
+            },
+          },
+          {
+            'target_name': 'png',
+            'type': 'none',
+            'direct_dependent_settings': {
+              'libraries' : [
+                '-lpng',
+              ],
+              'include_dirs': [
+                'external/libpng',
+              ],
+            },
+          },
+          {
+            'target_name': 'jpeg',
+            'type': 'none',
+            'direct_dependent_settings': {
+              'libraries' : [
+                '-ljpeg',
+              ],
+              'include_dirs': [
+                'external/jpeg',
+              ],
+            },
+          },
+          {
+            'target_name': 'cpu_features',
+            'type': 'none',
+          },
+        ],
+      }
+    ],
   ],
 }
diff --git a/gyp/android_framework_lib.gyp b/gyp/android_framework_lib.gyp
new file mode 100644 (file)
index 0000000..2b05598
--- /dev/null
@@ -0,0 +1,20 @@
+# Copyright 2014 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+{
+  'targets': [
+    {
+      'target_name': 'libskia',
+      'type': 'shared_library',
+      'dependencies': [
+        'core.gyp:core',
+        'effects.gyp:effects',
+        'images.gyp:images',
+        'opts.gyp:opts',
+        'pdf.gyp:pdf',
+        'ports.gyp:ports',
+      ],
+    },
+  ],
+}
index 48b9a6d..2a5bbd4 100644 (file)
           ],
         },
       ],
+      [ 'skia_android_framework==0', {
+        # These defines are not used for skia_android_framework, where we build
+        # one makefile and allow someone to add SK_DEBUG etc for their own
+        # debugging purposes.
+        'configurations': {
+          'Debug': {
+            'defines': [
+              'SK_DEBUG',
+              'SK_DEVELOPER=1',
+            ],
+          },
+          'Release': {
+            'defines': [
+              'SK_RELEASE',
+            ],
+          },
+          'Release_Developer': {
+            'inherit_from': ['Release'],
+            'defines': [
+              'SK_DEVELOPER=1',
+            ],
+          },
+        },
+      }],
     ],
-    'configurations': {
-      'Debug': {
-        'defines': [
-          'SK_DEBUG',
-          'SK_DEVELOPER=1',
-        ],
-      },
-      'Release': {
-        'defines': [
-          'SK_RELEASE',
-        ],
-      },
-      'Release_Developer': {
-        'inherit_from': ['Release'],
-        'defines': [
-          'SK_DEVELOPER=1',
-        ],
-      },
-    },
   }, # end 'target_defaults'
 }
index 4db0a40..bbf3097 100644 (file)
       },
     ],
 
+    ['skia_android_framework', {
+      'cflags': [
+        # Skia does not enforce this usage pattern so we disable it here to avoid
+        # unecessary log spew when building
+        '-Wno-unused-parameter',
+
+        # Android's -D_FORTIFY_SOURCE=2 extensions are incompatibile with SkString.
+        # Revert to -D_FORTIFY_SOURCE=1
+        '-U_FORTIFY_SOURCE',
+        '-D_FORTIFY_SOURCE=1',
+      ],
+      'defines': [
+        'DCT_IFAST_SUPPORTED',
+        # using freetype's embolden allows us to adjust fake bold settings at
+        # draw-time, at which point we know which SkTypeface is being drawn
+        'SK_USE_FREETYPE_EMBOLDEN',
+        # 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',
+      ],
+    }],
 
     [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "nacl", "chromeos"]',
       {
           '-fuse-ld=gold',
         ],
         'conditions': [
+          [ 'skia_android_framework', {
+            'libraries!': [
+              '-lstdc++',
+              '-lm',
+            ],
+          }],
           [ 'skia_shared_lib', {
             'cflags': [
               '-fPIC',
index c06666d..26b9961 100644 (file)
         # We set it automatically based on 'OS' (the host OS), but allow the
         # user to override it via GYP_DEFINES if they like.
         'skia_os%': '<(OS)',
+
+        'skia_android_framework%': 0,
       },
 
       # Re-define all variables defined within the level-3 'variables' dict,
       # so that siblings of the level-2 'variables' dict can see them.
-      'skia_os%': '<(skia_os)',
+      # (skia_os will depend on skia_android_framework.)
+      'skia_android_framework%': '<(skia_android_framework)',
 
       'conditions': [
+        [ 'skia_android_framework == 1', {
+          'skia_os%': 'android',
+        }, {
+          'skia_os%': '<(skia_os)',
+        }],
         [ 'skia_os == "win"', {
           'os_posix%': 0,
         }, {
 
     'conditions': [
       [ 'skia_os == "win" and skia_arch_width == 32 or '
-        'skia_os in ["linux", "freebsd", "openbsd", "solaris", "android"] or '
+        'skia_os in ["linux", "freebsd", "openbsd", "solaris", "android"] '
+            'and skia_android_framework == 0 or '
         'skia_os == "mac" and skia_arch_width == 32', {
         'skia_warnings_as_errors%': 1,
       }, {
     'skia_scalar%': '<(skia_scalar)',
     'skia_mesa%': '<(skia_mesa)',
     'skia_stroke_path_rendering%': '<(skia_stroke_path_rendering)',
+    'skia_android_framework%': '<(skia_android_framework)',
     'skia_android_path_rendering%': '<(skia_android_path_rendering)',
     'skia_resource_cache_mb_limit%': '<(skia_resource_cache_mb_limit)',
     'skia_resource_cache_count_limit%': '<(skia_resource_cache_count_limit)',
index 8c5270e..187c02b 100644 (file)
             'android_deps.gyp:cpu_features',
           ],
         }],
+        [ 'skia_android_framework', {
+            'libraries': [
+              # Required for SkAtomics_android.h
+              '-lcutils',
+            ],
+        }],
         [ 'skia_arch_type == "arm"', {
           # The code in SkUtilsArm.cpp can be used on an ARM-based Linux system, not only Android.
           'sources': [
index b0957d0..6717c78 100644 (file)
             ],
           },
         }],
+        [ 'skia_android_framework', {
+            'include_dirs': [
+              'external/expat/lib',
+              'external/freetype/include',
+            ],
+            'libraries': [
+              '-lft2',
+            ],
+            # Remove these, and use the system's freetype instead.
+            'dependencies!': [
+              'freetype_static',
+            ],
+            'export_dependent_settings!': [
+              'freetype_static',
+            ]
+        }],
       ],
     },
     {
index dedea51..fdbf2a0 100644 (file)
         'libwebp.gyp:libwebp',
         'utils.gyp:utils',
       ],
-      'export_dependent_settings': [
-        'libjpeg.gyp:*',
+      'conditions': [
+        [ 'skia_android_framework == 0', {
+          'export_dependent_settings': [
+            'libjpeg.gyp:*',
+          ],
+        }],
       ],
       'include_dirs': [
         '../include/images',
         '../src/images/SkImageDecoder.cpp',
         '../src/images/SkImageDecoder_FactoryDefault.cpp',
         '../src/images/SkImageDecoder_FactoryRegistrar.cpp',
+
         # If decoders are added/removed to/from (all/individual)
         # platform(s), be sure to update SkForceLinking.cpp
         # so the right decoders will be forced to link.
+
+        # IMPORTANT: The build order of the SkImageDecoder_*.cpp files
+        # defines the order image decoders are tested when decoding a
+        # stream. The last decoder is the first one tested, so the .cpp
+        # files should be in listed in order from the least likely to be
+        # used, to the most likely (jpeg and png should be the last two
+        # for instance.) As a result, they are deliberately not in
+        # alphabetical order.
+        '../src/images/SkImageDecoder_wbmp.cpp',
         '../src/images/SkImageDecoder_libbmp.cpp',
         '../src/images/SkImageDecoder_libgif.cpp',
         '../src/images/SkImageDecoder_libico.cpp',
+        '../src/images/SkImageDecoder_libwebp.cpp',
         '../src/images/SkImageDecoder_libjpeg.cpp',
         '../src/images/SkImageDecoder_libpng.cpp',
-        '../src/images/SkImageDecoder_libwebp.cpp',
-        '../src/images/SkImageDecoder_wbmp.cpp',
+
         '../src/images/SkImageEncoder.cpp',
         '../src/images/SkImageEncoder_Factory.cpp',
         '../src/images/SkImageEncoder_argb.cpp',
              'android_deps.gyp:gif',
              'android_deps.gyp:png',
           ],
-          'export_dependent_settings': [
-            'android_deps.gyp:png'
+          'conditions': [
+            [ 'skia_android_framework == 0', {
+              'export_dependent_settings': [
+                'android_deps.gyp:png'
+              ],
+            }],
           ],
         },{ #else if skia_os != android
           'sources!': [
index 1f8689a..cacfab6 100644 (file)
@@ -4,7 +4,13 @@
 
 {
   'variables': {
-    'use_system_libwebp%': 0,
+    'conditions':[
+      ['skia_android_framework == 1', {
+        'use_system_libwebp': 1,
+      }, {
+        'use_system_libwebp%': 0,
+      }],
+    ],
   },
   'conditions': [
     ['use_system_libwebp==0', {
         },
       ],
     }, {
+      # use_system_libwep == 1
       'targets': [
         {
           'target_name': 'libwebp',
           'type': 'none',
-          'direct_dependent_settings': {
-            'defines': [
-              'ENABLE_WEBP',
-            ],
-          },
-          'link_settings': {
-            'libraries': [
-              '-lwebp',
+          'conditions': [
+            [ 'skia_android_framework', {
+              'direct_dependent_settings': {
+                'libraries': [
+                  'libwebp-decode.a',
+                  'libwebp-encode.a',
+                ],
+              'include_dirs': [
+                'external/webp/include',
+              ],
+              },
+            }, { # skia_android_framework == 0
+              'direct_dependent_settings': {
+                'defines': [
+                  'ENABLE_WEBP',
+                ],
+                },
+                'link_settings': {
+                  'libraries': [
+                    '-lwebp',
+                  ],
+                },
+              },
             ],
-          },
+          ],
         }
       ],
     }],
index 83dfe14..9fe4023 100644 (file)
@@ -1,3 +1,4 @@
+# Gyp file for opts projects
 {
   'targets': [
     # Due to an unfortunate intersection of lameness between gcc and gyp,
@@ -98,7 +99,9 @@
             }],
           ],
         }],
-        [ '(skia_arch_type == "mips") or (skia_arch_type == "arm" and arm_version < 7) or (skia_os == "ios")', {
+        [ '(skia_arch_type == "mips") or (skia_arch_type == "arm" and arm_version < 7) \
+            or (skia_os == "ios") \
+            or (skia_os == "android" and skia_arch_type not in ["x86", "arm", "mips"])', {
           'sources': [
             '../src/opts/SkBitmapProcState_opts_none.cpp',
             '../src/opts/SkBlitMask_opts_none.cpp',
index 8281732..145dc5b 100644 (file)
@@ -1,3 +1,4 @@
+# This file builds the PDF backend.
 {
   'targets': [
     {
 
         '../src/doc/SkDocument_PDF.cpp', # Chromium does use this file
       ],
+      'conditions': [
+        [ 'skia_android_framework', {
+            # Add SFTNLY support for PDF (which in turns depends on ICU)
+            'include_dirs': [
+              'external/sfntly/cpp/src',
+            ],
+            'libraries': [
+              'libsfntly.a',
+              '-licuuc',
+              '-licui18n',
+            ],
+          }
+        ],
+      ],
       # This section makes all targets that depend on this target
       # #define SK_SUPPORT_PDF and have access to the pdf header files.
       'direct_dependent_settings': {
index eaa44c5..b26053e 100644 (file)
@@ -1,3 +1,4 @@
+# Target for including zlib.
 {
   'targets': [
     {
         }],
         [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "android", "nacl"]', {
           'link_settings': { 'libraries': [ '-lz', ], },
-          'defines': [ 'SK_ZLIB_INCLUDE=<zlib.h>', ],
+          'conditions': [
+            [ 'skia_android_framework==0', {
+              'defines': [ 'SK_ZLIB_INCLUDE=<zlib.h>', ],
+            }],
+          ],
+        }],
+        [ 'skia_android_framework', {
+          'include_dirs': [
+            'external/zlib',
+          ],
         }],
       ],
     },