Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
tools.build_workaround_header Namespace Reference

Functions

 merge_files_into_workarounds (files)
 
 write_header (filename, workarounds)
 
 main (argv)
 

Variables

str _LICENSE
 
tuple _DO_NOT_EDIT_WARNING
 

Detailed Description

code generator for gpu workaround definitions

Function Documentation

◆ main()

tools.build_workaround_header.main (   argv)

Definition at line 54 of file build_workaround_header.py.

54def main(argv):
55 usage = "usage: %prog [options] file1 file2 file3 etc"
56 parser = OptionParser(usage=usage)
57 parser.add_option(
58 "--output-file",
59 dest="output_file",
60 default="gpu_driver_bug_workaround_autogen.h",
61 help="the name of the header file to write")
62
63 (options, _) = parser.parse_args(args=argv)
64
65 workarounds = merge_files_into_workarounds(parser.largs)
66 write_header(options.output_file, workarounds)
67
68
Definition main.py:1

◆ merge_files_into_workarounds()

tools.build_workaround_header.merge_files_into_workarounds (   files)

Definition at line 22 of file build_workaround_header.py.

22def merge_files_into_workarounds(files):
23 workarounds = set()
24 for filename in files:
25 with open(filename, 'r') as f:
26 workarounds.update([workaround.strip() for workaround in f])
27 return sorted(list(workarounds))
28
29

◆ write_header()

tools.build_workaround_header.write_header (   filename,
  workarounds 
)

Definition at line 30 of file build_workaround_header.py.

30def write_header(filename, workarounds):
31 max_workaround_len = len(max(workarounds, key=len))
32
33 with open(filename, 'w') as f:
34 f.write(_LICENSE)
35 f.write(_DO_NOT_EDIT_WARNING)
36
37 indent = ' '
38 macro = 'GPU_OP'
39
40 # length of max string passed to write + 1
41 max_len = len(indent) + len(macro) + 1 + max_workaround_len + 1 + 1
42 write = lambda line: f.write(line + ' ' * (max_len - len(line)) + '\\\n')
43 f.write('#ifndef GPU_DRIVER_BUG_WORKAROUNDS\n')
44 write('#define GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)')
45 for w in workarounds:
46 write(indent + macro + '(' + w.upper() + ',')
47 write(indent + ' ' * (len(macro) + 1) + w + ')')
48
49 # one extra line for the last escaped newline to handle.
50 f.write('\n')
51 f.write('#endif // GPU_DRIVER_BUG_WORKAROUNDS\n')
52
53
static float max(float r, float g, float b)
Definition hsl.cpp:49
void write(SkWStream *wStream, const T &text)
Definition skqp.cpp:188

Variable Documentation

◆ _DO_NOT_EDIT_WARNING

tuple tools.build_workaround_header._DO_NOT_EDIT_WARNING
protected
Initial value:
1= ("// This file is auto-generated from " +
2 os.path.basename(__file__) + "\n" +
3 "// DO NOT EDIT!\n\n")

Definition at line 18 of file build_workaround_header.py.

◆ _LICENSE

str tools.build_workaround_header._LICENSE
protected
Initial value:
1= """// Copyright 2018 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5"""

Definition at line 12 of file build_workaround_header.py.