Skip to content

Commit f379aca

Browse files
Merge pull request #2508 from sensei-hacker/fix-macos-dmg-windows-binaries
Fix postPackage hook to remove non-native SITL binaries from macOS builds
2 parents 9649161 + d28fa43 commit f379aca

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

forge.config.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,38 @@ export default {
4949
// Remove SITL binaries for other platforms/architectures to reduce package size
5050
postPackage: async (forgeConfig, options) => {
5151
for (const outputPath of options.outputPaths) {
52-
const sitlPath = path.join(outputPath, 'resources', 'sitl');
53-
if (!fs.existsSync(sitlPath)) continue;
52+
let sitlPath;
53+
54+
if (options.platform === 'darwin') {
55+
// macOS app bundle structure: <outputDir>/<AppName>.app/Contents/Resources/sitl
56+
// Find the .app directory
57+
const appBundles = fs.readdirSync(outputPath).filter(f => f.endsWith('.app'));
58+
if (appBundles.length === 0) {
59+
console.log(`postPackage: No .app bundle found in ${outputPath}`);
60+
continue;
61+
}
62+
sitlPath = path.join(outputPath, appBundles[0], 'Contents', 'Resources', 'sitl');
63+
} else {
64+
// Windows/Linux: <outputPath>/resources/sitl
65+
sitlPath = path.join(outputPath, 'resources', 'sitl');
66+
}
67+
68+
console.log(`postPackage: Checking SITL path for ${options.platform}: ${sitlPath}`);
69+
if (!fs.existsSync(sitlPath)) {
70+
console.log(`postPackage: SITL path not found, skipping: ${sitlPath}`);
71+
continue;
72+
}
5473

5574
if (options.platform === 'win32') {
75+
console.log('postPackage: Removing non-Windows SITL binaries (linux, macos)');
5676
fs.rmSync(path.join(sitlPath, 'linux'), { recursive: true, force: true });
5777
fs.rmSync(path.join(sitlPath, 'macos'), { recursive: true, force: true });
5878
} else if (options.platform === 'darwin') {
79+
console.log('postPackage: Removing non-macOS SITL binaries (linux, windows)');
5980
fs.rmSync(path.join(sitlPath, 'linux'), { recursive: true, force: true });
6081
fs.rmSync(path.join(sitlPath, 'windows'), { recursive: true, force: true });
6182
} else if (options.platform === 'linux') {
83+
console.log('postPackage: Removing non-Linux SITL binaries (macos, windows)');
6284
fs.rmSync(path.join(sitlPath, 'macos'), { recursive: true, force: true });
6385
fs.rmSync(path.join(sitlPath, 'windows'), { recursive: true, force: true });
6486
// Remove wrong architecture

0 commit comments

Comments
 (0)