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

Functions

 CheckFile (sdk_root, path)
 
 CheckDir (sdk_root, dir)
 
 DoCheck (sdk_root)
 

Variables

 INCLUDE_DIRECTIVE_RE = re.compile(r'^#include "(.*)"')
 
 PLATFORM_LAYER_RE = re.compile(r'^runtime/platform/')
 
 VM_LAYER_RE = re.compile(r'^runtime/(vm|lib)/')
 
 BIN_LAYER_RE = re.compile(r'^runtime/bin/')
 
list EXTRA_TEST_FILES
 
 errors = DoCheck('.')
 

Function Documentation

◆ CheckDir()

embedder_layering_check.CheckDir (   sdk_root,
  dir 
)

Definition at line 58 of file embedder_layering_check.py.

58def CheckDir(sdk_root, dir):
59 errors = []
60 for file in os.listdir(dir):
61 path = os.path.join(dir, file)
62 if os.path.isdir(path):
63 errors += CheckDir(sdk_root, path)
64 elif path.endswith('test.cc') or path in EXTRA_TEST_FILES:
65 None # Tests may violate layering.
66 elif path.endswith('.cc') or path.endswith('.h'):
67 errors += CheckFile(sdk_root, os.path.relpath(path, sdk_root))
68 return errors
69
70

◆ CheckFile()

embedder_layering_check.CheckFile (   sdk_root,
  path 
)

Definition at line 28 of file embedder_layering_check.py.

28def CheckFile(sdk_root, path):
29 includes = set()
30 with open(os.path.join(sdk_root, path), encoding='utf-8') as file:
31 for line in file:
32 m = INCLUDE_DIRECTIVE_RE.match(line)
33 if m is not None:
34 header = os.path.join('runtime', m.group(1))
35 if os.path.isfile(os.path.join(sdk_root, header)):
36 includes.add(header)
37
38 errors = []
39 for include in includes:
40 if PLATFORM_LAYER_RE.match(path):
41 if VM_LAYER_RE.match(include):
42 errors.append(
43 'LAYERING ERROR: %s must not include %s' % (path, include))
44 elif BIN_LAYER_RE.match(include):
45 errors.append(
46 'LAYERING ERROR: %s must not include %s' % (path, include))
47 elif VM_LAYER_RE.match(path):
48 if BIN_LAYER_RE.match(include):
49 errors.append(
50 'LAYERING ERROR: %s must not include %s' % (path, include))
51 elif BIN_LAYER_RE.match(path):
52 if VM_LAYER_RE.match(include):
53 errors.append(
54 'LAYERING ERROR: %s must not include %s' % (path, include))
55 return errors
56
57

◆ DoCheck()

embedder_layering_check.DoCheck (   sdk_root)

Definition at line 71 of file embedder_layering_check.py.

71def DoCheck(sdk_root):
72 return CheckDir(sdk_root, 'runtime')
73
74

Variable Documentation

◆ BIN_LAYER_RE

embedder_layering_check.BIN_LAYER_RE = re.compile(r'^runtime/bin/')

Definition at line 18 of file embedder_layering_check.py.

◆ errors

embedder_layering_check.errors = DoCheck('.')

Definition at line 76 of file embedder_layering_check.py.

◆ EXTRA_TEST_FILES

list embedder_layering_check.EXTRA_TEST_FILES
Initial value:
1= [
2 'runtime/bin/run_vm_tests.cc',
3 'runtime/bin/ffi_unit_test/run_ffi_unit_tests.cc',
4 'runtime/vm/libfuzzer/dart_libfuzzer.cc'
5]

Definition at line 21 of file embedder_layering_check.py.

◆ INCLUDE_DIRECTIVE_RE

embedder_layering_check.INCLUDE_DIRECTIVE_RE = re.compile(r'^#include "(.*)"')

Definition at line 14 of file embedder_layering_check.py.

◆ PLATFORM_LAYER_RE

embedder_layering_check.PLATFORM_LAYER_RE = re.compile(r'^runtime/platform/')

Definition at line 16 of file embedder_layering_check.py.

◆ VM_LAYER_RE

embedder_layering_check.VM_LAYER_RE = re.compile(r'^runtime/(vm|lib)/')

Definition at line 17 of file embedder_layering_check.py.