From 58629291bc145edca8fb303e465c8537bed65314 Mon Sep 17 00:00:00 2001 From: "djsollen@google.com" Date: Thu, 3 Nov 2011 13:08:29 +0000 Subject: Adding support to trunk for building Skia using the Android NDK. This CL depends on a subsequent CL to add the appropriate NDK toolchain and system sources to the skia repo. Review URL: http://codereview.appspot.com/5306089/ Review URL: http://codereview.appspot.com/5306089 git-svn-id: http://skia.googlecode.com/svn/trunk@2592 2bbb7eff-a529-9590-31e7-b0007b416f81 --- gyp/SampleApp.gyp | 17 ++++- gyp/android_system.gyp | 152 +++++++++++++++++++++++++++++++++++++++++++++ gyp/bench.gypi | 5 +- gyp/common_conditions.gypi | 44 +++++++++++++ gyp/core.gyp | 18 ++++++ gyp/gpu.gyp | 17 +++++ gyp/images.gyp | 11 +++- gyp/opts.gyp | 34 ++++++++-- gyp/xml.gyp | 2 +- 9 files changed, 290 insertions(+), 10 deletions(-) create mode 100644 gyp/android_system.gyp (limited to 'gyp') diff --git a/gyp/SampleApp.gyp b/gyp/SampleApp.gyp index ba650968cb..1855fe7a32 100644 --- a/gyp/SampleApp.gyp +++ b/gyp/SampleApp.gyp @@ -247,7 +247,22 @@ '../experimental/iOSSampleApp/iPhone/MainWindow_iPhone.xib', ], }], - + [ 'skia_os == "android"', { + # TODO: This doesn't build properly yet, but it's getting there. + 'type': 'shared_library', + 'sources!': [ + '../samplecode/SampleAnimator.cpp', + '../samplecode/SampleUnitMapper.cpp', + ], + 'dependencies!': [ + 'animator.gyp:animator', + 'experimental.gyp:experimental', + ], + 'sources': [ + # TODO add support for the android sample app +# '../samplecode/SampleApp_android.cpp', + ], + }], ], 'msvs_settings': { 'VCLinkerTool': { diff --git a/gyp/android_system.gyp b/gyp/android_system.gyp new file mode 100644 index 0000000000..6818f699a9 --- /dev/null +++ b/gyp/android_system.gyp @@ -0,0 +1,152 @@ +# This GYP file stores the dependencies necessary to build Skia on the Android +# platform. The OS doesn't provide many stable libraries as part of the +# distribution so we have to build a few of them ourselves. +# +# NOTE: We tried adding the gyp file to the android/ directory at the root of +# the Skia repo, but that resulted in the generated makefiles being created +# outside of the out directory. We may be able to move the bulk of this gyp +# to the /android directory and put a simple shim here, but that has yet to be +# tested. + +{ + # Define the location of the required Android sources, allowing for override + # in GYP_DEFINES. + # + # These sources are necessary because they must be built using the Android + # toolchain and they are not expected to be present on the host OS. + # + 'variables': { + 'android_repo%': '../../android_tools', + }, + 'android_repo%': '<(android_repo)', + + 'includes': [ + 'common.gypi', + ], + + 'targets': [ + { + 'target_name': 'ft2', + 'type': 'static_library', + 'sources': [ + '<(android_repo)/external/freetype/src/base/ftbbox.c', + '<(android_repo)/external/freetype/src/base/ftbitmap.c', + '<(android_repo)/external/freetype/src/base/ftglyph.c', + '<(android_repo)/external/freetype/src/base/ftlcdfil.c', + '<(android_repo)/external/freetype/src/base/ftstroke.c', + '<(android_repo)/external/freetype/src/base/ftxf86.c', + '<(android_repo)/external/freetype/src/base/ftbase.c', + '<(android_repo)/external/freetype/src/base/ftsystem.c', + '<(android_repo)/external/freetype/src/base/ftinit.c', + '<(android_repo)/external/freetype/src/base/ftgasp.c', + '<(android_repo)/external/freetype/src/base/ftfstype.c', + '<(android_repo)/external/freetype/src/raster/raster.c', + '<(android_repo)/external/freetype/src/sfnt/sfnt.c', + '<(android_repo)/external/freetype/src/smooth/smooth.c', + '<(android_repo)/external/freetype/src/autofit/autofit.c', + '<(android_repo)/external/freetype/src/truetype/truetype.c', + '<(android_repo)/external/freetype/src/cff/cff.c', + '<(android_repo)/external/freetype/src/psnames/psnames.c', + '<(android_repo)/external/freetype/src/pshinter/pshinter.c', + ], + 'include_dirs': [ + '<(android_repo)/external/freetype/builds', + '<(android_repo)/external/freetype/include', + ], + 'cflags': [ + '-W', + '-Wall', + '-fPIC', + '-DPIC', + '-DDARWIN_NO_CARBON', + '-DFT2_BUILD_LIBRARY', + '-O2', + ], + 'direct_dependent_settings': { + 'include_dirs': [ + '<(android_repo)/external/freetype/include', # For ft2build.h + ], + } + }, + { + 'target_name': 'expat', + 'type': 'static_library', + 'sources': [ + '<(android_repo)/external/expat/lib/xmlparse.c', + '<(android_repo)/external/expat/lib/xmlrole.c', + '<(android_repo)/external/expat/lib/xmltok.c', + ], + 'include_dirs': [ + '<(android_repo)/external/expat', + '<(android_repo)/external/expat/lib', + ], + 'cflags': [ + '-Wall', + '-Wmissing-prototypes', + '-Wstrict-prototypes', + '-fexceptions', + '-DHAVE_EXPAT_CONFIG_H', + ], + 'direct_dependent_settings': { + 'include_dirs': [ + '<(android_repo)/external/expat/lib', # For expat.h + ], + } + }, + { + 'target_name': 'gif', + 'type': 'static_library', + 'sources': [ + '<(android_repo)/external/gif/dgif_lib.c', + '<(android_repo)/external/gif/gifalloc.c', + '<(android_repo)/external/gif/gif_err.c', + ], + 'include_dirs': [ + '<(android_repo)/external/gif', + ], + 'cflags': [ + '-Wno-format', + '-DHAVE_CONFIG_H', + ], + 'direct_dependent_settings': { + 'include_dirs': [ + '<(android_repo)/external/gif', + ], + } + }, + { + 'target_name': 'png', + 'type': 'static_library', + 'sources': [ + '<(android_repo)/external/png/png.c', + '<(android_repo)/external/png/pngerror.c', + '<(android_repo)/external/png/pnggccrd.c', + '<(android_repo)/external/png/pngget.c', + '<(android_repo)/external/png/pngmem.c', + '<(android_repo)/external/png/pngpread.c', + '<(android_repo)/external/png/pngread.c', + '<(android_repo)/external/png/pngrio.c', + '<(android_repo)/external/png/pngrtran.c', + '<(android_repo)/external/png/pngrutil.c', + '<(android_repo)/external/png/pngset.c', + '<(android_repo)/external/png/pngtrans.c', + '<(android_repo)/external/png/pngvcrd.c', + '<(android_repo)/external/png/pngwio.c', + '<(android_repo)/external/png/pngwrite.c', + '<(android_repo)/external/png/pngwtran.c', + '<(android_repo)/external/png/pngwutil.c', + ], + 'include_dirs': [ + '<(android_repo)/external/png', + ], + 'cflags': [ + '-fvisibility=hidden', + ], + 'direct_dependent_settings': { + 'include_dirs': [ + '<(android_repo)/external/png', + ], + } + }, + ] +} \ No newline at end of file diff --git a/gyp/bench.gypi b/gyp/bench.gypi index e993790c4d..6ac64d1dbe 100644 --- a/gyp/bench.gypi +++ b/gyp/bench.gypi @@ -40,12 +40,13 @@ '../bench/BenchSysTimer_mach.cpp', ], }], - [ 'skia_os not in ["linux", "freebsd", "openbsd", "solaris"]', { + [ 'skia_os not in ["linux", "freebsd", "openbsd", "solaris", "android"]', { 'sources!': [ '../bench/BenchSysTimer_posix.h', '../bench/BenchSysTimer_posix.cpp', ], - },{ + }], + [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', { 'link_settings': { 'libraries': [ '-lrt', diff --git a/gyp/common_conditions.gypi b/gyp/common_conditions.gypi index d627998a86..759d8952ab 100644 --- a/gyp/common_conditions.gypi +++ b/gyp/common_conditions.gypi @@ -135,6 +135,50 @@ }, }, ], + + ['skia_os == "android"', + { + 'defines': [ + 'ANDROID', # TODO: change these defines to SK_BUILD_FOR_ANDROID + 'SK_BUILD_FOR_ANDROID', + 'SK_BUILD_FOR_ANDROID_NDK', + ], + 'configurations': { + 'Debug': { + 'cflags': ['-g'] + }, + 'Release': { + 'cflags': ['-O2'] + }, + }, + 'libraries': [ + '-lstdc++', + '-lm', + + ], + 'conditions': [ + [ 'skia_target_arch == "arm" and armv7 == 1', { + 'defines': [ + '__ARM_ARCH__=7', + ], + 'cflags': [ + '-march=armv7-a', + ], + 'conditions': [ + [ 'arm_neon == 1', { + 'defines': [ + '__ARM_HAVE_NEON', + ], + 'cflags': [ + '-mfloat-abi=softfp', + '-mfpu=neon', + ], + }], + ], + }], + ], + }, + ], ], # end 'conditions' } diff --git a/gyp/core.gyp b/gyp/core.gyp index abe9d1171c..a79af6b73e 100644 --- a/gyp/core.gyp +++ b/gyp/core.gyp @@ -340,6 +340,24 @@ '../src/ports/SkTime_win.cpp', ], }], + [ 'skia_os == "android"', { + 'sources!': [ + '../src/opts/opts_check_SSE2.cpp', + ], + 'sources': [ + '../include/core/SkMMapStream.h', + '../src/core/SkMMapStream.cpp', + '../src/ports/SkThread_pthread.cpp', + '../src/ports/SkFontHost_android.cpp', + '../src/ports/SkFontHost_gamma.cpp', + '../src/ports/SkFontHost_FreeType.cpp', + '../src/ports/FontHostConfiguration_android.cpp', + ], + 'dependencies': [ + 'android_system.gyp:ft2', + 'android_system.gyp:expat', + ], + }], ], 'direct_dependent_settings': { 'include_dirs': [ diff --git a/gyp/gpu.gyp b/gyp/gpu.gyp index a919de7d15..8b30a1259b 100644 --- a/gyp/gpu.gyp +++ b/gyp/gpu.gyp @@ -114,6 +114,8 @@ '../src/gpu/SkGrTexturePixelRef.cpp', '../src/gpu/SkNullGLContext.cpp', + '../src/gpu/android/SkNativeGLContext_android.cpp', + '../src/gpu/mac/SkNativeGLContext_mac.cpp', '../src/gpu/win/SkNativeGLContext_win.cpp', @@ -270,6 +272,8 @@ '../src/gpu/unix/GrGLCreateNativeInterface_unix.cpp', + '../src/gpu/android/GrGLCreateNativeInterface_android.cpp', + '../src/gpu/mesa/GrGLCreateMesaInterface.cpp', ], 'defines': [ @@ -327,6 +331,19 @@ '../src/gpu/GrGLCreateNativeInterface_none.cpp', ], }], + [ 'skia_os == "android"', { + 'sources!': [ + '../src/gpu/GrGLDefaultInterface_none.cpp', + '../src/gpu/GrGLCreateNativeInterface_none.cpp', + ], + 'link_settings': { + 'libraries': [ + '-lGLESv2', + '-lEGL', + '-shared', + ], + }, + }], ], }, ], diff --git a/gyp/images.gyp b/gyp/images.gyp index b50dd34594..4dce2c549b 100644 --- a/gyp/images.gyp +++ b/gyp/images.gyp @@ -116,7 +116,16 @@ }, # end libpng stuff }], - + [ 'skia_os == "android"', { + 'sources!': [ + '../src/images/SkImageDecoder_libjpeg.cpp', + '../src/images/SkJpegUtility.cpp', + ], + 'dependencies': [ + 'android_system.gyp:gif', + 'android_system.gyp:png', + ], + }], ], 'direct_dependent_settings': { 'include_dirs': [ diff --git a/gyp/opts.gyp b/gyp/opts.gyp index e63b1cb1f0..ae364816d8 100644 --- a/gyp/opts.gyp +++ b/gyp/opts.gyp @@ -35,11 +35,35 @@ '-msse2', ], }], - ], - 'sources': [ - '../src/opts/SkBitmapProcState_opts_SSE2.cpp', - '../src/opts/SkBlitRow_opts_SSE2.cpp', - '../src/opts/SkUtils_opts_SSE2.cpp', + [ 'skia_target_arch != "arm"', { + 'sources': [ + '../src/opts/SkBitmapProcState_opts_SSE2.cpp', + '../src/opts/SkBlitRow_opts_SSE2.cpp', + '../src/opts/SkUtils_opts_SSE2.cpp', + ], + }], + [ 'skia_target_arch == "arm" and armv7 == 1', { + # The assembly uses the frame pointer register (r7 in Thumb/r11 in + # ARM), the compiler doesn't like that. + 'cflags!': [ + '-fno-omit-frame-pointer', + ], + 'cflags': [ + '-fomit-frame-pointer', + ], + 'sources': [ + '../src/opts/SkBitmapProcState_opts_arm.cpp', + '../src/opts/SkBlitRow_opts_arm.cpp', + '../src/opts/SkUtils_opts_none.cpp', + ], + }], + [ 'skia_target_arch == "arm" and armv7 != 1', { + 'sources': [ + '../src/opts/SkBitmapProcState_opts_none.cpp', + '../src/opts/SkBlitRow_opts_none.cpp', + '../src/opts/SkUtils_opts_none.cpp', + ], + }], ], }, ], diff --git a/gyp/xml.gyp b/gyp/xml.gyp index 5c9edb27f6..7da8666630 100644 --- a/gyp/xml.gyp +++ b/gyp/xml.gyp @@ -33,7 +33,7 @@ '../src/xml/SkXMLPullParser.cpp', #if 0 around class decl in header ], 'conditions': [ - [ 'skia_os in ["win", "mac", "linux", "freebsd", "openbsd", "solaris"]', { + [ 'skia_os in ["win", "mac", "linux", "freebsd", "openbsd", "solaris", "android"]', { 'sources!': [ # no jsapi.h by default on system '../include/xml/SkJS.h', -- cgit v1.2.3