OLD | NEW |
(Empty) | |
| 1 # What is it? |
| 2 |
| 3 Cr is the new unified interface to the myriad tools we use while working within
a chromium checkout. |
| 4 Its main additional feature is that it allows you to build many configurations a
nd run targets within a single checkout (by not relying on a directory called 'o
ut'). |
| 5 This is especially important when you want to cross-compile (for instance, build
ing android from linux or building arm from intel), but it extends to any build
variation. |
| 6 |
| 7 ## A quick example |
| 8 |
| 9 The following is all you need to prepare an output directory, and then build and
run the release build of chrome for the host platform: |
| 10 ``` |
| 11 cr init |
| 12 cr run |
| 13 ``` |
| 14 |
| 15 # How do I get it? |
| 16 |
| 17 You already have it, it lives in `src/tools/cr` |
| 18 |
| 19 You can run the cr.py file by hand, but if you are using bash it is much easier
to source the bash helpers. |
| 20 This will add a cr function to your bash shell that runs with pyc generation tur
ned off, and also installs the bash tab completion handler (which is very primit
ive at the moment, it only completes the command not the options) |
| 21 It also adds a function you can use in your prompt to tell you your selected bui
ld (`_cr_ps1`), and an helper to return you to the root of your active tree (`cr
cd`). |
| 22 I recommend you add the following lines to the end of your ~/.bashrc (with a mor
e correct path) |
| 23 ``` |
| 24 CR_CLIENT_PATH="/path/to/chromium" |
| 25 source ${CR_CLIENT_PATH}/src/tools/cr/cr-bash-helpers.sh |
| 26 ``` |
| 27 At that point the cr command is available to you. |
| 28 |
| 29 # How do I use it? |
| 30 |
| 31 It should be mostly self documenting |
| 32 ``` |
| 33 cr --help |
| 34 ``` |
| 35 will list all the commands installed |
| 36 ``` |
| 37 cr --help command |
| 38 ``` |
| 39 will give you more detailed help for a specific command. |
| 40 |
| 41 > _**A note to existing android developers:**_ |
| 42 > Do not source envsetup! ever! |
| 43 > If you use cr in a shell that has had envsetup sourced, miscellaneous things w
ill be broken. The cr tool does all the work that envsetup used to do in a way t
hat does not pollute your current shell. |
| 44 > If you really need a shell that has had the environment modified like envsetup
used to do, see the cr shell command, also probably file a bug for a missing cr
feature! |
| 45 |
| 46 # The commands |
| 47 |
| 48 Below are some common workflows, but first there is a quick overview of the comm
ands currently in the system. |
| 49 |
| 50 ## Output directory commands |
| 51 |
| 52 init |
| 53 > Create and configure an output directory. Also runs select to make it the defa
ult. |
| 54 select |
| 55 > Select an output directory. This makes it the default output for all commands,
so you can omit the --out option if you want to. |
| 56 prepare |
| 57 > Prepares an output directory. This runs any preparation steps needed for an ou
tput directory to be viable, which at the moment means run gyp. |
| 58 |
| 59 ## Build commands |
| 60 |
| 61 build |
| 62 > Build a target. |
| 63 install |
| 64 > Install a binary. Does build first unless `--builder==skip` |
| 65 > This does nothing on linux, and installs the apk onto the device for android b
uilds. |
| 66 run |
| 67 > Invoke a target. Does an install first, unless `--installer=skip`. |
| 68 debug |
| 69 > Debug a target. Does a run first, unless `--runner=skip`. Uses the debugger sp
ecified by `--debugger`. |
| 70 |
| 71 ## Other commands |
| 72 |
| 73 sync |
| 74 > Sync the source tree. Uses gclient sync to do the real work. |
| 75 shell |
| 76 > Run an exernal command in a cr environment. |
| 77 > This is an escape hatch, if passed a command it runs it in the correct environ
ment for the current output directory, otherwise it starts a sub shell with that
environment. This allows you to run any commands that don't have shims, or are
too specialized to get one. This is especially important on android where the en
vironment is heavily modified. |
| 78 |
| 79 # Preparing to build |
| 80 |
| 81 The first thing you need to do is prepare an output directory to build into. |
| 82 You do this with: |
| 83 ``` |
| 84 cr init |
| 85 ``` |
| 86 By default on linux this will prepare a linux x86 release build output directory
, called out\_linux/Release, if you want an android debug one, you can use: |
| 87 ``` |
| 88 cr init --out=out_android/Debug |
| 89 ``` |
| 90 The output directory can be called anything you like, but if you pick a non stan
dard name cr might not be able to infer the platform, in which case you need to
specify it. |
| 91 The second part **must** be either Release or Debug. |
| 92 All options can be shortened to the shortest non ambiguous prefix, so the short
command line to prepare an android debug output directory in out is: |
| 93 ``` |
| 94 cr init --o=out/Debug --p=android |
| 95 ``` |
| 96 It is totally safe to do this in an existing output directory, and is an easy wa
y to migrate an existing output directory to use in cr if you don't want to star
t from scratch. |
| 97 |
| 98 Most commands in cr take a --out parameter to tell them which output directory y
ou want to operate on, but it will default to the last value passed to init or s
elect. |
| 99 This enables you to omit it from most commands. |
| 100 |
| 101 Both init and select do additional work to prepare the output directory, which i
nclude things like running gyp. You can do that work on it's own with the prepar
e command if you want, something you need to do when changing between branches w
here you have modified the build files. |
| 102 |
| 103 If you want to set custom GYP defines for your build you can do this by adding a
dding the -s GYP\_DEFINES argument, for example: |
| 104 ``` |
| 105 cr init --o=out/Debug -s GYP_DEFINES=component=shared_library |
| 106 ``` |
| 107 |
| 108 # Running chrome |
| 109 |
| 110 If you just want to do a basic build and run, then you do |
| 111 ``` |
| 112 cr run |
| 113 ``` |
| 114 which will build, install if necessary, and run chrome, with some default args t
o open on https://www.google.com/. |
| 115 The same command line will work for any supported platform and mode. |
| 116 If you want to just run it again, you can turn off the build and install steps, |
| 117 ``` |
| 118 cr run --installer=skip |
| 119 ``` |
| 120 note that turning off install automatically turns off build (which you could do
with `--builder=skip`) as there is no point building if you are not going to ins
tall. |
| 121 |
| 122 |
| 123 # Debugging chrome |
| 124 |
| 125 To start chrome under a debugger you use |
| 126 ``` |
| 127 cr debug |
| 128 ``` |
| 129 which will build, install, and run chrome, and attach a debugger to it. This wor
ks on any supported platform, and if multiple debuggers are available, you can s
elect which one you want with `--debugger=my_debugger` |
| 130 |
| 131 # Help, it went wrong! |
| 132 |
| 133 There are a few things to do, and you should probably do all of them. |
| 134 Run your commands with dry-run and/or verbose turned on to see what the tool is
really doing, for instance |
| 135 ``` |
| 136 cr --d -vvvv init |
| 137 ``` |
| 138 The number of v's matter, it's the verbosity level, you can also just specify th
e value with -v=4 if you would rather. |
| 139 |
| 140 [Report a bug](https://code.google.com/p/chromium/issues/entry?comment=%3CDont%2
0forget%20to%20attach%20the%20command%20lines%20used%20with%20-v=4%20if%20possib
le%3E&pri=2&labels=OS-Android,tool-cr,Build-Tools,Type-Bug&owner=iancottrell@chr
omium.org&status=Assigned), even if it is just something that confused or annoye
d rather than broke, we want this tool to be very low friction for developers. |
| 141 |
| 142 # Known issues |
| 143 |
| 144 You can see the full list of issues with [this](https://code.google.com/p/chromi
um/issues/list?can=2&q=label%3Atool-cr) query, but here are the high level issue
s: |
| 145 |
| 146 * **Only supports gtest** : You run tests using the run command, which tries t
o infer from the target whether it is a runnable binary or a test. The inference
could be improved, and it needs to handle the other test types as well. |
| 147 * **No support for windows or mac** : allowed for in the design, but need peop
le with expertise on those platforms to help out |
| 148 * **Bash completion** : The hooks for it are there, but at the moment it only
ever completes the command, not any of the arguments |
OLD | NEW |