Skip to content

Commit d7d4239

Browse files
vontureCommit Bot
authored andcommitted
Format all of ANGLE's python code.
BUG=angleproject:3421 Change-Id: I1d7282ac513c046de5d8ed87f7789290780d30a6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1595440 Reviewed-by: Jamie Madill <[email protected]> Commit-Queue: Geoff Lang <[email protected]>
1 parent 8ba78da commit d7d4239

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1363
-1134
lines changed

.style.yapf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[style]
22
based_on_style = chromium
3-
column_limit = 99
3+
column_limit = 99
4+
indent_width = 4

PRESUBMIT.py

Lines changed: 51 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Copyright 2019 The ANGLE Project Authors. All rights reserved.
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
4-
54
"""Top-level presubmit script for code generation.
65
76
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
@@ -10,101 +9,93 @@
109

1110
from subprocess import call
1211

13-
1412
# Fragment of a regular expression that matches C++ and Objective-C++ implementation files.
1513
_IMPLEMENTATION_EXTENSIONS = r'\.(cc|cpp|cxx|mm)$'
1614

17-
1815
# Fragment of a regular expression that matches C++ and Objective-C++ header files.
1916
_HEADER_EXTENSIONS = r'\.(h|hpp|hxx)$'
2017

2118

2219
def _CheckCodeGeneration(input_api, output_api):
2320

2421
class Msg(output_api.PresubmitError):
25-
"""Specialized error message"""
26-
def __init__(self, message):
27-
super(output_api.PresubmitError, self).__init__(message,
28-
long_text='Please ensure your ANGLE repositiory is synced to tip-of-tree\n'
29-
'and you have an up-to-date checkout of all ANGLE dependencies.\n'
30-
'If you are using ANGLE inside Chromium you may need to bootstrap ANGLE \n'
31-
'and run gclient sync. See the DevSetup documentation for details.\n')
22+
"""Specialized error message"""
23+
24+
def __init__(self, message):
25+
super(output_api.PresubmitError, self).__init__(
26+
message,
27+
long_text='Please ensure your ANGLE repositiory is synced to tip-of-tree\n'
28+
'and you have an up-to-date checkout of all ANGLE dependencies.\n'
29+
'If you are using ANGLE inside Chromium you may need to bootstrap ANGLE \n'
30+
'and run gclient sync. See the DevSetup documentation for details.\n')
3231

3332
code_gen_path = input_api.os_path.join(input_api.PresubmitLocalPath(),
3433
'scripts/run_code_generation.py')
3534
cmd_name = 'run_code_generation'
3635
cmd = [input_api.python_executable, code_gen_path, '--verify-no-dirty']
37-
test_cmd = input_api.Command(
38-
name=cmd_name,
39-
cmd=cmd,
40-
kwargs={},
41-
message=Msg)
36+
test_cmd = input_api.Command(name=cmd_name, cmd=cmd, kwargs={}, message=Msg)
4237
if input_api.verbose:
4338
print('Running ' + cmd_name)
4439
return input_api.RunTests([test_cmd])
4540

4641

4742
# Taken directly from Chromium's PRESUBMIT.py
4843
def _CheckNewHeaderWithoutGnChange(input_api, output_api):
49-
"""Checks that newly added header files have corresponding GN changes.
44+
"""Checks that newly added header files have corresponding GN changes.
5045
Note that this is only a heuristic. To be precise, run script:
5146
build/check_gn_headers.py.
5247
"""
5348

