Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3385)

Unified Diff: build/check_gn_headers.py

Issue 2846593007: Support checking and fixing non-existing header files in GN (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/fix_gn_headers.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/check_gn_headers.py
diff --git a/build/check_gn_headers.py b/build/check_gn_headers.py
index be1e797a77e381623735d75de356268279721fa9..71f394805117c83eb83446858b0e87dcda8e4d56 100755
--- a/build/check_gn_headers.py
+++ b/build/check_gn_headers.py
@@ -107,6 +107,18 @@ def ParseWhiteList(whitelist):
return out
+def FilterOutDepsedRepo(files, deps):
Nico 2017/04/28 20:31:19 a) isn't this slow? i would've thought that deps h
wychen 2017/04/28 22:04:43 This is asymptotically slow, but only takes <0.1se
+ return {f for f in files if not any(f.startswith(d) for d in deps)}
+
+
+def GetNonExistingFiles(lst):
+ out = set()
+ for f in lst:
+ if not os.path.isfile(f):
+ out.add(f)
+ return out
+
+
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--out-dir', default='out/Release')
@@ -129,11 +141,15 @@ def main():
deps_p.start()
d = d_q.get()
+ assert len(GetNonExistingFiles(d)) == 0, \
+ 'Found non-existing files in ninja deps'
gn = gn_q.get()
missing = d - gn
+ extra = GetNonExistingFiles(gn)
deps = deps_q.get()
- missing = {m for m in missing if not any(m.startswith(d) for d in deps)}
+ missing = FilterOutDepsedRepo(missing, deps)
+ extra = FilterOutDepsedRepo(extra, deps)
d_p.join()
gn_p.join()
@@ -144,17 +160,25 @@ def main():
missing -= whitelist
missing = sorted(missing)
+ extra = sorted(extra)
if args.json:
with open(args.json, 'w') as f:
json.dump(missing, f)
- if len(missing) == 0:
+ if len(missing) == 0 and len(extra) == 0:
return 0
- print 'The following files should be included in gn files:'
- for i in missing:
- print i
+ if len(missing) > 0:
+ print '\nThe following files should be included in gn files:'
+ for i in missing:
+ print i
+
+ if len(extra) > 0:
+ print '\nThe following files should be removed from gn files:'
+ for i in extra:
+ print i
+
return 1
« no previous file with comments | « no previous file | build/fix_gn_headers.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698