1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
# The Servo Parallel Browser Engine Project
Servo is a prototype web browser engine written in the
[Rust](https://github.com/rust-lang/rust) language. It is currently developed on
64-bit macOS, 64-bit Linux, 64-bit Windows, and Android.
Servo welcomes contribution from everyone. See
[`CONTRIBUTING.md`](CONTRIBUTING.md) and [`HACKING_QUICKSTART.md`](docs/HACKING_QUICKSTART.md)
for help getting started.
Visit the [Servo Project page](https://servo.org/) for news and guides.
## Build Setup
* [macOS](#macos)
* [Linux](#Linux)
* [Windows](#windows)
* [Android](https://github.com/servo/servo/wiki/Building-for-Android)
If these instructions fail or you would like to install dependencies
manually, try the [manual build setup][manual-build].
### macOS
- Install [Xcode](https://developer.apple.com/xcode/)
- Install [Homebrew](https://brew.sh/)
- Run `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
- Run `pip install virtualenv`
- Run `./mach bootstrap`<br/>
*Note: This will install the recommended version of GStreamer globally on your system.*
### Linux
- Run `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
- Install Python and virtualenv
- **Debian-like:** Run `sudo apt install python3-virtualenv python3-pip`
- **Fedora:** Run `sudo dnf install python3 python3-virtualenv python3-pip python3-devel`
- **Arch:** Run `sudo pacman -S --needed python python-virtualenv python-pip`
- **Gentoo:** Run `sudo emerge dev-python/virtualenv dev-python/pip`
- Run `./mach bootstrap`
### Windows
- Download and run [`rustup-init.exe`](https://win.rustup.rs/) then follow the onscreen instructions.
- Install [chocolatey](https://chocolatey.org/)
- Run `mach bootstrap`
- *This will install CMake, Git, Ninja, Python and the Visual Studio 2019 Build Tools
via choco in an Administrator console. It can take quite a while.*
- *If you already have Visual Studio 2019 installed, this may not install all necessary components.
Please follow the Visual Studio 2019 installation instructions in the [manual setup][manual-build].*
- Run `refreshenv`
See also [Windows Troubleshooting Tips][windows-tips].
### Cloning the Repo
Your CARGO_HOME needs to point to (or be in) the same drive as your Servo repository (See [#28530](https://github.com/servo/servo/issues/28530)).
``` sh
git clone https://github.com/servo/servo
cd servo
```
## Building
Servo is built with [Cargo](https://crates.io/), the Rust package manager.
We also use Mozilla's Mach tools to orchestrate the build and other tasks.
You can call Mach like this:
On Unix systems:
```
./mach [command] [arguments]
```
On Windows Commandline:
```
mach.bat [command] [arguments]
```
The examples below will use Unix, but the same applies to Windows.
### The Rust compiler
Servo's build system uses rustup.rs to automatically download a Rust compiler.
This is a specific version of Rust Nightly determined by the
[`rust-toolchain`](https://github.com/servo/servo/blob/master/rust-toolchain) file.
### Normal build
To build Servo in development mode.
This is useful for development, but the resulting binary is very slow:
``` sh
./mach build --dev
./mach run tests/html/about-mozilla.html
```
### Release build
For benchmarking, performance testing, or real-world use.
Add the `--release` flag to create an optimized build:
``` sh
./mach build --release
./mach run --release tests/html/about-mozilla.html
```
### Checking for build errors, without building
If you’re making changes to one crate that cause build errors in another crate,
consider this instead of a full build:
```sh
./mach check
```
It will run `cargo check`, which runs the analysis phase of the compiler
(and so shows build errors if any) but skips the code generation phase.
This can be a lot faster than a full build,
though of course it doesn’t produce a binary you can run.
### Building for Android target
For ARM (`armv7-linux-androideabi`, most phones):
``` sh
./mach build --release --android
./mach package --release --android
```
For x86 (typically for the emulator):
```sh
./mach build --release --target i686-linux-android
./mach package --release --target i686-linux-android
```
## Running
Run Servo with the command:
```sh
./servo [url] [arguments] # if you run with nightly build
./mach run [url] [arguments] # if you run with mach
# For example
./mach run https://www.google.com
```
### Commandline Arguments
- `-p INTERVAL` turns on the profiler and dumps info to the console every
`INTERVAL` seconds
- `-s SIZE` sets the tile size for painting; defaults to 512
- `-z` disables all graphical output; useful for running JS / layout tests
- `-Z help` displays useful output to debug servo
### Keyboard Shortcuts
- `Ctrl`+`L` opens URL prompt (`Cmd`+`L` on Mac)
- `Ctrl`+`R` reloads current page (`Cmd`+`R` on Mac)
- `Ctrl`+`-` zooms out (`Cmd`+`-` on Mac)
- `Ctrl`+`=` zooms in (`Cmd`+`=` on Mac)
- `Alt`+`left arrow` goes backwards in the history (`Cmd`+`left arrow` on Mac)
- `Alt`+`right arrow` goes forwards in the history (`Cmd`+`right arrow` on Mac)
- `Esc` or `Ctrl`+`Q` exits Servo (`Cmd`+`Q` on Mac)
### Runtime dependencies
#### Linux
* `GStreamer` >=1.16
* `gst-plugins-bad` >=1.16
* `libXcursor`
* `libXrandr`
* `libXi`
* `libxkbcommon`
* `vulkan-loader`
## Developing
There are lots of mach commands you can use. You can list them with `./mach
--help`.
The generated documentation can be found on https://doc.servo.org/servo/index.html
[manual-build]: https://github.com/servo/servo/wiki/Building#manual-build-setup
[windows-tips]: https://github.com/servo/servo/wiki/Building#troubleshooting-the-windows-build
|