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

Unified Diff: build/check_gn_headers.py

Issue 2846593007: Support checking and fixing non-existing header files in GN (Closed)
Patch Set: more naming 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 73f1593ef0889f4ceaea8832e1904d32733b201a..0850196e31b1594e8923e263ae71468794bcba0b 100755
--- a/build/check_gn_headers.py
+++ b/build/check_gn_headers.py
@@ -112,6 +112,18 @@ def ParseWhiteList(whitelist):
return out
+def FilterOutDepsedRepo(files, deps):
+ 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')
@@ -134,11 +146,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
+ nonexisting = 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)
+ nonexisting = FilterOutDepsedRepo(nonexisting, deps)
d_p.join()
gn_p.join()
@@ -149,17 +165,25 @@ def main():
missing -= whitelist
missing = sorted(missing)
+ nonexisting = sorted(nonexisting)
if args.json:
with open(args.json, 'w') as f:
json.dump(missing, f)
- if len(missing) == 0:
+ if len(missing) == 0 and len(nonexisting) == 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(nonexisting) > 0:
+ print '\nThe following non-existing files should be removed from gn files:'
+ for i in nonexisting:
+ 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