Build a dict of the VTK Module name, library name(if it exists) and any header files. :param vtk_src_dir: The path to the VTK source folder :return: Module name, library name and headers.
(vtk_src_dir)
| 58 | |
| 59 | |
| 60 | def find_vtk_modules(vtk_src_dir): |
| 61 | """ |
| 62 | Build a dict of the VTK Module name, library name(if it exists) and any header files. |
| 63 | |
| 64 | :param vtk_src_dir: The path to the VTK source folder |
| 65 | :return: Module name, library name and headers. |
| 66 | """ |
| 67 | vtk_modules = defaultdict(dict) |
| 68 | modules = [f for f in Path(vtk_src_dir).rglob('vtk.module')] |
| 69 | # Includes in the module path |
| 70 | file_patterns = ['vtk*.h', 'vtk*.h.in', 'QVTK*.h', '*QtQuick.h'] |
| 71 | for module in modules: |
| 72 | content = module.read_text() |
| 73 | args = content.split('\n') |
| 74 | # Assuming NAME is always there. |
| 75 | if 'NAME' in args: |
| 76 | name = args[args.index('NAME') + 1].strip() |
| 77 | if 'LIBRARY_NAME' in args: |
| 78 | library_name = args[args.index('LIBRARY_NAME') + 1].strip() |
| 79 | else: |
| 80 | library_name = None |
| 81 | headers = list() |
| 82 | for pattern in file_patterns: |
| 83 | if pattern == 'vtk*.h.in': |
| 84 | # These files will be converted to header files in the build folder of VTK. |
| 85 | headers.extend([f.with_suffix('').name for f in module.parent.glob(pattern)]) |
| 86 | else: |
| 87 | headers.extend([f.name for f in module.parent.glob(pattern)]) |
| 88 | vtk_modules[name]['library_name'] = library_name |
| 89 | vtk_modules[name]['headers'] = headers |
| 90 | return vtk_modules |
| 91 | |
| 92 | |
| 93 | def build_headers_modules(modules): |
no test coverage detected