主要介绍本地如何编译、运行 servo
环境
- win 10 64 位
- 版本号 21H1
-
教训
不要和自己过不去,servo 一定要和 .cargo 在同一个盘符
- 多看看 python/servo/build_commands.py
- 实在搞不定,重启试试,环境变量可能没生效
-
准备工作
rustup 1.8+
- python 3.9+
- pip install virtualenv
- MSVC 安装时选择 complete
- git
visual studio(二选一)
choco
choco install -y visualstudio2019buildtools --package-parameters="--add Microsoft.VisualStudio.Component.Roslyn.Compiler --add Microsoft.Component.MSBuild --add Microsoft.VisualStudio.Component.CoreBuildTools --add Microsoft.VisualStudio.Workload.MSBuildTools --add Microsoft.VisualStudio.Component.Windows10SDK --add Microsoft.VisualStudio.Component.VC.CoreBuildTools --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.VC.Redist.14.Latest --add Microsoft.VisualStudio.Component.VC.ATL --add Microsoft.VisualStudio.Component.VC.ATLMFC --add Microsoft.VisualStudio.Component.TextTemplating --add Microsoft.VisualStudio.Component.VC.CoreIde --add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core --add Microsoft.VisualStudio.Workload.VCTools"
visual studio build tolls 2019(Visual Studio Installer (UI))
开发版本
./mach build --dev./mach run tests/html/about-mozilla.html
发布版本
./mach build --release./mach run --release tests/html/about-mozilla.html
默认 build 会同时构建 servo 和 libsimpleservo,如果想用稍微快一点,可以试试:
./mach build -dev -p servo
构建检查,不进行构建
./mach check
加速构建(build 命令会自动下载并配置)LLVM更快的链接时间
- 添加到环境变量
- 添加到 Cargo config(%USERPROFILE%.cargo\config)
[target.x86_64-pc-windows-msvc]linker = "lld-link.exe"
运行
```bash ./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
<a name="TGBrM"></a>
### 命令行参数
```bash
-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
快捷键
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)
FAQ
- No such file or directory: xx\venv\scripts\nt\python.exe
- python.exe pythonw.exe python.pdb pythonw.pdb 到指定目录
- Exception: Error populating virtualenv.
- 需要设置环境变量 PYTHON3=python.exe
- ModuleNotFoundError: No module named ‘mozversioncontrol’
- cargo 和 servo 不在一个盘符
ERROR: could not find required GStreamer DLL
# gstreamer 安装不完整,缺少以下依赖 gst_dlls: avcodec-58.dll avfilter-7.dll avformat-58.dll avutil-56.dll swresample-3.dll GSTREAMER_PLUGINS: gstlibav.dll # 如下目录也有对应的依赖: C:\Users\xxx\servo\.servo\msvc-dependencies\gstreamer-uwp\1.16.0.5\x64\bin C:\Users\xxx\servo\.servo\msvc-dependencies\gstreamer-uwp\1.16.0.5\x64\lib\gstreamer-1.0尽量不要构建两次,实在需要应该过滤重复的库
waiting mozangle(build) for long time, but no response
- update mozangle 0.2 to 0.3
# components/script/Cargo.toml mozangle = "0.2" # components/servo/Cargo.toml mozangle = {version = "0.3.1", features = ["egl"]}
- update mozangle 0.2 to 0.3
WARNING: could not find libEGL.dll and WARNING: could not find libGLESv2.dll
不影响 build,可以通过修改 package_generated_shared_libraries 返回值忽略
- 原因可能是 mozangle-5109cbb033ab3fb1\out\gfx\angle\checkout\src\libEGL and libGLESv2 没有生成对应的 dll 文件
- 下载 官方每日构建版本,复制 libEGL.dll 和 libGLESv2.dll 到本地 servo_exe_dir 目录
- mach run 报错: assertion failed:
(left != right)复制 libEGL.dll 和 libGLESv2.dll 到 servo_exe_dir 目录
assertion failed: `(left != right)`
left: `0x0`,
right: `0x0` (thread main, at D:\.cargo\registry\src\github.com-1ecc6299db9ec823\surfman-0.4.1\src\platform\windows\angle\device.rs:206)
servo.exe 目录
servo_exe_dir: xx\servo\target\debug
build_path: ${servo_exe_dir}\build ```
