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
diff --git a/gyp/freetype.gyp b/gyp/freetype.gyp
index 4a885a1..db61742 100644
--- a/gyp/freetype.gyp
+++ b/gyp/freetype.gyp
@@ -1,60 +1,82 @@
 {
   'targets': [
     {
-      'target_name': 'skfreetype',
+      'target_name': 'freetype',
       'type': 'static_library',
       'sources': [
-        '../third_party/freetype/src/base/ftbbox.c',
-        '../third_party/freetype/src/base/ftbitmap.c',
-        '../third_party/freetype/src/base/ftglyph.c',
-        '../third_party/freetype/src/base/ftlcdfil.c',
-        '../third_party/freetype/src/base/ftstroke.c',
-        '../third_party/freetype/src/base/ftxf86.c',
-        '../third_party/freetype/src/base/ftbase.c',
-        '../third_party/freetype/src/base/ftsystem.c',
-        '../third_party/freetype/src/base/ftinit.c',
-        '../third_party/freetype/src/base/ftgasp.c',
-        '../third_party/freetype/src/base/ftfstype.c',
-        '../third_party/freetype/src/raster/raster.c',
-        '../third_party/freetype/src/sfnt/sfnt.c',
-        '../third_party/freetype/src/smooth/smooth.c',
-        '../third_party/freetype/src/autofit/autofit.c',
-        '../third_party/freetype/src/truetype/truetype.c',
-        '../third_party/freetype/src/cff/cff.c',
-        '../third_party/freetype/src/psnames/psnames.c',
-        '../third_party/freetype/src/pshinter/pshinter.c',
+        # base components (required)
+        '../third_party/externals/freetype/src/base/ftsystem.c',
+        '../third_party/externals/freetype/src/base/ftinit.c',
+        '../third_party/externals/freetype/src/base/ftdebug.c',
+        '../third_party/externals/freetype/src/base/ftbase.c',
 
-# added for linker
-        '../third_party/freetype/src/lzw/ftlzw.c',
-        '../third_party/freetype/src/gzip/ftgzip.c',
-        '../third_party/freetype/src/cid/type1cid.c',
-        '../third_party/freetype/src/bdf/bdf.c',
-        '../third_party/freetype/src/psaux/psaux.c',
-        '../third_party/freetype/src/pcf/pcf.c',
-        '../third_party/freetype/src/pfr/pfr.c',
-        '../third_party/freetype/src/type1/type1.c',
-        '../third_party/freetype/src/type42/type42.c',
-        '../third_party/freetype/src/winfonts/winfnt.c',
+        '../third_party/externals/freetype/src/base/ftbbox.c',       # recommended, see <freetype/ftbbox.h>
+        '../third_party/externals/freetype/src/base/ftglyph.c',      # recommended, see <freetype/ftglyph.h>
+
+        '../third_party/externals/freetype/src/base/ftbitmap.c',     # optional, see <freetype/ftbitmap.h>
+        '../third_party/externals/freetype/src/base/ftfstype.c',     # optional
+        '../third_party/externals/freetype/src/base/ftgasp.c',       # optional, see <freetype/ftgasp.h>
+        '../third_party/externals/freetype/src/base/ftlcdfil.c',     # optional, see <freetype/ftlcdfil.h>
+        '../third_party/externals/freetype/src/base/ftmm.c',         # optional, see <freetype/ftmm.h>
+        '../third_party/externals/freetype/src/base/ftpatent.c',     # optional
+        '../third_party/externals/freetype/src/base/ftstroke.c',     # optional, see <freetype/ftstroke.h>
+        '../third_party/externals/freetype/src/base/ftsynth.c',      # optional, see <freetype/ftsynth.h>
+        '../third_party/externals/freetype/src/base/fttype1.c',      # optional, see <freetype/t1tables.h>
+        '../third_party/externals/freetype/src/base/ftwinfnt.c',     # optional, see <freetype/ftwinfnt.h>
+        '../third_party/externals/freetype/src/base/ftxf86.c',       # optional, see <freetype/ftxf86.h>
+
+        # 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
+          ],
+        }],
+      ],
     },
   ],
 }