Load an API registry and generate extension dependencies registry_path - relative filename of XML registry. If not specified, uses the API default. api_name - API name for which to generate dependencies. Only extensions supported for that API are considered.
(self,
registry_path = None,
api_name = None)
| 87 | |
| 88 | class ApiDependencies: |
| 89 | def __init__(self, |
| 90 | registry_path = None, |
| 91 | api_name = None): |
| 92 | """Load an API registry and generate extension dependencies |
| 93 | |
| 94 | registry_path - relative filename of XML registry. If not specified, |
| 95 | uses the API default. |
| 96 | |
| 97 | api_name - API name for which to generate dependencies. Only |
| 98 | extensions supported for that API are considered. |
| 99 | """ |
| 100 | |
| 101 | conventions = APIConventions() |
| 102 | if registry_path is None: |
| 103 | registry_path = conventions.registry_path |
| 104 | if api_name is None: |
| 105 | api_name = conventions.xml_api_name |
| 106 | |
| 107 | self.allExts = set() |
| 108 | self.khrExts = set() |
| 109 | self.ratifiedExts = set() |
| 110 | self.versions = set() |
| 111 | self.graph = DiGraph() |
| 112 | self.extensions = {} |
| 113 | self.tree = etree.parse(registry_path) |
| 114 | |
| 115 | # Loop over all supported features (versions) |
| 116 | for elem in self.tree.findall('feature'): |
| 117 | name = elem.get('name') |
| 118 | api = elem.get('api') |
| 119 | |
| 120 | if api_name in api.split(','): |
| 121 | self.versions.add(name) |
| 122 | |
| 123 | self.graph.add_node(name) |
| 124 | depends = elem.get('depends') |
| 125 | if depends: |
| 126 | for dep in dependencyNames(depends): |
| 127 | self.graph.add_edge(name, dep) |
| 128 | |
| 129 | # Loop over all supported extensions, creating a digraph of the |
| 130 | # extension dependencies in the 'depends' attribute, which is a |
| 131 | # boolean expression of core version and extension names. |
| 132 | # A static dependency tree can be constructed only by treating all |
| 133 | # extension names in the expression as dependencies, even though |
| 134 | # that may not be true if it is of form (ext OR ext). |
| 135 | # For the purpose these dependencies are used for - generating |
| 136 | # specifications with required dependencies included automatically - |
| 137 | # this will suffice. |
| 138 | # Separately tracks lists of all extensions and all KHR extensions, |
| 139 | # which are common specification targets. |
| 140 | for elem in self.tree.findall('extensions/extension'): |
| 141 | name = elem.get('name') |
| 142 | supported = elem.get('supported') |
| 143 | ratified = elem.get('ratified', '') |
| 144 | |
| 145 | if api_name in supported.split(','): |
| 146 | self.allExts.add(name) |
nothing calls this directly
no test coverage detected