13from io
import StringIO
16parser = argparse.ArgumentParser()
17parser.add_argument(
'-n',
'--dry-run', action=
'store_true',
18 help=
'Just check there is nothing to rewrite.')
19parser.add_argument(
'sources', nargs=
'*',
20 help=
'Source files to rewrite, or all if empty.')
21args = parser.parse_args()
32 'platform_tools/android/apps',
44 'include/third_party/vulkan',
47 'include/third_party/skcms',
48 'src/gpu/vk/vulkanmemoryallocator',
54 'GrGLMakeEGLInterface.h',
55 'GrGLMakeEpoxyEGLInterface.h',
56 'GrGLMakeGLXInterface.h',
61assert '/' in [os.sep, os.altsep]
63 return p.replace(os.sep, os.altsep)
if os.altsep
else p
68 for path, _, files
in os.walk(root):
69 if not any(snippet
in fix_path(path)
for snippet
in ignorelist):
70 for file_name
in files:
71 if file_name.endswith(
'.h')
and not file_name
in ignorelist:
72 if file_name
in headers:
73 message = (
'Header filename is used more than once!\n- ' + path +
'/' + file_name +
74 '\n- ' + headers[file_name])
75 assert file_name
not in headers, message
76 headers[file_name] = os.path.abspath(os.path.join(path, file_name))
80 for path
in args.sources:
84 for path, _, files
in os.walk(root):
85 for file_name
in files:
86 yield os.path.join(path, file_name)
91 if (
'/generated/' in file_path
or
92 'tests/sksl/' in file_path
or
93 'third_party/skcms' in file_path
or
94 'modules/skcms' in file_path
or
96 'jetski' in file_path
or
97 'tools/window' in file_path
or
98 file_path.startswith(
'bazel/rbe')
or
99 'example/external_client/' in file_path
or
101 file_path ==
'include/private/base/SkLoadUserConfig.h'):
103 if (file_path.endswith(
'.h')
or
104 file_path.endswith(
'.c')
or
105 file_path.endswith(
'.m')
or
106 file_path.endswith(
'.mm')
or
107 file_path.endswith(
'.inc')
or
108 file_path.endswith(
'.cc')
or
109 file_path.endswith(
'.cpp')):
114 output = StringIO()
if args.dry_run
else open(file_path,
'w')
118 parts = line.replace(
'<',
'"').replace(
'>',
'"').split(
'"')
121 and 'include' in parts[0]
122 and os.path.basename(parts[1])
in headers):
123 header =
fix_path(os.path.relpath(headers[os.path.basename(parts[1])],
'.'))
124 includes.append(parts[0] +
'"%s"' % header + parts[2])
128 includes = sorted(list(
set(includes)))
130 output.write(inc.strip(
'\n') +
'\n')
132 output.write(line.strip(
'\n') +
'\n')
134 for inc
in sorted(includes):
135 output.write(inc.strip(
'\n') +
'\n')
136 if args.dry_run
and output.getvalue() != open(file_path).
read():
137 need_rewriting.append(file_path)
142 print(
'Some files need rewritten #includes:')
143 for path
in need_rewriting:
145 print(
'To do this automatically, run')
146 print(
'python3 tools/rewrite_includes.py ' +
' '.
join(need_rewriting))
static bool read(SkStream *stream, void *buffer, size_t amount)
static void readlines(const void *data, size_t size, F f)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
def print(*args, **kwargs)
SIT bool any(const Vec< 1, T > &x)
static SkString join(const CommandLineFlags::StringArray &)