From 7158e6acca1b1ecc321d4d514a31cba11b5ead60 Mon Sep 17 00:00:00 2001 From: "borenet@google.com" Date: Thu, 1 Nov 2012 17:43:44 +0000 Subject: Improve NaCl support - Add nacl_make script to build Skia targets for NaCl using gyp - Add nacl_interface for command-line apps - Add nacl_sample as front-end for SampleApp - Add freetype to DEPS - Various gyp tweaks for NaCl TODO: - Implement GL interface - Implement font host - Fix plumbing so that SampleApp works properly Review URL: https://codereview.appspot.com/6671044 git-svn-id: http://skia.googlecode.com/svn/trunk@6245 2bbb7eff-a529-9590-31e7-b0007b416f81 --- gyp/SampleApp.gyp | 5 +++ gyp/apptype_console.gypi | 5 +++ gyp/common.gypi | 22 ++++++---- gyp/common_conditions.gypi | 24 ++++++++--- gyp/common_variables.gypi | 2 - gyp/core.gyp | 2 +- gyp/everything.gyp | 2 +- gyp/freetype.gyp | 104 +++++++++++++++++++++++++++------------------ gyp/gpu.gyp | 12 ++++++ gyp/gpu.gypi | 1 + gyp/images.gyp | 2 +- gyp/nacl.gyp | 19 +++++++++ gyp/opts.gyp | 4 +- gyp/ports.gyp | 70 ++++++++++++++++++------------ gyp/utils.gyp | 8 +--- gyp/views.gyp | 12 ++++++ gyp/xml.gyp | 2 +- gyp/zlib.gyp | 2 +- 18 files changed, 201 insertions(+), 97 deletions(-) create mode 100644 gyp/nacl.gyp (limited to 'gyp') diff --git a/gyp/SampleApp.gyp b/gyp/SampleApp.gyp index 3b0be1b177..5668428784 100644 --- a/gyp/SampleApp.gyp +++ b/gyp/SampleApp.gyp @@ -290,6 +290,11 @@ '../src/gpu', # To pull gl/GrGLUtil.h ], }], + [ 'skia_os == "nacl"', { + 'sources': [ + '../../nacl/src/nacl_sample.cpp', + ], + }], ], 'msvs_settings': { 'VCLinkerTool': { diff --git a/gyp/apptype_console.gypi b/gyp/apptype_console.gypi index 80e925d9de..a30619373b 100644 --- a/gyp/apptype_console.gypi +++ b/gyp/apptype_console.gypi @@ -17,6 +17,11 @@ 'android_deps.gyp:Android_EntryPoint', ], }], + [ 'skia_os == "nacl"', { + 'dependencies': [ + 'nacl.gyp:nacl_interface', + ], + }], ['skia_os == "ios"', { 'target_conditions': [ ['_type == "executable"', { diff --git a/gyp/common.gypi b/gyp/common.gypi index b6202262d0..7dc27da143 100644 --- a/gyp/common.gypi +++ b/gyp/common.gypi @@ -21,15 +21,21 @@ # situations, like building for iOS on a Mac. 'variables': { 'conditions': [ - ['skia_os != OS and not (skia_os == "ios" and OS == "mac")', - {'error': ' + '../third_party/externals/freetype/src/base/ftglyph.c', # recommended, see + + '../third_party/externals/freetype/src/base/ftbitmap.c', # optional, see + '../third_party/externals/freetype/src/base/ftfstype.c', # optional + '../third_party/externals/freetype/src/base/ftgasp.c', # optional, see + '../third_party/externals/freetype/src/base/ftlcdfil.c', # optional, see + '../third_party/externals/freetype/src/base/ftmm.c', # optional, see + '../third_party/externals/freetype/src/base/ftpatent.c', # optional + '../third_party/externals/freetype/src/base/ftstroke.c', # optional, see + '../third_party/externals/freetype/src/base/ftsynth.c', # optional, see + '../third_party/externals/freetype/src/base/fttype1.c', # optional, see + '../third_party/externals/freetype/src/base/ftwinfnt.c', # optional, see + '../third_party/externals/freetype/src/base/ftxf86.c', # optional, see + + # font drivers (optional; at least one is needed) + '../third_party/externals/freetype/src/cff/cff.c', # CFF/OpenType font driver + '../third_party/externals/freetype/src/sfnt/sfnt.c', # SFNT files support (TrueType & OpenType) + '../third_party/externals/freetype/src/truetype/truetype.c', # TrueType font driver + + # rasterizers (optional; at least one is needed for vector formats) + '../third_party/externals/freetype/src/raster/raster.c', # monochrome rasterizer + '../third_party/externals/freetype/src/smooth/smooth.c', # anti-aliasing rasterizer + + # auxiliary modules (optional) + '../third_party/externals/freetype/src/autofit/autofit.c', # auto hinting module + '../third_party/externals/freetype/src/psaux/psaux.c', # PostScript Type 1 parsing + '../third_party/externals/freetype/src/pshinter/pshinter.c', # PS hinting module + '../third_party/externals/freetype/src/psnames/psnames.c', # PostScript glyph names support ], 'include_dirs': [ - '../third_party/freetype/internal', - '../third_party/freetype/builds', - '../third_party/freetype/include', - '../third_party/freetype', + '../third_party/externals/freetype/internal', + '../third_party/externals/freetype/builds', + '../third_party/externals/freetype/include', + '../third_party/externals/freetype', ], 'cflags': [ - '-W', - '-Wall', - '-fPIC', - '-DPIC', - '-DDARWIN_NO_CARBON', '-DFT2_BUILD_LIBRARY', ], 'direct_dependent_settings': { 'include_dirs': [ - '../third_party/freetype/include', # For ft2build.h + '../third_party/externals/freetype/include', ], }, + 'conditions': [ + [ 'skia_os == "mac"', { + 'sources': [ + '../third_party/externals/freetype/src/base/ftmac.c', # only on the Macintosh + ], + }], + [ 'skia_os == "android"', { + # These flags are used by the Android OS. They are probably overkill + # for Skia, but we add them for consistency. + 'cflags': [ + '-W', + '-Wall', + '-fPIC', + '-DPIC', + '-DDARWIN_NO_CARBON', + '-DFT2_BUILD_LIBRARY', + '-O2', + ], + 'cflags!': [ + '-fno-rtti', # supress warnings about invalid option of non-C++ code + ], + }], + ], }, ], } diff --git a/gyp/gpu.gyp b/gyp/gpu.gyp index 9cb06980d3..d5223e40ef 100644 --- a/gyp/gpu.gyp +++ b/gyp/gpu.gyp @@ -21,6 +21,10 @@ 'sources/': [ ['exclude', '_android.(h|cpp)$'], ], }], + ['skia_os != "nacl"', { + 'sources/': [ ['exclude', '_nacl.(h|cpp)$'], + ], + }], [ 'skia_os == "android"', { 'defines': [ 'GR_ANDROID_BUILD=1', @@ -209,10 +213,18 @@ 'link_settings': { 'libraries': [ '-lGL', + '-lGLU', '-lX11', ], }, }], + [ 'skia_os == "nacl"', { + 'link_settings': { + 'libraries': [ + '-lppapi_gles2', + ], + }, + }], [ 'skia_mesa and skia_os == "linux"', { 'link_settings': { 'libraries': [ diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi index 0c45aa5908..67cf6034f2 100644 --- a/gyp/gpu.gypi +++ b/gyp/gpu.gypi @@ -238,6 +238,7 @@ 'skgr_native_gl_sources': [ '<(skia_include_path)/gpu/gl/SkNativeGLContext.h', '<(skia_src_path)/gpu/gl/mac/SkNativeGLContext_mac.cpp', + '<(skia_src_path)/gpu/gl/nacl/SkNativeGLContext_nacl.cpp', '<(skia_src_path)/gpu/gl/win/SkNativeGLContext_win.cpp', '<(skia_src_path)/gpu/gl/unix/SkNativeGLContext_unix.cpp', '<(skia_src_path)/gpu/gl/android/SkNativeGLContext_android.cpp', diff --git a/gyp/images.gyp b/gyp/images.gyp index 2989afeb11..daf4c5f6c8 100644 --- a/gyp/images.gyp +++ b/gyp/images.gyp @@ -89,7 +89,7 @@ '../src/ports/SkImageDecoder_CG.cpp', ], }], - [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', { + [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "nacl"]', { 'sources!': [ '../src/images/SkImageDecoder_libgif.cpp', '../src/images/SkMovie_gif.cpp', diff --git a/gyp/nacl.gyp b/gyp/nacl.gyp new file mode 100644 index 0000000000..95b2a8226e --- /dev/null +++ b/gyp/nacl.gyp @@ -0,0 +1,19 @@ +# Common entry point for all Skia executables running in NaCl +{ + 'targets': [ + { + 'target_name': 'nacl_interface', + 'type': 'static_library', + 'dependencies': [ + 'skia_base_libs.gyp:skia_base_libs', + ], + 'include_dirs': [ + # For SkThreadUtils.h + '../src/utils', + ], + 'sources': [ + '../../nacl/src/nacl_interface.cpp', + ], + }, + ], +} \ No newline at end of file diff --git a/gyp/opts.gyp b/gyp/opts.gyp index b8d7e22960..cd892e8f59 100644 --- a/gyp/opts.gyp +++ b/gyp/opts.gyp @@ -32,7 +32,7 @@ 'conditions': [ [ 'skia_arch_type == "x86" and skia_os != "ios"', { 'conditions': [ - [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', { + [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "nacl"]', { 'cflags': [ '-msse2', ], @@ -108,7 +108,7 @@ '../src/core', ], 'conditions': [ - [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', { + [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "nacl"]', { 'cflags': [ '-mssse3', ], diff --git a/gyp/ports.gyp b/gyp/ports.gyp index f743ad4f7f..6403693f98 100644 --- a/gyp/ports.gyp +++ b/gyp/ports.gyp @@ -20,6 +20,7 @@ '../src/utils', ], 'sources': [ + '../src/ports/SkDebug_nacl.cpp', '../src/ports/SkDebug_stdio.cpp', '../src/ports/SkDebug_win.cpp', '../src/ports/SkFontDescriptor.h', @@ -39,36 +40,51 @@ ], 'conditions': [ [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', { - 'conditions': [ - [ 'skia_nacl', { - 'defines': [ - 'SK_CAN_USE_DLOPEN=0', - ], - 'sources': [ - '../src/ports/SkFontHost_none.cpp', - ], - }, { - 'defines': [ - #The font host requires at least FreeType 2.3.0 at runtime. - 'SK_FONTHOST_FREETYPE_RUNTIME_VERSION=0x020300', - 'SK_CAN_USE_DLOPEN=1', - ], - 'sources': [ - '../src/ports/SkFontHost_FreeType.cpp', - '../src/ports/SkFontHost_FreeType_common.cpp', - '../src/ports/SkFontHost_linux.cpp', - ], - 'link_settings': { - 'libraries': [ - '-lfreetype', - '-ldl', - ], - }, - }], + 'defines': [ + #The font host requires at least FreeType 2.3.0 at runtime. + 'SK_FONTHOST_FREETYPE_RUNTIME_VERSION=0x020300',\ + 'SK_CAN_USE_DLOPEN=1', + ], + 'link_settings': { + 'libraries': [ + '-lfreetype', + '-ldl', + ], + }, + 'sources': [ + '../src/ports/SkFontHost_FreeType.cpp', + '../src/ports/SkFontHost_FreeType_common.cpp', + '../src/ports/SkFontHost_linux.cpp', + '../src/ports/SkThread_pthread.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', '../src/ports/SkThread_pthread.cpp', ], + 'sources!': [ + '../src/ports/SkDebug_stdio.cpp', + ], + }, { + 'sources!': [ + '../src/ports/SkDebug_nacl.cpp', + ], }], [ 'skia_os == "mac"', { 'include_dirs': [ @@ -150,7 +166,7 @@ #TODO: include the ports/SkImageRef_ashmem.cpp for non-NDK builds ], 'dependencies': [ - 'android_deps.gyp:ft2', + 'freetype.gyp:freetype', 'android_deps.gyp:expat', ], }], diff --git a/gyp/utils.gyp b/gyp/utils.gyp index 97f25b158d..aa3f4a3c74 100644 --- a/gyp/utils.gyp +++ b/gyp/utils.gyp @@ -129,12 +129,6 @@ ], }], [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', { - 'link_settings': { - 'libraries': [ - '-lGL', - '-lGLU', - ], - }, 'sources!': [ '../src/utils/SkThreadUtils_pthread_other.cpp', ], @@ -176,7 +170,7 @@ '../src/utils/win/SkIStream.cpp', ], }], - [ 'skia_nacl == 1', { + [ 'skia_os == "nacl"', { 'sources': [ '../src/utils/SkThreadUtils_pthread_other.cpp', ], diff --git a/gyp/views.gyp b/gyp/views.gyp index 80be87e0d6..5f58a87f49 100644 --- a/gyp/views.gyp +++ b/gyp/views.gyp @@ -32,6 +32,7 @@ '../include/views/SkKey.h', '../include/views/SkOSMenu.h', '../include/views/SkOSWindow_Mac.h', + '../include/views/SkOSWindow_NaCl.h', '../include/views/SkOSWindow_SDL.h', '../include/views/SkOSWindow_Unix.h', '../include/views/SkOSWindow_Win.h', @@ -111,6 +112,17 @@ '../src/views/win/skia_win.cpp', ], }], + [ 'skia_os == "nacl"', { + 'sources!': [ + '../src/views/unix/SkOSWindow_Unix.cpp', + '../src/views/unix/keysym2ucs.c', + '../src/views/unix/skia_unix.cpp', + ], + }, { + 'sources!': [ + '../src/views/nacl/SkOSWindow_NaCl.cpp', + ], + }], [ 'skia_gpu == 1', { 'include_dirs': [ '../include/gpu', diff --git a/gyp/xml.gyp b/gyp/xml.gyp index b7fdb8397a..5cf06594b1 100644 --- a/gyp/xml.gyp +++ b/gyp/xml.gyp @@ -32,7 +32,7 @@ '../src/xml/SkXMLPullParser.cpp', #if 0 around class decl in header ], 'conditions': [ - [ 'skia_os in ["win", "mac", "linux", "freebsd", "openbsd", "solaris", "android", "ios"]', { + [ 'skia_os in ["win", "mac", "linux", "freebsd", "openbsd", "solaris", "android", "ios", "nacl"]', { 'sources!': [ # no jsapi.h by default on system '../include/xml/SkJS.h', diff --git a/gyp/zlib.gyp b/gyp/zlib.gyp index 864a059bf3..fcd0ac3b40 100644 --- a/gyp/zlib.gyp +++ b/gyp/zlib.gyp @@ -29,7 +29,7 @@ }, 'defines': [ 'SK_ZLIB_INCLUDE=', ], }], - [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "android"]', { + [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "android", "nacl"]', { 'link_settings': { 'libraries': [ '-lz', ], }, 'defines': [ 'SK_ZLIB_INCLUDE=', ], }], -- cgit v1.2.3