refactor(macho): consolidate universal image selection

This commit is contained in:
morluto committed 2026-10-27 13:04:22 +08:00
1 parent df8c90df8f
commit c7afedc3d2
4 files changed
+80 -70

No files matched your search

+2 -2
View File
@@ -25,6 +25,7 @@ import {
validateFatSliceIdentity,
type FatSliceDeclaration,
} from "../domain/apple/machoContainer.js";
import { MACHO_CPU_TYPES } from "../domain/apple/machoTargetSelection.js";
import { machoCpuSubtypeBase } from "../domain/apple/machoCpuIdentity.js";
import {
HopperCancelledError,
@@ -366,7 +367,6 @@ const inspectHopperMachOImage = async (
)
return invalid("Hopper cannot select the admitted Mach-O architecture");
const architecture = target.architecture;
const cpuTypes = { x86: 7, x86_64: 0x1000007, arm: 12, arm64: 0x100000c };
const matches = [];
for (const slice of parsed.slices) {
if (signal?.aborted)
@@ -393,7 +393,7 @@ const inspectHopperMachOImage = async (
);
const identityError = validateFatSliceIdentity(slice, identity);
if (identityError !== null) return invalid(identityError);
if (slice.cpuType === cpuTypes[architecture]) matches.push(slice);
if (slice.cpuType === MACHO_CPU_TYPES[architecture]) matches.push(slice);
}
if (findOverlappingFatSlices(parsed.slices) !== null)
return invalid("FAT slices overlap");