Skip to content

Commit

Permalink
fix: ignore differences caused by merged machO files (#66)
Browse files Browse the repository at this point in the history
* Ignore differences caused by merged machO files

* Fix filter indent

* Fix types & Fix error caught by type check
  • Loading branch information
macdja38 authored Nov 21, 2023
1 parent b6f0c88 commit 20b1b02
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const makeUniversalApp = async (opts: MakeUniversalOpts): Promise<void> =
);
}
}

const knownMergedMachOFiles = new Set();
for (const machOFile of x64Files.filter((f) => f.type === AppFileType.MACHO)) {
const first = await fs.realpath(path.resolve(tmpApp, machOFile.relativePath));
const second = await fs.realpath(path.resolve(opts.arm64AppPath, machOFile.relativePath));
Expand Down Expand Up @@ -170,6 +170,7 @@ export const makeUniversalApp = async (opts: MakeUniversalOpts): Promise<void> =
'-output',
await fs.realpath(path.resolve(tmpApp, machOFile.relativePath)),
]);
knownMergedMachOFiles.add(machOFile.relativePath);
}

/**
Expand All @@ -185,8 +186,14 @@ export const makeUniversalApp = async (opts: MakeUniversalOpts): Promise<void> =
path.resolve(opts.arm64AppPath, 'Contents', 'Resources', 'app'),
{ compareSize: true, compareContent: true },
);

if (!comparison.same) {
const differences = comparison.diffSet!
.filter(difference => difference.state !== "equal")
d(`Found ${differences.length} difference(s) between the x64 and arm64 folders`);
const nonMergedDifferences = differences
.filter(difference => !difference.name1 || !knownMergedMachOFiles.has(path.join('Contents', 'Resources', 'app', difference.relativePath, difference.name1)))
d(`After discluding MachO files merged with lipo ${nonMergedDifferences.length} remain.`);

if (nonMergedDifferences.length > 0) {
d('x64 and arm64 app folders are different, creating dynamic entry ASAR');
await fs.move(
path.resolve(tmpApp, 'Contents', 'Resources', 'app'),
Expand Down

0 comments on commit 20b1b02

Please sign in to comment.