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

Side by Side Diff: build/check_gn_headers.py

Issue 2925863002: check_gn_headers: use pinned depot_tools (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2017 The Chromium Authors. All rights reserved. 2 # Copyright 2017 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Find header files missing in GN. 6 """Find header files missing in GN.
7 7
8 This script gets all the header files from ninja_deps, which is from the true 8 This script gets all the header files from ninja_deps, which is from the true
9 dependency generated by the compiler, and report if they don't exist in GN. 9 dependency generated by the compiler, and report if they don't exist in GN.
10 """ 10 """
11 11
12 import argparse 12 import argparse
13 import json 13 import json
14 import os 14 import os
15 import re 15 import re
16 import shutil 16 import shutil
17 import subprocess 17 import subprocess
18 import sys 18 import sys
19 import tempfile 19 import tempfile
20 from multiprocessing import Process, Queue 20 from multiprocessing import Process, Queue
21 21
22 SRC_DIR = os.path.abspath(
23 os.path.join(os.path.abspath(os.path.dirname(__file__)), os.path.pardir))
24 DEPOT_TOOLS_DIR = os.path.join(SRC_DIR, 'depot_tools')
Dirk Pranke 2017/06/07 01:29:53 This needs to be os.path.join(SRC_DIR, 'third_part
25
22 26
23 def GetHeadersFromNinja(out_dir, q): 27 def GetHeadersFromNinja(out_dir, q):
24 """Return all the header files from ninja_deps""" 28 """Return all the header files from ninja_deps"""
25 29
26 def NinjaSource(): 30 def NinjaSource():
27 cmd = ['ninja', '-C', out_dir, '-t', 'deps'] 31 cmd = [os.path.join(DEPOT_TOOLS_DIR, 'ninja'), '-C', out_dir, '-t', 'deps']
wychen 2017/06/07 01:27:03 I don't have src/depot_tools in my checkout. Is th
Dirk Pranke 2017/06/07 01:29:53 Good catch, see comment above.
wychen 2017/06/07 01:32:20 Ah. I haven't updated to https://chromium-review.g
28 # A negative bufsize means to use the system default, which usually 32 # A negative bufsize means to use the system default, which usually
29 # means fully buffered. 33 # means fully buffered.
30 popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, bufsize=-1) 34 popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, bufsize=-1)
31 for line in iter(popen.stdout.readline, ''): 35 for line in iter(popen.stdout.readline, ''):
32 yield line.rstrip() 36 yield line.rstrip()
33 37
34 popen.stdout.close() 38 popen.stdout.close()
35 return_code = popen.wait() 39 return_code = popen.wait()
36 if return_code: 40 if return_code:
37 raise subprocess.CalledProcessError(return_code, cmd) 41 raise subprocess.CalledProcessError(return_code, cmd)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 def GetHeadersFromGN(out_dir, q): 79 def GetHeadersFromGN(out_dir, q):
76 """Return all the header files from GN""" 80 """Return all the header files from GN"""
77 81
78 tmp = None 82 tmp = None
79 ans, err = set(), None 83 ans, err = set(), None
80 try: 84 try:
81 tmp = tempfile.mkdtemp() 85 tmp = tempfile.mkdtemp()
82 shutil.copy2(os.path.join(out_dir, 'args.gn'), 86 shutil.copy2(os.path.join(out_dir, 'args.gn'),
83 os.path.join(tmp, 'args.gn')) 87 os.path.join(tmp, 'args.gn'))
84 # Do "gn gen" in a temp dir to prevent dirtying |out_dir|. 88 # Do "gn gen" in a temp dir to prevent dirtying |out_dir|.
85 subprocess.check_call(['gn', 'gen', tmp, '--ide=json', '-q']) 89 subprocess.check_call([
90 os.path.join(DEPOT_TOOLS_DIR, 'gn'), 'gen', tmp, '--ide=json', '-q'])
86 gn_json = json.load(open(os.path.join(tmp, 'project.json'))) 91 gn_json = json.load(open(os.path.join(tmp, 'project.json')))
87 ans = ParseGNProjectJSON(gn_json, out_dir, tmp) 92 ans = ParseGNProjectJSON(gn_json, out_dir, tmp)
88 except Exception as e: 93 except Exception as e:
89 err = str(e) 94 err = str(e)
90 finally: 95 finally:
91 if tmp: 96 if tmp:
92 shutil.rmtree(tmp) 97 shutil.rmtree(tmp)
93 q.put((ans, err)) 98 q.put((ans, err))
94 99
95 100
(...skipping 15 matching lines...) Expand all
111 f = out_dir + f[len(tmp_out):] 116 f = out_dir + f[len(tmp_out):]
112 all_headers.add(f) 117 all_headers.add(f)
113 118
114 return all_headers 119 return all_headers
115 120
116 121
117 def GetDepsPrefixes(q): 122 def GetDepsPrefixes(q):
118 """Return all the folders controlled by DEPS file""" 123 """Return all the folders controlled by DEPS file"""
119 prefixes, err = set(), None 124 prefixes, err = set(), None
120 try: 125 try:
121 gclient_out = subprocess.check_output( 126 gclient_out = subprocess.check_output([
122 ['gclient', 'recurse', '--no-progress', '-j1', 127 os.path.join(DEPOT_TOOLS_DIR, 'gclient'),
123 'python', '-c', 'import os;print os.environ["GCLIENT_DEP_PATH"]']) 128 'recurse', '--no-progress', '-j1',
129 'python', '-c', 'import os;print os.environ["GCLIENT_DEP_PATH"]'])
124 for i in gclient_out.split('\n'): 130 for i in gclient_out.split('\n'):
125 if i.startswith('src/'): 131 if i.startswith('src/'):
126 i = i[4:] 132 i = i[4:]
127 prefixes.add(i) 133 prefixes.add(i)
128 except Exception as e: 134 except Exception as e:
129 err = str(e) 135 err = str(e)
130 q.put((prefixes, err)) 136 q.put((prefixes, err))
131 137
132 138
133 def IsBuildClean(out_dir): 139 def IsBuildClean(out_dir):
134 cmd = ['ninja', '-C', out_dir, '-n'] 140 cmd = [os.path.join(DEPOT_TOOLS_DIR, 'ninja'), '-C', out_dir, '-n']
135 out = subprocess.check_output(cmd) 141 out = subprocess.check_output(cmd)
136 return 'no work to do.' in out 142 return 'no work to do.' in out
137 143
138 144
139 def ParseWhiteList(whitelist): 145 def ParseWhiteList(whitelist):
140 out = set() 146 out = set()
141 for line in whitelist.split('\n'): 147 for line in whitelist.split('\n'):
142 line = re.sub(r'#.*', '', line).strip() 148 line = re.sub(r'#.*', '', line).strip()
143 if line: 149 if line:
144 out.add(line) 150 out.add(line)
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 if len(nonexisting) > 0: 264 if len(nonexisting) > 0:
259 print '\nThe following non-existing files should be removed from gn files:' 265 print '\nThe following non-existing files should be removed from gn files:'
260 for i in nonexisting: 266 for i in nonexisting:
261 print i 267 print i
262 268
263 return 1 269 return 1
264 270
265 271
266 if __name__ == '__main__': 272 if __name__ == '__main__':
267 sys.exit(main()) 273 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698