Yields all codegen dependencies. outputwrapper is the CodegenDirWrapper that was passed to generate_all; it's used to determine the files that have been read. In addition, all imported python modules are yielded.
(outputwrapper: CodegenDirWrapper)
| 192 | |
| 193 | |
| 194 | def get_codegen_depends(outputwrapper: CodegenDirWrapper) -> Generator[str, None, None]: |
| 195 | """ |
| 196 | Yields all codegen dependencies. |
| 197 | |
| 198 | outputwrapper is the CodegenDirWrapper that was passed to generate_all; |
| 199 | it's used to determine the files that have been read. |
| 200 | |
| 201 | In addition, all imported python modules are yielded. |
| 202 | """ |
| 203 | # add all files that have been read as depends |
| 204 | for parts in outputwrapper.get_reads(): |
| 205 | # TODO: this assumes that the wrap.obj.fsobj is a fslike.Directory |
| 206 | # this just resolves paths to the output directory |
| 207 | yield outputwrapper.obj.fsobj.resolve(parts).decode() |
| 208 | |
| 209 | module_blacklist = set(depend_module_blacklist()) |
| 210 | |
| 211 | # add all source files that have been loaded as depends |
| 212 | for module in modules.values(): |
| 213 | if module in module_blacklist: |
| 214 | continue |
| 215 | |
| 216 | try: |
| 217 | filename = module.__file__ |
| 218 | except AttributeError: |
| 219 | # built-in modules don't have __file__, we don't want those as |
| 220 | # depends. |
| 221 | continue |
| 222 | |
| 223 | if filename is None: |
| 224 | # some modules have __file__ == None, we don't want those either. |
| 225 | continue |
| 226 | |
| 227 | if module.__package__ == '': |
| 228 | continue |
| 229 | |
| 230 | if not filename.endswith('.py'): |
| 231 | # This usually means that some .so file is imported as module. |
| 232 | # This is not a problem as long as it's not "our" .so file. |
| 233 | # => just handle non-openage non-.py files normally |
| 234 | |
| 235 | if 'openage' in module.__name__: |
| 236 | print("codegeneration depends on non-.py module " + filename) |
| 237 | sys.exit(1) |
| 238 | |
| 239 | yield filename |
| 240 | |
| 241 | |
| 242 | def get_header_lines() -> Generator[str, None, None]: |
no test coverage detected