|
| 1 | +# Build Instructions |
| 2 | + |
| 3 | +Answering "how do I build Wuffs" depends on what exactly you mean by "Wuffs": |
| 4 | + |
| 5 | +1. The Wuffs library (e.g. image decoders) in C/C++ form. |
| 6 | +2. Its example programs (e.g. jsonptr). |
| 7 | +3. The Wuffs toolchain (e.g. Wuffs-to-C compiler/proof-checker). |
| 8 | +4. The Wuffs library in Wuffs form (converting it to C/C++ code). |
| 9 | +5. Everything. |
| 10 | + |
| 11 | + |
| 12 | +## Quick Start |
| 13 | + |
| 14 | +The rest of this document assumes that you've already checked out and moved |
| 15 | +into the Wuffs repository's directory, like this: |
| 16 | + |
| 17 | +``` |
| 18 | +git clone https://github.com/google/wuffs.git |
| 19 | +cd wuffs |
| 20 | +``` |
| 21 | + |
| 22 | +If you just want to kick the metaphorical tyres: |
| 23 | + |
| 24 | +``` |
| 25 | +./build-example.sh example/jsonptr |
| 26 | +gen/bin/example-jsonptr test/data/rfc-6901-json-pointer.json |
| 27 | +``` |
| 28 | + |
| 29 | + |
| 30 | +## Building the Wuffs Library (in C/C++ Form) |
| 31 | + |
| 32 | +There's no build step, in that there's no "configure and make" step needed |
| 33 | +before moving on to building the example programs. |
| 34 | + |
| 35 | +To elaborate, transpiling (converting Wuffs-the-library from `*.wuffs` form |
| 36 | +into a single `*.c` file) isn't done by whoever *checks out* the Wuffs |
| 37 | +repository. It's done by whoever *checks in* code changes. |
| 38 | + |
| 39 | +Wuffs-the-library is provided as [single file C |
| 40 | +library](https://github.com/nothings/stb/blob/master/docs/stb_howto.txt). The |
| 41 | +example programs just `#include` that file directly. |
| 42 | + |
| 43 | +For your own projects, just copy `release/c/wuffs-$VERSION.c` to your directory |
| 44 | +and add that file to your pre-existing build system, or compile an `*.o` object |
| 45 | +file directly like below. Remember to define the `WUFFS_IMPLEMENTATION` macro |
| 46 | +to compile all of the C code in that single file, not just the "header" part. |
| 47 | + |
| 48 | +``` |
| 49 | +# Most developers won't have to do this. It just demonstrates how to produce |
| 50 | +# wuffs-v0.3.o directly from a C/C++ compiler. |
| 51 | +gcc -c -DWUFFS_IMPLEMENTATION -O3 release/c/wuffs-v0.3.c |
| 52 | +``` |
| 53 | + |
| 54 | + |
| 55 | +## Building the Example Programs |
| 56 | + |
| 57 | +Just run your favorite C/C++ compiler (e.g. `gcc` or `g++`) on the |
| 58 | +`example/foo/*.{c,cc}` file. Pass `-O3` or equivalent for an optimized build: |
| 59 | + |
| 60 | +``` |
| 61 | +gcc -O3 example/bzcat/bzcat.c -o my-bzcat |
| 62 | +./my-bzcat < test/data/romeo.txt.bz2 |
| 63 | +``` |
| 64 | + |
| 65 | +Some example programs require additional libraries: |
| 66 | + |
| 67 | +``` |
| 68 | +g++ example/imageviewer/imageviewer.cc -lxcb -lxcb-image -lxcb-render -lxcb-render-util |
| 69 | +
|
| 70 | +g++ example/sdl-imageviewer/sdl-imageviewer.cc -lSDL2 -lSDL2_image |
| 71 | +``` |
| 72 | + |
| 73 | +The `build-example.sh` script (an alternative to running your favorite C/C++ |
| 74 | +compiler directly) takes care of having to remember those additional libraries. |
| 75 | + |
| 76 | +``` |
| 77 | +./build-example.sh example/sdl-imageviewer |
| 78 | +gen/bin/example-sdl-imageviewer test/data/hat.jpeg |
| 79 | +``` |
| 80 | + |
| 81 | +Building the fuzzers are similar, using `build-fuzz.sh` instead of |
| 82 | +`build-example.sh`. |
| 83 | + |
| 84 | + |
| 85 | +## Building the Wuffs Toolchain |
| 86 | + |
| 87 | +Most developers won't have to do this. See the sections above instead. |
| 88 | + |
| 89 | +But after editing `lang/check/*.go` files, do this: |
| 90 | + |
| 91 | +``` |
| 92 | +go install ./cmd/wuffs* |
| 93 | +``` |
| 94 | + |
| 95 | + |
| 96 | +## Building the Wuffs library (from its Wuffs Form) |
| 97 | + |
| 98 | +Most developers won't have to do this. See the sections above instead. |
| 99 | + |
| 100 | +But after editing `std/jpeg/*.wuffs` files, do this: |
| 101 | + |
| 102 | +``` |
| 103 | +wuffs gen std/... |
| 104 | +``` |
| 105 | + |
| 106 | + |
| 107 | +## Building Everything (All of the Above, Plus Tests, Benchmarks, Etc) |
| 108 | + |
| 109 | +Most developers won't have to do this. See the sections above instead. |
| 110 | + |
| 111 | +But before sending a Pull Request, do this: |
| 112 | + |
| 113 | +``` |
| 114 | +./build-all.sh |
| 115 | +``` |
0 commit comments