summaryrefslogtreecommitdiff
path: root/tools/format.py
blob: d1392df4610df9f4a29e58f199629d186ae98e8a (plain)
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
#!/usr/bin/env python

import os
from glob import glob
from util import run

root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

os.chdir(root_path)
# TODO(ry) Install clang-format in third_party.
run(["clang-format", "-i", "-style", "Google"] + glob("src/*.cc") +
    glob("src/*.h"))
for fn in ["BUILD.gn", ".gn"] + glob("build_extra/**/*.gn*"):
    run(["gn", "format", fn])
# TODO(ry) Install yapf in third_party.
run(["yapf", "-i"] + glob("tools/*.py"))
# TODO(ry) Install prettier in third_party.
run([
    "prettier", "--write", "js/deno.d.ts", "js/main.ts", "js/mock_runtime.js",
    "tsconfig.json"
])
# Do not format these.
#  js/msg_generated.ts
#  js/flatbuffers.js
run(["rustfmt", "-f", "--write-mode", "overwrite"] + glob("src/*.rs"))