(build_obj: BuildConfigUnit, link_step: LinkStep)
| 1127 | return obj_path |
| 1128 | |
| 1129 | def add_unit(build_obj: BuildConfigUnit, link_step: LinkStep): |
| 1130 | obj_path, obj_name = build_obj["object"], build_obj["name"] |
| 1131 | obj = objects.get(obj_name) |
| 1132 | if obj is None: |
| 1133 | if config.warn_missing_config and not build_obj["autogenerated"]: |
| 1134 | print(f"Missing configuration for {obj_name}") |
| 1135 | if obj_path is not None: |
| 1136 | link_step.add(Path(obj_path)) |
| 1137 | return |
| 1138 | |
| 1139 | link_built_obj = obj.completed |
| 1140 | built_obj_path: Optional[Path] = None |
| 1141 | if obj.src_path is not None and obj.src_path.exists(): |
| 1142 | check_path_case(obj.src_path) |
| 1143 | if file_is_c_cpp(obj.src_path): |
| 1144 | # Add C/C++ build rule |
| 1145 | built_obj_path = c_build(obj, obj.src_path) |
| 1146 | elif file_is_asm(obj.src_path): |
| 1147 | # Add assembler build rule |
| 1148 | built_obj_path = asm_build(obj, obj.src_path, obj.src_obj_path) |
| 1149 | else: |
| 1150 | sys.exit(f"Unknown source file type {obj.src_path}") |
| 1151 | else: |
| 1152 | if config.warn_missing_source or obj.completed: |
| 1153 | print(f"Missing source file {obj.src_path}") |
| 1154 | link_built_obj = False |
| 1155 | |
| 1156 | # Assembly overrides |
| 1157 | if ( |
| 1158 | not link_built_obj |
| 1159 | and obj.asm_path is not None |
| 1160 | and obj.asm_path.exists() |
| 1161 | ): |
| 1162 | check_path_case(obj.asm_path) |
| 1163 | link_built_obj = True |
| 1164 | built_obj_path = asm_build(obj, obj.asm_path, obj.asm_obj_path) |
| 1165 | |
| 1166 | if link_built_obj and built_obj_path is not None: |
| 1167 | # Use the source-built object |
| 1168 | link_step.add(built_obj_path) |
| 1169 | elif obj_path is not None: |
| 1170 | # Use the original (extracted) object |
| 1171 | link_step.add(Path(obj_path)) |
| 1172 | |
| 1173 | # Add DOL link step |
| 1174 | link_step = LinkStep(build_config) |
no test coverage detected