Search code examples
skia

How to compile HelloWorld application included in skia?


How do I compile skia HelloWorld program?

I went through this guide - it doesn't mention how to build example/HelloWorld

The version I have checked out is:

c7b263b603107acdb16b6570989e1ce5a2c7eb4e

I see mentions of it inside the .gn files but I am not sure how to invoke that specific item.


Solution

  • The HelloWorld program will be build as part of the normal Skia build process (Reference) for debug builds.

    In the Skia source directory:

    • Sync the third-party dependencies with python2 tools/git-sync-deps

    • Generate the build files with bin/gn gen out/Debug.

      • If you run into problems with Python 2 vs 3 here (i.e. when it complains about syntax errors in the build script), you would have to set Python 2 as the default. Instructions on how to achieve this might vary depending on your setup. You could look e.g. here for an example approach (creating a temporary bin directory with symlinks python and python-config to /usr/bin/python2 and /usr/bin/python2-config, then prepending this temporary directory to the $PATH).
    • Start the build process with ninja -C out/Debug. This will build all targets including HelloWorld.

      • To only build HelloWorld (and its dependencies), you could directly invoke ninja -C out/Debug HelloWorld.
    • The resulting binary is in out/Debug/HelloWorld.