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

Unified Diff: build/check_gn_headers.py

Issue 2914323002: Make check_gn_headers.py run on Windows (Closed)
Patch Set: Created 3 years, 7 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 | no next file » | 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 fe884db6cb0b8e8253d5be3ac91d59d1c4290211..f3953704d95e1b69acb06e998a9e6542879d073d 100755
--- a/build/check_gn_headers.py
+++ b/build/check_gn_headers.py
@@ -48,7 +48,8 @@ def ParseNinjaDepsOutput(ninja_out):
"""Parse ninja output and get the header files"""
all_headers = set()
- prefix = '..' + os.sep + '..' + os.sep
+ # Ninja always use "/", even on Windows.
brucedawson 2017/06/12 17:38:40 use-> uses
wychen 2017/06/12 21:45:45 Done.
+ prefix = '../../'
is_valid = False
for line in ninja_out:
@@ -76,11 +77,14 @@ def GetHeadersFromGN(out_dir, q):
tmp = None
ans, err = set(), None
try:
- tmp = tempfile.mkdtemp()
+ # Argument |dir| is needed to make sure it's on the same drive on Windows.
+ # dir='' means dir='.', but doesn't introduce an unneeded prefix.
+ tmp = tempfile.mkdtemp(dir='')
shutil.copy2(os.path.join(out_dir, 'args.gn'),
os.path.join(tmp, 'args.gn'))
# Do "gn gen" in a temp dir to prevent dirtying |out_dir|.
- subprocess.check_call(['gn', 'gen', tmp, '--ide=json', '-q'])
+ GN_EXE = 'gn.bat' if sys.platform == 'win32' else 'gn'
brucedawson 2017/06/12 17:38:40 Why upper-case for GN_EXE and GCLIENT_EXE? Doesn't
wychen 2017/06/12 21:45:45 Done.
+ subprocess.check_call([GN_EXE, 'gen', tmp, '--ide=json', '-q'])
gn_json = json.load(open(os.path.join(tmp, 'project.json')))
ans = ParseGNProjectJSON(gn_json, out_dir, tmp)
except Exception as e:
@@ -116,9 +120,11 @@ def GetDepsPrefixes(q):
"""Return all the folders controlled by DEPS file"""
prefixes, err = set(), None
try:
+ GCLIENT_EXE = 'gclient.bat' if sys.platform == 'win32' else 'gclient'
gclient_out = subprocess.check_output(
- ['gclient', 'recurse', '--no-progress', '-j1',
- 'python', '-c', 'import os;print os.environ["GCLIENT_DEP_PATH"]'])
+ [GCLIENT_EXE, 'recurse', '--no-progress', '-j1',
+ 'python', '-c', 'import os;print os.environ["GCLIENT_DEP_PATH"]'],
+ universal_newlines = True)
for i in gclient_out.split('\n'):
if i.startswith('src/'):
i = i[4:]
« 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