mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
Fix recursive globbing in tools/format.py
And use third_party/depot_tools/gn.
This commit is contained in:
parent
1de16af1f3
commit
7baf8a0fd1
2 changed files with 27 additions and 12 deletions
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
from glob import glob
|
||||
from util import run
|
||||
from util import run, find_exts
|
||||
|
||||
root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
||||
third_party_path = os.path.join(root_path, "third_party")
|
||||
|
@ -12,15 +10,19 @@ tools_path = os.path.join(root_path, "tools")
|
|||
rustfmt_config = os.path.join(tools_path, "rustfmt.toml")
|
||||
|
||||
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) Use third_party/depot_tools/clang-format.
|
||||
run(["clang-format", "-i", "-style", "Google"] + find_exts("src", ".cc", ".h"))
|
||||
|
||||
for fn in ["BUILD.gn", ".gn"] + find_exts("build_extra", ".gn", ".gni"):
|
||||
run(["third_party/depot_tools/gn", "format", fn])
|
||||
|
||||
# TODO(ry) Install yapf in third_party.
|
||||
run(["yapf", "-i"] + glob("tools/*.py") + glob("build_extra/**/*.py"))
|
||||
run(["node", prettier, "--write"] + glob("js/*.js") + glob("js/*.ts") +
|
||||
["tsconfig.json"] + ["tslint.json"])
|
||||
run(["yapf", "-i"] + find_exts("tools/", ".py") +
|
||||
find_exts("build_extra", ".py"))
|
||||
|
||||
run(["node", prettier, "--write"] + find_exts("js/", ".js", ".ts") +
|
||||
["tsconfig.json", "tslint.json"])
|
||||
|
||||
# Set RUSTFMT_FLAGS for extra flags.
|
||||
rustfmt_extra_args = []
|
||||
|
@ -29,4 +31,4 @@ if 'RUSTFMT_FLAGS' in os.environ:
|
|||
run([
|
||||
"rustfmt", "--config-path", rustfmt_config, "--error-on-unformatted",
|
||||
"--write-mode", "overwrite"
|
||||
] + rustfmt_extra_args + glob("src/*.rs"))
|
||||
] + rustfmt_extra_args + find_exts("src/", ".rs"))
|
||||
|
|
|
@ -55,3 +55,16 @@ def touch(fname):
|
|||
os.utime(fname, None)
|
||||
else:
|
||||
open(fname, 'a').close()
|
||||
|
||||
|
||||
# Recursive search for files of certain extensions.
|
||||
# (Recursive glob doesn't exist in python 2.7.)
|
||||
def find_exts(directory, *extensions):
|
||||
matches = []
|
||||
for root, dirnames, filenames in os.walk(directory):
|
||||
for filename in filenames:
|
||||
for ext in extensions:
|
||||
if filename.endswith(ext):
|
||||
matches.append(os.path.join(root, filename))
|
||||
break
|
||||
return matches
|
||||
|
|
Loading…
Reference in a new issue