HACKING_QUICKSTART: update vscode guide

This commit is contained in:
Delan Azabani 2023-02-15 13:31:04 +08:00
parent d00a78a1c7
commit 7fe42ec8e9

View file

@ -138,23 +138,29 @@ For more details about overriding dependencies, see [Cargo's documentation](http
### Visual Studio Code
Running plain `cargo` will cause problems! This is because the rustflags (flags passed to the rust compiler) that
standard `cargo` provides are different to what `./mach` uses, and so every time Servo is built using `cargo` it will
undo all the work done by `./mach` (and vice versa).
Running plain `cargo` will cause problems! For example, you might get rust-analyzer extension errors
about build scripts like
* The style crate requires enabling one of its 'servo' or 'gecko' feature flags and, in the 'servo'
case, one of 'servo-layout-2013' or 'servo-layout-2020'.
* (if you are on NixOS) thread 'main' panicked at 'called \`Result::unwrap()\` on an \`Err\` value:
"Could not run \`PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=\\"1\\" PKG_CONFIG_ALLOW_SYSTEM_LIBS=\\"1\\"
\\"pkg-config\\" \\"--libs\\" \\"--cflags\\" \\"fontconfig\\"\`
This is because the rustflags (flags passed to the rust compiler) that standard `cargo` provides are
different to what `./mach` uses, and so every time Servo is built using `cargo` it will undo all the
work done by `./mach` (and vice versa).
You can override this in a `.vscode/settings.json` file:
```
{
"rust-analyzer.checkOnSave.overrideCommand": [
"./mach",
"check",
"--message-format=json",
],
"rust-analyzer.rustfmt.overrideCommand": [
"./mach",
"fmt"
],
"rust-analyzer.check.overrideCommand": [
"./mach", "check", "--message-format=json" ],
"rust-analyzer.cargo.buildScripts.overrideCommand": [
"./mach", "check", "--message-format=json" ],
"rust-analyzer.rustfmt.overrideCommand": [ "./mach", "fmt" ],
}
```
@ -164,19 +170,16 @@ the amount of disc space used).
```
{
"rust-analyzer.checkOnSave.overrideCommand": [
"./mach",
"check",
"--message-format=json",
"--target-dir",
"target/lsp"
],
"rust-analyzer.rustfmt.overrideCommand": [
"./mach",
"fmt"
],
"./mach", "check", "--message-format=json", "--target-dir", "target/lsp" ],
"rust-analyzer.cargo.buildScripts.overrideCommand": [
"./mach", "check", "--message-format=json", "--target-dir", "target/lsp" ],
"rust-analyzer.rustfmt.overrideCommand": [ "./mach", "fmt" ],
}
```
If you are on NixOS, these settings should be enough to not need to run `code .` from within a
`nix-shell etc/shell.nix`, but it wouldnt hurt to try that if you still have problems.
## Debugging
### Logging: