@@ -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