54-
def headers(f):
55-
return input_api.FilterSourceFile(
56-
f, white_list=(r'.+%s' % _HEADER_EXTENSIONS, ))
57-
58-
new_headers = []
59-
for f in input_api.AffectedSourceFiles(headers):
60-
if f.Action() != 'A':
61-
continue
62-
new_headers.append(f.LocalPath())
63-
64-
def gn_files(f):
65-
return input_api.FilterSourceFile(f, white_list=(r'.+\.gn', ))
66-
67-
all_gn_changed_contents = ''
68-
for f in input_api.AffectedSourceFiles(gn_files):
69-
for _, line in f.ChangedContents():
70-
all_gn_changed_contents += line
71-
72-
problems = []
73-
for header in new_headers:
74-
basename = input_api.os_path.basename(header)
75-
if basename not in all_gn_changed_contents:
76-
problems.append(header)
77-
78-
if problems:
79-
return [output_api.PresubmitPromptWarning(
80-
'Missing GN changes for new header files', items=sorted(problems),
81-
long_text='Please double check whether newly added header files need '
82-
'corresponding changes in gn or gni files.\nThis checking is only a '
83-
'heuristic. Run build/check_gn_headers.py to be precise.\n'
84-
'Read https://crbug.com/661774 for more info.')]
85-
return []
49+
def headers(f):
50+
return input_api.FilterSourceFile(f, white_list=(r'.+%s' % _HEADER_EXTENSIONS,))
51+
52+
new_headers = []
53+
for f in input_api.AffectedSourceFiles(headers):
54+
if f.Action() != 'A':
55+
continue
56+
new_headers.append(f.LocalPath())
57+
58+
def gn_files(f):
59+
return input_api.FilterSourceFile(f, white_list=(r'.+\.gn',))
60+
61+
all_gn_changed_contents = ''
62+
for f in input_api.AffectedSourceFiles(gn_files):
63+
for _, line in f.ChangedContents():
64+
all_gn_changed_contents += line
65+
66+
problems = []
67+
for header in new_headers:
68+
basename = input_api.os_path.basename(header)
69+
if basename not in all_gn_changed_contents:
70+
problems.append(header)
71+
72+
if problems:
73+
return [
74+
output_api.PresubmitPromptWarning(
75+
'Missing GN changes for new header files',
76+
items=sorted(problems),
77+
long_text='Please double check whether newly added header files need '
78+
'corresponding changes in gn or gni files.\nThis checking is only a '
79+
'heuristic. Run build/check_gn_headers.py to be precise.\n'
80+
'Read https://crbug.com/661774 for more info.')
81+
]
82+
return []
8683

8784

8885
def CheckChangeOnUpload(input_api, output_api):
8986
results = []
9087
results.extend(_CheckCodeGeneration(input_api, output_api))
91-
results.extend(input_api.canned_checks.CheckChangeHasBugField(
92-
input_api, output_api))
93-
results.extend(input_api.canned_checks.CheckChangeHasDescription(
94-
input_api, output_api))
88+
results.extend(input_api.canned_checks.CheckChangeHasBugField(input_api, output_api))
89+
results.extend(input_api.canned_checks.CheckChangeHasDescription(input_api, output_api))
9590
results.extend(_CheckNewHeaderWithoutGnChange(input_api, output_api))
96-
results.extend(
97-
input_api.canned_checks.CheckPatchFormatted(input_api, output_api))
91+
results.extend(input_api.canned_checks.CheckPatchFormatted(input_api, output_api))
9892
return results
9993

10094

10195
def CheckChangeOnCommit(input_api, output_api):
10296
results = []
10397
results.extend(_CheckCodeGeneration(input_api, output_api))
104-
results.extend(
105-
input_api.canned_checks.CheckPatchFormatted(input_api, output_api))
106-
results.extend(input_api.canned_checks.CheckChangeHasBugField(
107-
input_api, output_api))
108-
results.extend(input_api.canned_checks.CheckChangeHasDescription(
109-
input_api, output_api))
98+
results.extend(input_api.canned_checks.CheckPatchFormatted(input_api, output_api))
99+
results.extend(input_api.canned_checks.CheckChangeHasBugField(input_api, output_api))
100+
results.extend(input_api.canned_checks.CheckChangeHasDescription(input_api, output_api))
110101
return results

android/compress_symbols.py

Lines changed: 95 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -14,115 +14,101 @@
1414

1515

