My favorites | Sign in
Project Home Wiki Issues Source
Search
for
GettingStartedOnMac  
How to check out and build Skia on Mac OS X
Updated Jul 21, 2011 by epoger@google.com

How to check out and build Skia on Mac OS X

originally written by epoger@google.com on 25 May 2011

status: updated by epoger on 29 June 2011

Prerequisites

Make sure the following have been installed:

  • XCode (Apple's development environment): required
    • available at http://developer.apple.com/xcode/
    • this version is known to work: 3.2.4
    • this version is known to not work: 4.0.2 (XCode 4 no longer includes the Mac OS X 10.5 SDK)
    • during installation, be sure to include "Mac OS X 10.4 SDK" on the "Installation Type" page
  • Subversion (svn) client: required
  • Python: required
  • libpng: required to build/run tests

Check out the source code

To anonymously check out a read-only copy of the Skia source code, open a Terminal window and run the following commands:

SKIA_INSTALLDIR=/Users/$USER/src/skia    # or wherever you want to install it
mkdir -p $SKIA_INSTALLDIR
cd $SKIA_INSTALLDIR
svn checkout http://skia.googlecode.com/svn/trunk
cd trunk

If you plan to make changes, see instructions for downloading a writable copy within http://code.google.com/p/skia/wiki/DownloadingSkiaCode .

Generate XCode projects

We use the open-source gyp tool to generate XCode projects (and analogous build scripts on other platforms) from our multiplatform "gyp" files.

You would think that gyp would be able to create Makefiles that work on the Mac... but you'd be wrong. For now, you have to use gyp's XCode output to build on a Mac.

You can generate the XCode projects by running ./gyp_skia (or ./gyp_skia -Dskia_scalar-fixed) within the trunk/ directory. Or, you can just rely on it being run automatically by the make examples shown below.

Build and run tests from the command line

(Like all "make" steps shown on this page, this will automatically run the gyp_skia script to generate the platform-specific build files, and then run the build. Also, it must be run from within the trunk/ directory.)

make tests
out/Debug/tests

By default, the target is built in Debug mode (SK_DEBUG is defined, and debug symbols are included in the binary). If you would like to build the Release version instead:

make tests BUILDTYPE=Release
out/Release/tests

Build and run SampleApp in the XCode IDE

  • Run gyp_skia as described above.
  • In the Finder, navigate to $SKIA_INSTALLDIR/trunk/out/gyp
  • Double-click SampleApp.xcodeproj ; this will launch XCode and open the SampleApp project
  • Click the “Build and Run” button in the top toolbar
  • Once the build is complete, you should see a window with lots of shaded text examples. To move through the sample app, use the following keypresses:
    • right-arrow key: cycle through different test pages
    • left-arrow key: cycle through rendering methods for each test page
    • other keys are defined in SampleApp.cpp’s SampleWindow::onHandleKey() and SampleWindow::onHandleChar() methods

Build and run gm ("golden master") tests from the command line

This will display the return value (0 = success) after running the tests...

make gm
out/Debug/gm -r gm/base ; echo $?

You can also adjust the type used to represent SkScalar. By default, we use a float. To change that, run it as follows:

GYP_DEFINES="skia_scalar=fixed" make gm
out/Debug/gm -r gm/base-MacPro-fixed ; echo $?

Build and run bench (performance testbench) from the command line

In this case, we will build with the "Release" configuration, since we are running performance tests...

make bench BUILDTYPE=Release
out/Release/bench -repeat 2

Build tools

Note that the tools don't get automatically copied into out/Debug by our "make" wrapper yet, so you have to go find the binary where XCode wrote it...

make tools
xcodebuild/Debug/skdiff.app/Contents/MacOS/skdiff

Clean up all generated files

make clean
Powered by Google Project Hosting