OLD | NEW |
| 1 # Ninja Build |
1 | 2 |
| 3 Ninja is a build system written with the specific goal of improving the |
| 4 edit-compile cycle time. It is used by default everywhere except when building |
| 5 for iOS. |
2 | 6 |
3 Ninja is a build system written with the specific goal of improving the edit-com
pile cycle time. It is used by default everywhere except when building for iOS. | 7 Ninja behaves very similar to Make -- the major feature is that it starts |
| 8 building files nearly instantly. (It has a number of minor user interface |
| 9 improvements to make as well.) |
4 | 10 |
5 Ninja behaves very similar to Make -- the major feature is that it starts buildi
ng files nearly instantly. (It has a number of minor user interface improvement
s to make as well.) | 11 Read more about Ninja at |
6 | 12 [the Ninja home page](http://martine.github.com/ninja/). |
7 Read more about Ninja at [the Ninja home page](http://martine.github.com/ninja/)
. | |
8 | 13 |
9 ## Using it | 14 ## Using it |
10 | 15 |
11 ### Configure your system to use Ninja | 16 ### Configure your system to use Ninja |
12 | 17 |
13 #### Install | 18 #### Install |
14 | 19 |
15 Ninja is included in depot\_tools as well as gyp, so there's nothing to install. | 20 Ninja is included in `depot_tools` as well as `gyp`, so there's nothing to |
| 21 install. |
16 | 22 |
17 ## Build instructions | 23 ## Build instructions |
18 | 24 |
19 To build Chrome: | 25 To build Chrome: |
20 ``` | |
21 cd /path/to/chrome/src | |
22 ninja -C out/Debug chrome | |
23 ``` | |
24 | 26 |
25 Specify `out/Release` for a release build. I recommend setting up an alias so th
at you don't need to type out that build directory path. | 27 cd /path/to/chrome/src |
| 28 ninja -C out/Debug chrome |
26 | 29 |
27 If you want to build all targets, use `ninja -C out/Debug all`. It's faster to b
uild only the target you're working on, like 'chrome' or 'unit\_tests'. | 30 Specify `out/Release` for a release build. I recommend setting up an alias so |
| 31 that you don't need to type out that build directory path. |
| 32 |
| 33 If you want to build all targets, use `ninja -C out/Debug all`. It's faster to |
| 34 build only the target you're working on, like `chrome` or `unit_tests`. |
28 | 35 |
29 ## Android | 36 ## Android |
30 | 37 |
31 Identical to Linux, just make sure `OS=android` is in your `GYP_DEFINES`. You wa
nt to build one of the _apk targets, e.g. `content_shell_apk`._ | 38 Identical to Linux, just make sure `OS=android` is in your `GYP_DEFINES`. You |
| 39 want to build one of the apk targets, e.g. `content_shell_apk`. |
32 | 40 |
33 ## Windows | 41 ## Windows |
34 | 42 |
35 Similar to Linux. It uses MSVS's `cl.exe`, `link.exe`, etc. so you still need to
have VS installed. To use it, open `cmd.exe`, go to your chrome checkout, and r
un: | 43 Similar to Linux. It uses MSVS's `cl.exe`, `link.exe`, etc. so you still need to |
36 ``` | 44 have VS installed. To use it, open `cmd.exe`, go to your chrome checkout, and |
37 set GYP_DEFINES=component=shared_library | 45 run: |
38 python build\gyp_chromium | |
39 ninja -C out\Debug chrome.exe | |
40 ``` | |
41 | 46 |
42 `component=shared_library` optional but recommended for faster links. | 47 set GYP_DEFINES=component=shared_library |
| 48 python build\gyp_chromium |
| 49 ninja -C out\Debug chrome.exe |
43 | 50 |
44 You can also set `GYP_GENERATORS=ninja,msvs-ninja` to get both VS projects gener
ated if you want to use VS just to browse/edit (but then gyp takes twice as long
to run). | 51 `component=shared_library` is optional but recommended for faster links. |
45 | 52 |
46 If you're using Express or the Windows SDK by itself (rather than using a Visual
Studio install), you'll need to run from a vcvarsall command prompt. | 53 You can also set `GYP_GENERATORS=ninja,msvs-ninja` to get both VS projects |
| 54 generated if you want to use VS just to browse/edit (but then gyp takes twice as |
| 55 long to run). |
| 56 |
| 57 If you're using Express or the Windows SDK by itself (rather than using a Visual |
| 58 Studio install), you'll need to run from a vcvarsall command prompt. |
47 | 59 |
48 ### Debugging | 60 ### Debugging |
49 | 61 |
50 Miss VS for debugging? | 62 Miss VS for debugging? |
| 63 |
51 ``` | 64 ``` |
52 devenv.com /debugexe chrome.exe --my-great-args "go here" --single-process etc | 65 devenv.com /debugexe chrome.exe --my-great-args "go here" --single-process etc |
53 ``` | 66 ``` |
54 | 67 |
55 Miss Xcode for debugging? Read http://dev.chromium.org/developers/debugging-on-o
s-x/building-with-ninja-debugging-with-xcode | 68 Miss Xcode for debugging? Read |
| 69 http://dev.chromium.org/developers/debugging-on-os-x/building-with-ninja-debuggi
ng-with-xcode |
56 | 70 |
57 ### Without Visual Studio | 71 ### Without Visual Studio |
58 | 72 |
59 That is, building with just the WinDDK. This is documented in the [regular build
instructions](http://dev.chromium.org/developers/how-tos/build-instructions-win
dows#TOC-Setting-up-the-environment-for-building-with-Visual-C-2010-Express-or-W
indows-7.1-SDK). | 73 That is, building with just the WinDDK. This is documented in the |
| 74 [regular build instructions](http://dev.chromium.org/developers/how-tos/build-in
structions-windows#TOC-Setting-up-the-environment-for-building-with-Visual-C-201
0-Express-or-Windows-7.1-SDK). |
60 | 75 |
61 ## Tweaks | 76 ## Tweaks |
62 | 77 |
63 ### Building through errors | 78 ### Building through errors |
64 Pass a flag like `-k3` to make Ninja build until it hits three errors instead of
stopping at the first. | 79 |
| 80 Pass a flag like `-k3` to make Ninja build until it hits three errors instead of |
| 81 stopping at the first. |
65 | 82 |
66 ### Parallelism | 83 ### Parallelism |
67 Pass a flag like `-j8` to use 8 parallel processes, or `-j1` to compile just one
at a time (helpful if you're getting weird compiler errors). By default Ninja
tries to use all your processors. | 84 |
| 85 Pass a flag like `-j8` to use 8 parallel processes, or `-j1` to compile just one |
| 86 at a time (helpful if you're getting weird compiler errors). By default Ninja |
| 87 tries to use all your processors. |
68 | 88 |
69 ### More options | 89 ### More options |
| 90 |
70 There are more options. Run `ninja --help` to see them all. | 91 There are more options. Run `ninja --help` to see them all. |
71 | 92 |
72 ### Custom build configs | 93 ### Custom build configs |
73 | 94 |
74 You can write a specific build config to a specific output directory via the `-G
` flags to gyp. Here's an example from jamesr: | 95 You can write a specific build config to a specific output directory via the |
75 `build/gyp_chromium -Gconfig=Release -Goutput_dir=out_profiling -Dprofiling=1 -D
linux_fpic=0` | 96 `-G` flags to gyp. Here's an example from jamesr: |
| 97 `build/gyp_chromium -Gconfig=Release -Goutput_dir=out_profiling -Dprofiling=1 |
| 98 -Dlinux_fpic=0` |
76 | 99 |
77 ## Bugs | 100 ## Bugs |
78 | 101 |
79 If you encounter any problems, please file a bug at http://crbug.com/new with la
bel `ninja` and cc `thakis@` or `scottmg@`. Assume that it is a bug in Ninja be
fore you bother anyone about e.g. link problems. | 102 If you encounter any problems, please file a bug at http://crbug.com/new with |
| 103 label `ninja` and cc `thakis@` or `scottmg@`. Assume that it is a bug in Ninja |
| 104 before you bother anyone about e.g. link problems. |
OLD | NEW |