1616
def main():
17-
parser = argparse.ArgumentParser(description=__doc__)
18-
parser.add_argument(
19-
'--objcopy',
20-
required=True,
21-
help='The objcopy binary to run',
22-
metavar='PATH')
23-
parser.add_argument(
24-
'--nm', required=True, help='The nm binary to run', metavar='PATH')
25-
parser.add_argument(
26-
'--sofile',
27-
required=True,
28-
help='Shared object file produced by linking command',
29-
metavar='FILE')
30-
parser.add_argument(
31-
'--output',
32-
required=True,
33-
help='Final output shared object file',
34-
metavar='FILE')
35-
parser.add_argument(
36-
'--unstrippedsofile',
37-
required=True,
38-
help='Unstripped shared object file produced by linking command',
39-
metavar='FILE')
40-
args = parser.parse_args()
41-
42-
copy_cmd = ["cp", args.sofile, args.output]
43-
result = subprocess.call(copy_cmd)
44-
45-
objcopy_cmd = [args.objcopy]
46-
objcopy_cmd.append('--only-keep-debug')
47-
objcopy_cmd.append(args.unstrippedsofile)
48-
objcopy_cmd.append(args.output + '.debug')
49-
result = subprocess.call(objcopy_cmd)
50-
51-
nm_cmd = subprocess.Popen(
52-
[args.nm, args.unstrippedsofile, '--format=posix', '--defined-only'],
53-
stdout=subprocess.PIPE)
54-
55-
awk_cmd = subprocess.Popen(['awk', '{ print $1}'],
56-
stdin=nm_cmd.stdout,
57-
stdout=subprocess.PIPE)
58-
59-
dynsym_out = open(args.output + '.dynsyms', 'w')
60-
sort_cmd = subprocess.Popen(['sort'], stdin=awk_cmd.stdout, stdout=dynsym_out)
61-
dynsym_out.close()
62-
63-
nm_cmd = subprocess.Popen(
64-
[args.nm, args.unstrippedsofile, '--format=posix', '--defined-only'],
65-
stdout=subprocess.PIPE)
66-
67-
awk_cmd = subprocess.Popen(
68-
['awk', '{ if ($2 == "T" || $2 == "t" ||' + ' $2 == "D") print $1 }'],
69-
stdin=nm_cmd.stdout,
70-
stdout=subprocess.PIPE)
71-
72-
funcsyms_out = open(args.output + '.funcsyms', 'w')
73-
sort_cmd = subprocess.Popen(['sort'],
74-
stdin=awk_cmd.stdout,
75-
stdout=funcsyms_out)
76-
funcsyms_out.close()
77-
78-
keep_symbols = open(args.output + '.keep_symbols', 'w')
79-
sort_cmd = subprocess.Popen(
80-
['comm', '-13', args.output + '.dynsyms', args.output + '.funcsyms'],
81-
stdin=awk_cmd.stdout,
82-
stdout=keep_symbols)
83-
84-
# Ensure that the keep_symbols file is not empty.
85-
keep_symbols.write("\n")
86-
keep_symbols.close()
87-
88-
objcopy_cmd = [
89-
args.objcopy, '--rename-section', '.debug_frame=saved_debug_frame',
90-
args.output + '.debug', args.output + ".mini_debuginfo"
91-
]
92-
subprocess.check_call(objcopy_cmd)
93-
94-
objcopy_cmd = [
95-
args.objcopy, '-S', '--remove-section', '.gdb_index', '--remove-section',
96-
'.comment', '--keep-symbols=' + args.output + '.keep_symbols',
97-
args.output + '.mini_debuginfo'
98-
]
99-
subprocess.check_call(objcopy_cmd)
100-
101-
objcopy_cmd = [
102-
args.objcopy, '--rename-section', '.saved_debug_frame=.debug_frame',
103-
args.output + ".mini_debuginfo"
104-
]
105-
subprocess.check_call(objcopy_cmd)
106-
107-
xz_cmd = ['xz', args.output + '.mini_debuginfo']
108-
subprocess.check_call(xz_cmd)
109-
110-
objcopy_cmd = [
111-
args.objcopy, '--add-section',
112-
'.gnu_debugdata=' + args.output + '.mini_debuginfo.xz', args.output
113-
]
114-
subprocess.check_call(objcopy_cmd)
115-
116-
# Clean out scratch files
117-
rm_cmd = [
118-
'rm', '-f', args.output + '.dynsyms', args.output + '.funcsyms',
119-
args.output + '.keep_symbols', args.output + '.debug',
120-
args.output + '.mini_debuginfo', args.output + '.mini_debuginfo.xz'
121-
]
122-
result = subprocess.call(rm_cmd)
123-
124-
return result
17+
parser = argparse.ArgumentParser(description=__doc__)
18+
parser.add_argument(
19+
'--objcopy', required=True, help='The objcopy binary to run', metavar='PATH')
20+
parser.add_argument('--nm', required=True, help='The nm binary to run', metavar='PATH')
21+
parser.add_argument(
22+
'--sofile',
23+
required=True,
24+
help='Shared object file produced by linking command',
25+
metavar='FILE')
26+
parser.add_argument(
27+
'--output', required=True, help='Final output shared object file', metavar='FILE')
28+
parser.add_argument(
29+
'--unstrippedsofile',
30+
required=True,
31+
help='Unstripped shared object file produced by linking command',
32+
metavar='FILE')
33+
args = parser.parse_args()
34+
35+
copy_cmd = ["cp", args.sofile, args.output]
36+
result = subprocess.call(copy_cmd)
37+
38+
objcopy_cmd = [args.objcopy]
39+
objcopy_cmd.append('--only-keep-debug')
40+
objcopy_cmd.append(args.unstrippedsofile)
41+
objcopy_cmd.append(args.output + '.debug')
42+
result = subprocess.call(objcopy_cmd)
43+
44+
nm_cmd = subprocess.Popen([args.nm, args.unstrippedsofile, '--format=posix', '--defined-only'],
45+
stdout=subprocess.PIPE)
46+
47+
awk_cmd = subprocess.Popen(['awk', '{ print $1}'], stdin=nm_cmd.stdout, stdout=subprocess.PIPE)
48+
49+
dynsym_out = open(args.output + '.dynsyms', 'w')
50+
sort_cmd = subprocess.Popen(['sort'], stdin=awk_cmd.stdout, stdout=dynsym_out)
51+
dynsym_out.close()
52+
53+
nm_cmd = subprocess.Popen([args.nm, args.unstrippedsofile, '--format=posix', '--defined-only'],
54+
stdout=subprocess.PIPE)
55+
56+
awk_cmd = subprocess.Popen(
57+
['awk', '{ if ($2 == "T" || $2 == "t" ||' + ' $2 == "D") print $1 }'],
58+
stdin=nm_cmd.stdout,
59+
stdout=subprocess.PIPE)
60+
61+
funcsyms_out = open(args.output + '.funcsyms', 'w')
62+
sort_cmd = subprocess.Popen(['sort'], stdin=awk_cmd.stdout, stdout=funcsyms_out)
63+
funcsyms_out.close()
64+
65+
keep_symbols = open(args.output + '.keep_symbols', 'w')
66+
sort_cmd = subprocess.Popen(
67+
['comm', '-13', args.output + '.dynsyms', args.output + '.funcsyms'],
68+
stdin=awk_cmd.stdout,
69+
stdout=keep_symbols)
70+
71+
# Ensure that the keep_symbols file is not empty.
72+
keep_symbols.write("\n")
73+
keep_symbols.close()
74+
75+
objcopy_cmd = [
76+
args.objcopy, '--rename-section', '.debug_frame=saved_debug_frame', args.output + '.debug',
77+
args.output + ".mini_debuginfo"
78+
]
79+
subprocess.check_call(objcopy_cmd)
80+
81+
objcopy_cmd = [
82+
args.objcopy, '-S', '--remove-section', '.gdb_index', '--remove-section', '.comment',
83+
'--keep-symbols=' + args.output + '.keep_symbols', args.output + '.mini_debuginfo'
84+
]
85+
subprocess.check_call(objcopy_cmd)
86+
87+
objcopy_cmd = [
88+
args.objcopy, '--rename-section', '.saved_debug_frame=.debug_frame',
89+
args.output + ".mini_debuginfo"
90+
]
91+
subprocess.check_call(objcopy_cmd)
92+
93+
xz_cmd = ['xz', args.output + '.mini_debuginfo']
94+
subprocess.check_call(xz_cmd)
95+
96+
objcopy_cmd = [
97+
args.objcopy, '--add-section', '.gnu_debugdata=' + args.output + '.mini_debuginfo.xz',
98+
args.output
99+
]
100+
subprocess.check_call(objcopy_cmd)
101+
102+
# Clean out scratch files
103+
rm_cmd = [
104+
'rm', '-f', args.output + '.dynsyms', args.output + '.funcsyms',
105+
args.output + '.keep_symbols', args.output + '.debug', args.output + '.mini_debuginfo',
106+
args.output + '.mini_debuginfo.xz'
107+
]
108+
result = subprocess.call(rm_cmd)
109+
110+
return result
125111

