<!--?prettify lang=sh?-->
git pull
- python bin/sync-and-gyp
+ python bin/sync
Adding a unit test
------------------
+++ /dev/null
-sync-and-gyp
-============
-
-[`sync-and-gyp`](https://skia.googlesource.com/skia.git/+/master/bin/sync-and-gyp)
-is a Python program that wraps `gclient sync` and `gyp_skia`.
-Motivations for using it:
-
-- Fewer steps to configure and compile Skia and Skia's dependencies.
- This makes documentation cleaner, too.
-
-- Written in Python, so it will work on all platforms. Python is
- already necessary for gyp.
-
-- Sets up gclient better than `gclient config`, which has been broken.
-
-- Checks to see if the `DEPS` file has changed since it last ran
- `gclient sync`. If not, it skips that step.
-
-- Checks to see if gyp needs to be re-run (it checks environment
- variables and changed or added files); if not, it skips running
- `gyp_skia`.
-
-- Since running `sync-and-gyp` is fast when it can do nothing, it is
- easy to do before every recompile of Skia. This is a good habit.
--- /dev/null
+sync
+====
+
+[`sync`](https://skia.googlesource.com/skia.git/+/master/bin/sync)
+is a Python program that wraps `gclient sync` and `fetch-gn`.
+Motivations for using it:
+
+- Written in Python, so it will work on all platforms.
+
+- Sets up gclient better than `gclient config`, which has been broken.
+
+- Checks to see if the `DEPS` file has changed since it last ran
+ `gclient sync`. If not, it skips that step.
+
+- Calls `fetch-gn` if needed.
+
+- Since running `sync` is fast when it can do nothing, it is
+ easy to do before every recompile of Skia. This is a good habit.
Skia correctness testing is primarily served by a tool named DM.
This is a quickstart to building and running DM.
-~~~
-$ python bin/sync-and-gyp
-$ ninja -C out/Debug dm
-$ out/Debug/dm -v -w dm_output
-~~~
+<!--?prettify lang=sh?-->
+
+ python bin/sync
+ gn gen out/Debug
+ ninja -C out/Debug dm
+ out/Debug/dm -v -w dm_output
When you run this, you may notice your CPU peg to 100% for a while, then taper
off to 1 or 2 active cores as the run finishes. This is intentional. DM is
These failures are also included in the dm.json file.
DM has a simple facility to compare against the results of a previous run:
-~~~
-$ python bin/sync-and-gyp
-$ ninja -C out/Debug dm
-$ out/Debug/dm -w good
- # do some work
+<!--?prettify lang=sh?-->
+
+ ninja -C out/Debug dm
+ out/Debug/dm -w good
+
+ # do some work
+
+ ninja -C out/Debug dm
+ out/Debug/dm -r good -w bad
-$ python bin/sync-and-gyp
-$ ninja -C out/Debug dm
-$ out/Debug/dm -r good -w bad
-~~~
When using `-r`, DM will display a failure for any test that didn't produce the
same image as the `good` run.
For anything fancier, I suggest using skdiff:
-~~~
-$ python bin/sync-and-gyp
-$ ninja -C out/Debug dm
-$ out/Debug/dm -w good
- # do some work
+<!--?prettify lang=sh?-->
-$ python bin/sync-and-gyp
-$ ninja -C out/Debug dm
-$ out/Debug/dm -w bad
+ ninja -C out/Debug dm
+ out/Debug/dm -w good
-$ ninja -C out/Debug skdiff
-$ mkdir diff
-$ out/Debug/skdiff good bad diff
+ # do some work
- # open diff/index.html in your web browser
-~~~
+ ninja -C out/Debug dm
+ out/Debug/dm -w bad
+
+ ninja -C out/Debug skdiff
+ mkdir diff
+ out/Debug/skdiff good bad diff
+
+ # open diff/index.html in your web browser
That's the basics of DM. DM supports many other modes and flags. Here are a
few examples you might find handy.
-~~~
-$ out/Debug/dm --help # Print all flags, their defaults, and a brief explanation of each.
-$ out/Debug/dm --src tests # Run only unit tests.
-$ out/Debug/dm --nocpu # Test only GPU-backed work.
-$ out/Debug/dm --nogpu # Test only CPU-backed work.
-$ out/Debug/dm --match blur # Run only work with "blur" in its name.
-$ out/Debug/dm --dryRun # Don't really do anything, just print out what we'd do.
-~~~
+
+<!--?prettify lang=sh?-->
+
+ out/Debug/dm --help # Print all flags, their defaults, and a brief explanation of each.
+ out/Debug/dm --src tests # Run only unit tests.
+ out/Debug/dm --nocpu # Test only GPU-backed work.
+ out/Debug/dm --nogpu # Test only CPU-backed work.
+ out/Debug/dm --match blur # Run only work with "blur" in its name.
+ out/Debug/dm --dryRun # Don't really do anything, just print out what we'd do.
+
+ [Rendering Tests](#gm)
+ [Benchmark Tests](#bench)
+We assume you have already synced Skia's dependecies and set up Skia's build system.
+
+<!--?prettify lang=sh?-->
+
+ python bin/sync
+ gn gen out/Debug
+ gn gen out/Release --args='is_debug=false'
+
<span id="test"></span>
Writing a Unit Test
REPORTER_ASSERT(reporter, lifeIsGood);
}
-2. Recompile and run test:
+2. Add `NewUnitTest.cpp` to `gn/tests.gni`.
+
+3. Recompile and run test:
+
+ <!--?prettify lang=sh?-->
- python bin/sync-and-gyp
ninja -C out/Debug dm
out/Debug/dm --match NewUnitTest
canvas->drawLine(16, 16, 112, 112, p);
}
-2. Recompile and run test:
+2. Add `newgmtest.cpp` to `gn/gm.gni`.
+
+3. Recompile and run test:
+
+ <!--?prettify lang=sh?-->
- python bin/sync-and-gyp
ninja -C out/Debug dm
out/Debug/dm --match newgmtest
-3. Run the GM inside SampleApp:
+4. Run the GM inside SampleApp:
+
+ <!--?prettify lang=sh?-->
- python bin/sync-and-gyp
ninja -C out/Debug SampleApp
out/Debug/SampleApp --slide GM:newgmtest
- On MacOS, try this:
-
- out/Debug/SampleApp.app/Contents/MacOS/SampleApp --slide GM:newgmtest
-
<span id="bench"></span>
Writing a Benchmark Test
} // namespace
DEF_BENCH(return new FooBench;)
+2. Add `FooBench.cpp` to `gn/bench.gni`.
+
+3. Recompile and run nanobench:
-2. Recompile and run nanobench:
+ <!--?prettify lang=sh?-->
- python bin/sync-and-gyp
ninja -C out/Release nanobench
out/Release/nanobench --match Foo
Tips & FAQ
==========
-+ [Gyp Options](#gypdefines)
+ [Bitmap Subsetting](#bitmap-subsetting)
+ [Capture a `.skp` file on a web page in Chromium](#skp-capture)
+ [Capture a `.mskp` file on a web page in Chromium](#mskp-capture)
* * *
-<span id="gypdefines">Gyp Options</span>
-----------------------------------------
-
-When running `sync-and-gyp`, the `GYP_DEFINES` environment variable can
-be used to change Skia’s compile-time settings, using a
-space-separated list of key=value pairs. For example, to disable both
-the Skia GPU backend and PDF backends, run it as follows:
-
-<!--?prettify lang=sh?-->
-
- GYP_DEFINES='skia_gpu=0 skia_pdf=0' python bin/sync-and-gyp
- ninja -C out/Debug
-
-Note: Setting enviroment variables in the Windows CMD.EXE shell [uses a
-different syntax](/user/quick/windows#env).
-
-You can also set environment variables such as `CC`, `CXX`,
-`CFLAGS`, `CXXFLAGS`, or `CPPFLAGS` to control how Skia is compiled.
-To build with clang, for example:
-
-<!--?prettify lang=sh?-->
-
- CC='clang' CXX='clang++' python bin/sync-and-gyp
- ninja -C out/Debug
-
-To build with clang and enable a compiler warning for unused parameters in C++
-(but not C or assembly) code:
-
-<!--?prettify lang=sh?-->
-
- CXXFLAGS='-Wunused-parameter' \
- CC='clang' CXX='clang++' python bin/sync-and-gyp
- ninja -C out/Debug
-
-
-The `GYP_GENERATORS` environment variable can be used to set the
-build systems that you want to use (as a comma-separated list).
-The default is `'ninja,msvs-ninja'` on Windows, `'ninja,xcode'` on
-Mac OS X, and just `'ninja'` on Linux. For example, to generate
-only Ninja files on Mac:
-
-<!--?prettify lang=sh?-->
-
- GYP_GENERATORS='ninja' python bin/sync-and-gyp
- ninja -C out/Debug
-
-Finally, the `SKIA_OUT` environment variable can be used to set
-the path for the build directory. The default is `out` inside the
-top-level Skia source directory. For example to test Skia with
-two different compilers:
-
-<!--?prettify lang=sh?-->
-
- CC='clang' CXX='clang++' SKIA_OUT=~/build/skia_clang python bin/sync-and-gyp
- CC='gcc' CXX='g++' SKIA_OUT=~/build/skia_gcc python bin/sync-and-gyp
- ninja -C ~/build/skia_clang/Debug
- ninja -C ~/build/skia_gcc/Debug
-
-* * *
-
-
-
<span id="bitmap-subsetting">Bitmap Subsetting</span>
-----------------------------------------------------