(build_obj: BuildConfigUnit, link_step: LinkStep)
| 997 | return obj_path |
| 998 | |
| 999 | def add_unit(build_obj: BuildConfigUnit, link_step: LinkStep): |
| 1000 | obj_path, obj_name = build_obj["object"], build_obj["name"] |
| 1001 | obj = objects.get(obj_name) |
| 1002 | if obj is None: |
| 1003 | if config.warn_missing_config and not build_obj["autogenerated"]: |
| 1004 | print(f"Missing configuration for {obj_name}") |
| 1005 | if obj_path is not None: |
| 1006 | link_step.add(Path(obj_path)) |
| 1007 | return |
| 1008 | |
| 1009 | link_built_obj = obj.completed |
| 1010 | built_obj_path: Optional[Path] = None |
| 1011 | if obj.src_path is not None and obj.src_path.exists(): |
| 1012 | if file_is_c_cpp(obj.src_path): |
| 1013 | # Add MWCC & host build rules |
| 1014 | built_obj_path = c_build(obj, obj.src_path) |
| 1015 | elif file_is_asm(obj.src_path): |
| 1016 | # Add assembler build rule |
| 1017 | built_obj_path = asm_build(obj, obj.src_path, obj.src_obj_path) |
| 1018 | else: |
| 1019 | sys.exit(f"Unknown source file type {obj.src_path}") |
| 1020 | else: |
| 1021 | if config.warn_missing_source or obj.completed: |
| 1022 | print(f"Missing source file {obj.src_path}") |
| 1023 | link_built_obj = False |
| 1024 | |
| 1025 | # Assembly overrides |
| 1026 | if obj.asm_path is not None and obj.asm_path.exists(): |
| 1027 | link_built_obj = True |
| 1028 | built_obj_path = asm_build(obj, obj.asm_path, obj.asm_obj_path) |
| 1029 | |
| 1030 | if link_built_obj and built_obj_path is not None: |
| 1031 | # Use the source-built object |
| 1032 | link_step.add(built_obj_path) |
| 1033 | elif obj_path is not None: |
| 1034 | # Use the original (extracted) object |
| 1035 | link_step.add(Path(obj_path)) |
| 1036 | |
| 1037 | # Add DOL link step |
| 1038 | link_step = LinkStep(build_config) |
no test coverage detected