126112

127113
if __name__ == "__main__":
128-
sys.exit(main())
114+
sys.exit(main())

scripts/bmp_to_nv12.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@
4949
# convert to YUV 4:4:4
5050
converted_pixels = bytearray(pixels)
5151
for i in range(0, width * height):
52-
R, = struct.unpack("B", pixels[i*3+2])
53-
G, = struct.unpack("B", pixels[i*3+1])
54-
B, = struct.unpack("B", pixels[i*3])
55-
converted_pixels[i*3] = ((66*R + 129*G + 25*B + 128) >> 8) + 16
56-
converted_pixels[i*3+1] = ((-38*R - 74*G + 112*B + 128) >> 8) + 128
57-
converted_pixels[i*3+2] = ((112*R - 94*G - 18*B + 128) >> 8) + 128
52+
R, = struct.unpack("B", pixels[i * 3 + 2])
53+
G, = struct.unpack("B", pixels[i * 3 + 1])
54+
B, = struct.unpack("B", pixels[i * 3])
55+
converted_pixels[i * 3] = ((66 * R + 129 * G + 25 * B + 128) >> 8) + 16
56+
converted_pixels[i * 3 + 1] = ((-38 * R - 74 * G + 112 * B + 128) >> 8) + 128
57+
converted_pixels[i * 3 + 2] = ((112 * R - 94 * G - 18 * B + 128) >> 8) + 128
5858

5959
# downsample to packed UV buffer
6060
uv_buffer = bytearray(width * height / 2)

0 commit comments

Comments
 (0)