OLD | NEW |
1 Mojo | 1 Mojo |
2 ==== | 2 ==== |
3 | 3 |
4 Mojo is an effort to extract a common platform out of Chrome's renderer and plug
in processes that can support multiple types of sandboxed content, such as HTML,
Pepper, or NaCl. | 4 Mojo is an effort to extract a common platform out of Chrome's renderer and |
| 5 plugin processes that can support multiple types of sandboxed content, such as |
| 6 HTML, Pepper, or NaCl. |
5 | 7 |
6 ## Set up your environment | 8 ## Set up your environment |
7 | 9 |
8 The instructions below only need to be done once. Note that a simple "git clone"
command is not sufficient to build the source code because this repo uses the g
client command from depot_tools to manage most third party dependencies. | 10 The instructions below only need to be done once. Note that a simple "git clone" |
| 11 command is not sufficient to build the source code because this repo uses the |
| 12 gclient command from depot_tools to manage most third party dependencies. |
9 | 13 |
10 1. Download depot_tools and make sure it is in your path:<br>http://www.chromium
.org/developers/how-tos/install-depot-tools<br> | 14 1. [Download |
11 | 15 depot_tools](http://www.chromium.org/developers/how-tos/install-depot-tools) |
| 16 and make sure it is in your path. |
12 2. [Googlers only] Install Goma in ~/goma. | 17 2. [Googlers only] Install Goma in ~/goma. |
13 | 18 3. Create a directory somewhere for your checkout (preferably on an SSD), cd |
14 3. Create a directory somewhere for your checkout (preferably on an SSD), cd int
o it, and run the following commands: | 19 into it, and run the following commands: |
15 | 20 |
16 | 21 |
17 ``` | 22 ``` |
18 $ fetch mojo # append --target_os=android to include Android build support. | 23 $ fetch mojo # append --target_os=android to include Android build support. |
19 $ cd src | 24 $ cd src |
20 | 25 |
21 # Or install-build-deps-android.sh if you plan to build for Android. | 26 # Or install-build-deps-android.sh if you plan to build for Android. |
22 $ ./build/install-build-deps.sh | 27 $ ./build/install-build-deps.sh |
23 | 28 |
24 $ mojo/tools/mojob.py gn | 29 $ mojo/tools/mojob.py gn |
25 ``` | 30 ``` |
26 | 31 |
27 The "fetch mojo" command does the following: | 32 The "fetch mojo" command does the following: |
28 - creates a directory called 'src' under your checkout directory | 33 - creates a directory called 'src' under your checkout directory |
29 - clones the repository using git clone | 34 - clones the repository using git clone |
30 - clones dependencies with gclient sync | 35 - clones dependencies with gclient sync |
31 | 36 |
32 `install-build-deps.sh` installs any packages needed to build, then `mojo/tools/
mojob.py gn` runs `gn args` and configures the build directory, out/Debug. | 37 `install-build-deps.sh` installs any packages needed to build, then |
| 38 `mojo/tools/mojob.py gn` runs `gn args` and configures the build directory, |
| 39 out/Debug. |
33 | 40 |
34 If the fetch command fails, you will need to delete the src directory and start
over. | 41 If the fetch command fails, you will need to delete the src directory and start |
| 42 over. |
35 | 43 |
36 ## <a name="buildmojo"></a>Build Mojo | 44 ## <a name="buildmojo"></a>Build Mojo |
37 | 45 |
38 Build Mojo for Linux by running: | 46 Build Mojo for Linux by running: |
39 | 47 |
40 ``` | 48 ``` |
41 $ ninja -C out/Debug -j 10 | 49 $ ninja -C out/Debug -j 10 |
42 ``` | 50 ``` |
43 | 51 |
44 (If you are a Googler, see the section at the end of this document for faster bu
ilds.) | 52 (If you are a Googler, see the section at the end of this document for faster |
| 53 builds.) |
45 | 54 |
46 You can also use the mojob.py script for building. This script automatically cal
ls ninja and sets -j to an appropriate value based on whether Goma is present. Y
ou cannot specify a target name with this script. | 55 You can also use the mojob.py script for building. This script automatically |
| 56 calls ninja and sets -j to an appropriate value based on whether Goma is |
| 57 present. You cannot specify a target name with this script. |
47 ``` | 58 ``` |
48 mojo/tools/mojob.py build | 59 mojo/tools/mojob.py build |
49 ``` | 60 ``` |
50 | 61 |
51 Run a demo: | 62 Run a demo: |
52 ``` | 63 ``` |
53 out/Debug//mojo_shell mojo:spinning_cube | 64 out/Debug//mojo_shell mojo:spinning_cube |
54 ``` | 65 ``` |
55 | 66 |
56 Run the tests: | 67 Run the tests: |
57 ``` | 68 ``` |
58 mojo/tools/mojob.py test | 69 mojo/tools/mojob.py test |
59 ``` | 70 ``` |
60 | 71 |
61 Create a release build: | 72 Create a release build: |
62 ``` | 73 ``` |
63 mojo/tools/mojob.py gn --release | 74 mojo/tools/mojob.py gn --release |
64 mojo/tools/mojob.py build --release | 75 mojo/tools/mojob.py build --release |
65 mojo/tools/mojob.py test --release | 76 mojo/tools/mojob.py test --release |
66 ``` | 77 ``` |
67 | 78 |
68 ## Update your repo | 79 ## Update your repo |
69 | 80 |
70 You can update your repo like this. The order is important. You must do the `git
pull` first because `gclient sync` is dependent on the current revision. | 81 You can update your repo like this. The order is important. You must do the `git |
71 ```YOu | 82 pull` first because `gclient sync` is dependent on the current revision. |
| 83 ``` |
72 # Fetch changes from upstream and rebase the current branch on top | 84 # Fetch changes from upstream and rebase the current branch on top |
73 $ git pull --rebase | 85 $ git pull --rebase |
74 # Update all modules as directed by the DEPS file | 86 # Update all modules as directed by the DEPS file |
75 $ gclient sync | 87 $ gclient sync |
76 ``` | 88 ``` |
77 | 89 |
78 You do not need to rerun `gn gen out/Debug` or `mojo/tools/mojob.py gn`. Ninja w
ill do so automatically as needed. | 90 You do not need to rerun `gn gen out/Debug` or `mojo/tools/mojob.py gn`. Ninja |
| 91 will do so automatically as needed. |
79 | 92 |
80 ## Contribute | 93 ## Contribute |
81 | 94 |
82 With git you should make all your changes in a local branch. Once your change is
committed, you can delete this branch. | 95 With git you should make all your changes in a local branch. Once your change is |
| 96 committed, you can delete this branch. |
83 | 97 |
84 Create a local branch named "mywork" and make changes to it. | 98 Create a local branch named "mywork" and make changes to it. |
85 ``` | 99 ``` |
86 cd src | 100 cd src |
87 git new-branch mywork | 101 git new-branch mywork |
88 vi ... | 102 vi ... |
89 ``` | 103 ``` |
90 Commit your change locally (this doesn't commit your change to the SVN or Git se
rver) | 104 Commit your change locally. (this doesn't commit your change to the SVN or Git |
| 105 server) |
91 | 106 |
92 ``` | 107 ``` |
93 git commit -a | 108 git commit -a |
94 ``` | 109 ``` |
95 | 110 |
96 Fix your source code formatting | 111 Fix your source code formatting. |
97 | 112 |
98 ``` | 113 ``` |
99 $ git cl format | 114 $ git cl format |
100 ``` | 115 ``` |
101 | 116 |
102 Upload your change for review | 117 Upload your change for review. |
103 | 118 |
104 ``` | 119 ``` |
105 $ git cl upload | 120 $ git cl upload |
106 ``` | 121 ``` |
107 | 122 |
108 Respond to review comments | 123 Respond to review comments. |
109 | 124 |
110 See <a href="http://www.chromium.org/developers/contributing-code">Contributing
code</a> for more detailed git instructions, including how to update your CL whe
n you get review comments. There's a short tutorial that might be helpful to try
before your first change: <a href="http://dev.chromium.org/developers/cpp-in-ch
romium-101-codelab">C++ in Chromium 101</a>. | 125 See [Contributing code](http://www.chromium.org/developers/contributing-code) |
| 126 for more detailed git instructions, including how to update your CL when you get |
| 127 review comments. There's a short tutorial that might be helpful to try before |
| 128 making your first change: [C++ in Chromium |
| 129 101](http://dev.chromium.org/developers/cpp-in-chromium-101-codelab). |
111 | 130 |
112 To land a change after receiving LGTM: | 131 To land a change after receiving LGTM: |
113 ``` | 132 ``` |
114 $ git cl land | 133 $ git cl land |
115 ``` | 134 ``` |
116 | 135 |
117 Don't break the build! Waterfall is here: http://build.chromium.org/p/client.moj
o/waterfall | 136 Don't break the build! Waterfall is here: |
| 137 http://build.chromium.org/p/client.mojo/waterfall |
118 | 138 |
119 ## Android Builds | 139 ## Android Builds |
120 | 140 |
121 To build for Android, first make sure you've downloaded build support for Androi
d, which you would have done by adding --target_os=android when you ran `fetch m
ojo`. If you didn't do that, there's an easy fix. Edit the file .gclient in your
root Mojo directory (the parent directory to src.) Add this line at the end of
the file: | 141 To build for Android, first make sure you've downloaded build support for |
| 142 Android, which you would have done by adding `--target_os=android` when you ran |
| 143 `fetch mojo`. If you didn't do that, there's an easy fix. Edit the file .gclient |
| 144 in your root Mojo directory (the parent directory to src.) Add this line at the |
| 145 end of the file: |
122 | 146 |
123 ``` | 147 ``` |
124 target_os = [u'android'] | 148 target_os = [u'android'] |
125 ``` | 149 ``` |
126 | 150 |
127 Bring in android specific build dependencies: | 151 Bring in android specific build dependencies: |
128 ``` | 152 ``` |
129 $ build/install-build-deps-android.sh | 153 $ build/install-build-deps-android.sh |
130 ``` | 154 ``` |
131 | 155 |
(...skipping 13 matching lines...) Expand all Loading... |
145 | 169 |
146 ``` | 170 ``` |
147 $ mojo/tools/mojob.py build --android | 171 $ mojo/tools/mojob.py build --android |
148 ``` | 172 ``` |
149 | 173 |
150 If you see javac compile errors, make sure you have an up-to-date JDK: | 174 If you see javac compile errors, make sure you have an up-to-date JDK: |
151 https://code.google.com/p/chromium/wiki/AndroidBuildInstructions#Install_Java_JD
K | 175 https://code.google.com/p/chromium/wiki/AndroidBuildInstructions#Install_Java_JD
K |
152 | 176 |
153 ## Dart Code | 177 ## Dart Code |
154 | 178 |
155 Because the dart analyzer is a bit slow, we don't run it unless the user specifi
cally asks for it. To run the dart analyzer against the list of dart targets in
the toplevel BUILD.gn file, run: | 179 Because the dart analyzer is a bit slow, we don't run it unless the user |
| 180 specifically asks for it. To run the dart analyzer against the list of dart |
| 181 targets in the toplevel BUILD.gn file, run: |
156 | 182 |
157 ``` | 183 ``` |
158 $ mojo/tools/mojob.py dartcheck | 184 $ mojo/tools/mojob.py dartcheck |
159 ``` | 185 ``` |
160 | 186 |
161 ## Googlers | 187 ## Googlers |
162 | 188 |
163 If you're a Googler, you can use Goma, a distributed compiler service for open-s
ource projects such as Chrome and Android. The instructions below assume that Go
ma is installed in the default location (~/goma). | 189 If you're a Googler, you can use Goma, a distributed compiler service for |
| 190 open-source projects such as Chrome and Android. The instructions below assume |
| 191 that Goma is installed in the default location (~/goma). |
164 | 192 |
165 To enable Goma, update your "args.gn" file. Open the file in your editor with th
is command: | 193 To enable Goma, update your "args.gn" file. Open the file in your editor with |
| 194 this command: |
166 ``` | 195 ``` |
167 $ gn args out/Debug | 196 $ gn args out/Debug |
168 ``` | 197 ``` |
169 | 198 |
170 Add this line to the end of the file: | 199 Add this line to the end of the file: |
171 ``` | 200 ``` |
172 use_goma = true | 201 use_goma = true |
173 ``` | 202 ``` |
174 | 203 |
175 After you close the editor, the "gn args" command will automatically run "gn gen
out/Debug" again. | 204 After you close the editor, the `gn args` command will automatically run `gn gen |
| 205 out/Debug`` again. |
176 | 206 |
177 Now you can dramatically increase the number of parallel tasks: | 207 Now you can dramatically increase the number of parallel tasks: |
178 ``` | 208 ``` |
179 $ ninja -C out/Debug -j 1000 | 209 $ ninja -C out/Debug -j 1000 |
180 ``` | 210 ``` |
181 | 211 |
182 ## Run Mojo Shell | 212 ## Run Mojo Shell |
183 | 213 |
184 ### On Android | 214 ### On Android |
185 | 215 |
186 0. Prerequisites: | 216 0. Prerequisites: |
187 * Before you start, you'll need a device with an unlocked bootloader, otherw
ise you won't be able to run adb root (or any of the commands that require root)
. For Googlers, <a href="http://go/mojo-internal-build-instructions">follow this
link</a> and follow the instructions before returning to this page. | 217 |
188 * Ensure your device is running Lollipop and has an userdebug build. | 218 * Before you start, you'll need a device with an unlocked bootloader, |
189 * Set up environment for building on Android. This sets up the adb path, etc
. You may need to remove /usr/bin/adb. | 219 otherwise you won't be able to run adb root (or any of the commands that |
190 ``` | 220 require root). For Googlers, [follow this |
191 source build/android/envsetup.sh | 221 link](http://go/mojo-internal-build-instructions) and follow the |
192 ``` | 222 instructions before returning to this page. |
| 223 * Ensure your device is running Lollipop and has an userdebug build. |
| 224 * Set up environment for building on Android. This sets up the adb path, |
| 225 etc. You may need to remove /usr/bin/adb. |
| 226 |
| 227 ``` |
| 228 source build/android/envsetup.sh |
| 229 ``` |
193 | 230 |
194 1. Build changed files: | 231 1. Build changed files: |
195 ``` | |
196 mojo/tools/mojob.py build --android | |
197 ``` | |
198 | 232 |
199 2. Run Mojo Shell on the device (this will also push the built apk to the device
): | 233 ``` |
200 ``` | 234 mojo/tools/mojob.py build --android |
201 mojo/tools/mojo_shell.py --android mojo:spinning_cube | 235 ``` |
202 ``` | 236 |
| 237 2. Run Mojo Shell on the device (this will also push the built apk to the |
| 238 device): |
| 239 |
| 240 ``` |
| 241 mojo/tools/mojo_shell.py --android mojo:spinning_cube |
| 242 ``` |
| 243 |
203 If this fails and prints: | 244 If this fails and prints: |
204 ``` | |
205 error: closed | |
206 error: closed | |
207 ``` | |
208 ... then you may not have a new enough build of Android on your device. You need
L (Lollipop) or later. | |
209 | 245 |
210 3. If you get a crash you won't see symbols. Use tools/android_stack_parser/stac
k to map back to symbols, e.g.: | 246 ``` |
211 ``` | 247 error: closed |
212 adb logcat | ./tools/android_stack_parser/stack | 248 error: closed |
213 ``` | 249 ``` |
| 250 |
| 251 ... then you may not have a new enough build of Android on your device. You need |
| 252 L (Lollipop) or later. |
| 253 |
| 254 3. If you get a crash you won't see symbols. Use |
| 255 tools/android_stack_parser/stack to map back to symbols, e.g.: |
| 256 |
| 257 ``` |
| 258 adb logcat | ./tools/android_stack_parser/stack |
| 259 ``` |
214 | 260 |
215 ### On Linux | 261 ### On Linux |
216 | 262 |
217 1. Build the mojo target as described under [link](#buildmojo). | 263 1. Build the mojo target as described under [link](#buildmojo). |
218 | 264 |
219 2. Run Mojo Shell: | 265 2. Run Mojo Shell: |
220 ``` | 266 |
221 ./out/Debug/mojo_shell mojo:spinning_cube | 267 ``` |
222 ``` | 268 ./out/Debug/mojo_shell mojo:spinning_cube |
| 269 ``` |
223 | 270 |
224 3. Optional: Run Mojo Shell with an HTTP server | 271 3. Optional: Run Mojo Shell with an HTTP server |
225 ``` | 272 |
226 cd out/Debug | 273 ``` |
227 python -m SimpleHTTPServer 4444 & | 274 cd out/Debug |
228 ./mojo_shell --origin=http://127.0.0.1:4444 --disable-cache mojo:spinning_cu
be | 275 python -m SimpleHTTPServer 4444 & |
229 ``` | 276 ./mojo_shell --origin=http://127.0.0.1:4444 --disable-cache mojo:spinning_cube |
| 277 ``` |
OLD | NEW |