17INCLUDE_DIRECTIVE_RE = re.compile(
r'^#include "(.*)"')
19RUNTIME_LAYER_HEADERS = [
20 'runtime/vm/isolate.h',
21 'runtime/vm/object.h',
22 'runtime/vm/raw_object.h',
23 'runtime/vm/thread.h',
26SHOULD_NOT_DEPEND_ON_RUNTIME = [
27 'runtime/vm/allocation.h',
28 'runtime/vm/growable_array.h',
42 self.
file_layers = {file:
'runtime' for file
in RUNTIME_LAYER_HEADERS}
52 """Check that given files do not depend on runtime layer."""
55 if not os.path.exists(os.path.join(self.
root, file)):
56 errors.append(
'File %s does not exist.' % (file))
59 'LAYERING ERROR: %s includes object.h or raw_object.h' %
76 """Propagate layering information through include graph.
78 If A is in layer L and A is included into B then B is in layer L.
91 'Layer mismatch: %s (%s) is included into %s (%s)' %
98 """Add all *.cc and *.h files from dir recursively into worklist."""
99 for file
in os.listdir(dir):
100 path = os.path.join(dir, file)
101 if os.path.isdir(path):
103 elif path.endswith(
'.cc')
or path.endswith(
'.h'):
107 """Extract the list of includes from the given file."""
109 with open(os.path.join(self.
root, file), encoding=
'utf-8')
as file:
111 if line.startswith(
'namespace dart {'):
114 m = INCLUDE_DIRECTIVE_RE.match(line)
116 header = os.path.join(
'runtime', m.group(1))
117 if os.path.isfile(os.path.join(self.
root, header)):
123 """Run layering check at the given root folder."""
127if __name__ ==
'__main__':
129 print(
'\n'.join(errors))
static std::function< void(void)> pop(std::deque< std::function< void(void)> > *list)
CheckNotInRuntime(self, files)
ExtractIncludes(self, file)
AddAllSourcesToWorklist(self, dir)