1## Build & Run
2
3Depending on what area you are working in change or add `HB_DEBUG_<whatever>`.
4Values defined in `hb-debug.hh`.
5
6```shell
7# quick sanity check
8time (make -j4 CPPFLAGS='-DHB_DEBUG_SUBSET=100' \
9  && (make -j4 -C test/api check || cat test/api/test-suite.log))
10
11# slower sanity check
12time (make -j4 CPPFLAGS='-DHB_DEBUG_SUBSET=100' \
13   && make -j4 -C src check \
14   && make -j4 -C test/api check \
15   && make -j4 -C test/subset check)
16
17# confirm you didn't break anything else
18time (make -j4 CPPFLAGS='-DHB_DEBUG_SUBSET=100' \
19  && make -j4 check)
20
21# often catches files you didn't add, e.g. test fonts to EXTRA_DIST
22make distcheck
23```
24
25### Run tests with asan
26
27**NOTE**: this sometimes yields harder to read results than the full fuzzer
28
29```shell
30# For nice symbols tell asan how to symoblize. Note that it doesn't like versioned copies like llvm-symbolizer-3.8
31# export ASAN_SYMBOLIZER_PATH=path to version-less llvm-symbolizer
32# ex
33export ASAN_SYMBOLIZER_PATH=/usr/lib/llvm-3.8/bin/llvm-symbolizer
34
35./configure CC=clang CXX=clang++ CPPFLAGS=-fsanitize=address LDFLAGS=-fsanitize=address
36# make/run tests as usual
37```
38
39### Debug with GDB
40
41```
42cd ./util
43../libtool --mode=execute gdb --args ./hb-subset ...
44```
45
46### Enable Debug Logging
47
48```shell
49# make clean if you previously build w/o debug logging
50make CPPFLAGS=-DHB_DEBUG_SUBSET=100
51```
52
53## Build and Test via CMake
54
55Note: You'll need to first install ninja-build via apt-get.
56
57```shell
58meson build && ninja -Cbuild && ninja -Cbuild test
59```
60
61## Test with the Fuzzer
62
63```shell
64# push your changs to a branch on googlefonts/harfbuzz
65# In a local copy of oss-fuzz, edit projects/harfbuzz/Dockerfile
66# Change the git clone to pull your branch
67
68# Do this periodically
69sudo python infra/helper.py build_image harfbuzz
70
71# Do these to update/run
72sudo python infra/helper.py build_fuzzers --sanitizer address harfbuzz
73sudo python infra/helper.py run_fuzzer harfbuzz hb-subset-fuzzer
74```
75
76## Profiling
77
78```
79make clean
80./configure CXXFLAGS="-fno-omit-frame-pointer -g"
81make
82perf record -o <perf output file> -g <command to run>
83perf report -i<perf output file>
84```
85
86