mirror of
https://github.com/servo/servo.git
synced 2025-06-08 08:33:26 +00:00
mach: Speed up taplo
runs on MacOS (#31452)
`taplo` is the TOML formatter that we use. It seems to be using a very slow directory walking mechanism on MacOS. This change works around that issue by explicitly listing globs of TOML files to format and check. Before: ```text real 0m17.632s user 0m2.164s sys 0m6.916s ``` After: ```text real 0m1.519s user 0m1.391s sys 0m0.112s ```
This commit is contained in:
parent
9a9abe9152
commit
6eb96290fa
1 changed files with 14 additions and 2 deletions
|
@ -48,6 +48,18 @@ UNSTABLE_RUSTFMT_ARGUMENTS = [
|
|||
"--config", "group_imports=StdExternalCrate",
|
||||
]
|
||||
|
||||
# Listing these globs manually is a work-around for very slow `taplo` invocation
|
||||
# on MacOS machines. If `taplo` runs fast without the globs on MacOS, this
|
||||
# can be removed.
|
||||
TOML_GLOBS = [
|
||||
"*.toml",
|
||||
".cargo/*.toml",
|
||||
"components/*/*.toml",
|
||||
"components/shared/*.toml",
|
||||
"ports/*/*.toml",
|
||||
"support/*/*.toml",
|
||||
]
|
||||
|
||||
|
||||
def format_toml_files_with_taplo(check_only: bool = True) -> int:
|
||||
taplo = shutil.which("taplo")
|
||||
|
@ -56,9 +68,9 @@ def format_toml_files_with_taplo(check_only: bool = True) -> int:
|
|||
return 1
|
||||
|
||||
if check_only:
|
||||
return call([taplo, "fmt", "--check"], env={'RUST_LOG': 'error'})
|
||||
return call([taplo, "fmt", "--check", *TOML_GLOBS], env={'RUST_LOG': 'error'})
|
||||
else:
|
||||
return call([taplo, "fmt"], env={'RUST_LOG': 'error'})
|
||||
return call([taplo, "fmt", *TOML_GLOBS], env={'RUST_LOG': 'error'})
|
||||
|
||||
|
||||
@CommandProvider
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue