summaryrefslogtreecommitdiff
path: root/build/fix_gn_headers.py
diff options
context:
space:
mode:
authorCole Faust <colefaust@google.com>2024-03-15 11:47:33 -0700
committerCole Faust <colefaust@google.com>2024-03-15 11:54:54 -0700
commit0d2fef2d6dc74ffd5429c435f87213d1167105c9 (patch)
tree19920fa3df6f81b120737c503bf60cf7aa2570ea /build/fix_gn_headers.py
parent67a099d7ad12d762da5f50e3904475fa1ff6be69 (diff)
downloadlibchrome-0d2fef2d6dc74ffd5429c435f87213d1167105c9.tar.gz
Add embedded_launcher: true to jni_generator
The jni_generator writes the path to the script into its output files. When using a non-embedded-launcher soong python binary, soong will extract the binary to a nondeterministic temporary directory before running it. These two points together means that the output files of jni_generator are non-deterministic. Adding embedded_launcher: true causes all the python sources to be precompiled as well, so we start getting syntax errors for code paths that are still in python2 but we weren't running before. Fix those syntax errors. Test: Presubmits Change-Id: I0a856f8cc98b11841c07bd6188d9722980428b5f
Diffstat (limited to 'build/fix_gn_headers.py')
-rwxr-xr-xbuild/fix_gn_headers.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/build/fix_gn_headers.py b/build/fix_gn_headers.py
index 01ff764e06..65b93f6dda 100755
--- a/build/fix_gn_headers.py
+++ b/build/fix_gn_headers.py
@@ -39,7 +39,7 @@ def ValidMatches(basename, cc, grep_lines):
continue
if lines[linenr - 2] == new:
continue
- print ' ', gnfile, linenr, new
+ print(' ', gnfile, linenr, new)
matches.append((gnfile, linenr, new))
return matches
@@ -59,7 +59,7 @@ def AddHeadersNextToCC(headers, skip_ambiguous=True):
if not (filename.endswith('.h') or filename.endswith('.hh')):
continue
basename = os.path.basename(filename)
- print filename
+ print(filename)
cc = r'\b' + os.path.splitext(basename)[0] + r'\.(cc|cpp|mm)\b'
out, returncode = GitGrep('(/|")' + cc + '"')
if returncode != 0 or not out:
@@ -71,9 +71,9 @@ def AddHeadersNextToCC(headers, skip_ambiguous=True):
if len(matches) == 0:
continue
if len(matches) > 1:
- print '\n[WARNING] Ambiguous matching for', filename
+ print('\n[WARNING] Ambiguous matching for', filename)
for i in enumerate(matches, 1):
- print '%d: %s' % (i[0], i[1])
+ print('%d: %s' % (i[0], i[1]))
print
if skip_ambiguous:
continue
@@ -86,7 +86,7 @@ def AddHeadersNextToCC(headers, skip_ambiguous=True):
for match in matches:
gnfile, linenr, new = match
- print ' ', gnfile, linenr, new
+ print(' ', gnfile, linenr, new)
edits.setdefault(gnfile, {})[linenr] = new
for gnfile in edits:
@@ -111,7 +111,7 @@ def AddHeadersToSources(headers, skip_ambiguous=True):
"""
for filename in headers:
filename = filename.strip()
- print filename
+ print(filename)
dirname = os.path.dirname(filename)
while not os.path.exists(os.path.join(dirname, 'BUILD.gn')):
dirname = os.path.dirname(dirname)
@@ -121,12 +121,12 @@ def AddHeadersToSources(headers, skip_ambiguous=True):
lines = open(gnfile).read().splitlines()
matched = [i for i, l in enumerate(lines) if ' sources = [' in l]
if skip_ambiguous and len(matched) > 1:
- print '[WARNING] Multiple sources in', gnfile
+ print('[WARNING] Multiple sources in', gnfile)
continue
if len(matched) < 1:
continue
- print ' ', gnfile, rel
+ print(' ', gnfile, rel)
index = matched[0]
lines.insert(index + 1, '"%s",' % rel)
open(gnfile, 'w').write('\n'.join(lines) + '\n')
@@ -144,18 +144,18 @@ def RemoveHeader(headers, skip_ambiguous=True):
if not (filename.endswith('.h') or filename.endswith('.hh')):
continue
basename = os.path.basename(filename)
- print filename
+ print(filename)
out, returncode = GitGrep('(/|")' + basename + '"')
if returncode != 0 or not out:
unhandled.append(filename)
- print ' Not found'
+ print(' Not found')
continue
grep_lines = out.splitlines()
matches = []
for line in grep_lines:
gnfile, linenr, contents = line.split(':')
- print ' ', gnfile, linenr, contents
+ print(' ', gnfile, linenr, contents)
linenr = int(linenr)
lines = open(gnfile).read().splitlines()
assert contents in lines[linenr - 1]
@@ -164,9 +164,9 @@ def RemoveHeader(headers, skip_ambiguous=True):
if len(matches) == 0:
continue
if len(matches) > 1:
- print '\n[WARNING] Ambiguous matching for', filename
+ print('\n[WARNING] Ambiguous matching for', filename)
for i in enumerate(matches, 1):
- print '%d: %s' % (i[0], i[1])
+ print('%d: %s' % (i[0], i[1]))
print
if skip_ambiguous:
continue
@@ -179,7 +179,7 @@ def RemoveHeader(headers, skip_ambiguous=True):
for match in matches:
gnfile, linenr, contents = match
- print ' ', gnfile, linenr, contents
+ print(' ', gnfile, linenr, contents)
edits.setdefault(gnfile, set()).add(linenr)
for gnfile in edits: