My favorites | Sign in
Project Home Wiki Issues Source
Search
for
GettingStartedOnWindows  
How to check out and build Skia on Windows
Updated Mar 23, 2012 by epoger@google.com

How to check out and build Skia on Windows

originally written by epoger@google.com on 2 June 2011

status: updated as of 23 March 2012

Prerequisites

Make sure the following have been installed:

Check out the source code

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

rem Modify the below line to install wherever you like
set SKIA_INSTALLDIR=%HOMEPATH%\src\skia
mkdir %SKIA_INSTALLDIR%
cd %SKIA_INSTALLDIR%
svn checkout http://skia.googlecode.com/svn/trunk

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

Generate Visual Studio projects

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

You can generate the Visual Studio projects by running gyp_skia, as follows:

cd %SKIA_INSTALLDIR%\trunk
python gyp_skia
rem Or, to generate buildfiles for SKIA_SCALAR_IS_FIXED:
python gyp_skia -Dskia_scalar=fixed

Or, you can just rely on it being run automatically by the "make" examples shown below.

Note that you will see a bunch of Warnings like the following when you run gyp_skia. They are the result of a gyp bug, but they should not prevent you from building your code successfully.

Warning: Missing input file C:\Users\epoger\src\skia\test\gyp\pdf.gyp
Warning: Missing input file C:\Users\epoger\src\skia\test\gyp\experimental.gyp
...

Build and run tests from the command line

(Like all command-line builds 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 tests in the Visual Studio IDE

  • Generate the Visual Studio project files by running gyp_skia as described above
  • Open a File Explorer window pointing at the %SKIA_INSTALLDIR%\trunk\out\gyp directory
  • Double-click on tests.sln to start Visual Studio and load the project
  • When Visual Studio starts, you may see an error dialog stating that "One or more projects in the solution were not loaded correctly"... but there's probably nothing to worry about.
  • In the "Solution Explorer" window, right-click on the "tests" project and select "Set as StartUp Project".
  • In the "Debug" menu, click on "Start Debugging" (or just press F5). If you get a dialog saying that the project is out of date, click on "Yes" to rebuild it.
  • Once the build is complete, you should see console output from the tests in the "Output" window at lower right.

Build and run SampleApp in Visual Studio

  • Generate the Visual Studio project files by running gyp_skia as described above
  • Open a File Explorer window pointing at the %SKIA_INSTALLDIR%\trunk\out\gyp directory
  • Double-click on SampleApp.sln
  • When Visual Studio starts, you may see an error dialog stating that "One or more projects in the solution were not loaded correctly"... but there's probably nothing to worry about.
  • In the "Debug" menu, click on "Start Debugging" (or just press F5). If you get a dialog saying that the project is out of date, click on "Yes" to rebuild it.
  • Once the build is complete, you should see a window with various example graphics. 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-win
echo %ERRORLEVEL%

You can also adjust the type used to represent SkScalar. By default, we use a float. To change that, run it as follows. (It should return an errorlevel of -1, because the base-win base images don't match the output when skia_scalar=fixed.)

make gm GYP_DEFINES=skia_scalar=fixed
out\Debug\gm -r gm\base-win-fixed
echo %ERRORLEVEL%

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

Since bench tests performance, it usually makes more sense to run it in Release mode...

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

Build tools

make tools
out\Debug\skdiff

Clean up all generated files

make clean

Building with Visual Studio 2008

This isn't supported, but the following steps were observed to work on 11/21/2011:

  1. Edit gyp_skia in the trunk directory and remove (or comment out) this line:
  2. args.extend(['-Gmsvs_version=2010'])
  3. Run "python gyp_skia" in trunk.
  4. Open out\skia.sln in Visual Studio 2008
  5. Build

Powered by Google Project Hosting