blog
blog copied to clipboard
Servo 快速上手
介绍如何编译、运行、调试 Servo 环境 setup environment to compile, run, debug
- build
-
./mach build -d
-
./mach build -r
-
- run
- servo的二进制在
target/debug/servo
和target/release/servo
目录下 - 可以直接运行二进制,但是更推荐用
./mach
-
./mach run -d -- http://github.com
等价于 -
./target/debug/servo http://github.com
-
- servo的二进制在
-
./mach
-
mach
是一个 python 的 utility- 它做了很多事情,让我们操作起来更轻松,eg.build, run, run tests, update dependencies
- 应用范围:除了编辑文件和操作git之外,其它的事情都是通过
mach
完成的
-
./mach --help
-
./mach run -d [mach options] -- [servo options]
-
--
把 mach options 和 servo options 分开- -- 不必须,但是建议用它。因为 mach 和 servo 有一些同名的选项,eg. --help --debug
-
- 需知晓
- mach commands
./mach --help
- servo options
./mach run -- --help
- mach commands
-
- Rust
- 之前没见过 Rust 也没事,但必须知道一些基本知识
- Match 和 Patterns
- Options
- Expression
- Traits
- 确保知道
println!
如何工作,尤其是 formatting traits
- 之前没见过 Rust 也没事,但必须知道一些基本知识
- Cargo 和 Crates
- 一个 Rust library 就叫 crate
- Servo 用了大量的 crate(依赖项),它们位于
Cargo.toml
这些文件里 - Servo 分为 components 和 ports(有同名文件夹)
-
Cargo.toml
每个文件夹下都有自己的依赖项 -
Cargo.lock
依赖项的特定版本
-
- 若要升级 git
- 正常的 Rust 项目,
cargo update -p std_image
- 但是 Servo 里,
./mach cargo-update -p std_image
- 正常的 Rust 项目,
- 关于 Cargo 及相关的两个文件
- 可 https://doc.rust-lang.org/cargo/guide/
- Working on a Crate
- Servo 依赖了很多 libraries,非常模块化
- 当要调试的时候,就要告诉 cargo 项目,不要使用在线的依赖版本,而是用本地的
[replace]
- 详见:https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html
- Debugging
- Logging: Servo 本身有大量的日志
-
./mach run -d -- --help
-
./mach run -d -- --debug help
-
- println!()
- https://doc.rust-lang.org/std/fmt/#fmtdisplay-vs-fmtdebug
- Debugger
- lldb
- gdb
- Logging: Servo 本身有大量的日志
- Test
- 没有 test 的 PR 不会被合并。均在 tests 目录下
- 更新一个测试
- 新增一个测试
- Documentation
- Ask questions
以上仅为快照,更多详情见 Hacking Quickstart
- Issue: A- C- E-
-
A-parser
-
A-grammar
-
A-frontend
-
E-easy
-
- 前缀
-
A-
Area -
E-
Effort, Experience -
P-
Priority -
O-
Operate system -
S-
Status -
C-
Category -
T-
Team -
WG-
Working Group
-
更多:Tag label names and definitions
Issues: 包括 bugs 和 feature requests 根据 label 和 tag 来找自己感兴趣的话题
Servo Starters. 新手认领任务,Rust / Servo
Servo Starters is a list of easy tasks that are good for beginners to Rust or Servo.
提 PR 的注意事项
- 建个 branch,在提交 PR 之前-可以先重拉下库
- commit 尽可能小,确保每个 commit 是独立的(每个 commit 都应该编译,且通过测试)
- 如需 review 自己的 patch,可以
@
某个人 - 要有测试用例,更多见 https://github.com/servo/servo/wiki/Testing
- DOM,通常是 web platform test
- Layout,通常是 reftest