@@ -21,6 +21,7 @@ import { createCommonTarget, NoOpTarget } from "./targets/targetFactory"
2121import { isMacOsHighSierra } from "./util/macosVersion"
2222import { getTemplatePath } from "./util/pathManager"
2323import { resolveFunction } from "./util/resolve"
24+ import { expandMacro as doExpandMacro } from "./util/macroExpander"
2425
2526export type CustomMacSignOptions = SignOptions
2627export type CustomMacSign = ( configuration : CustomMacSignOptions , packager : MacPackager ) => Promise < void >
@@ -69,6 +70,15 @@ export class MacPackager extends PlatformPackager<MacConfiguration> {
6970 return this . info . framework . macOsDefaultTargets
7071 }
7172
73+ expandArch ( pattern : string , arch ?: Arch | null ) : string [ ] {
74+ if ( arch === Arch . universal ) {
75+ // Universal build has `app-x64.asar.unpacked` & `app-arm64.asar.unpacked`
76+ return [ doExpandMacro ( pattern , Arch [ Arch . arm64 ] , this . appInfo , { } , false ) , doExpandMacro ( pattern , Arch [ Arch . x64 ] , this . appInfo , { } , false ) ]
77+ }
78+ // Every other build keeps the name as `app.asar.unpacked`
79+ return [ doExpandMacro ( pattern , null , this . appInfo , { } , false ) ]
80+ }
81+
7282 // eslint-disable-next-line @typescript-eslint/no-unused-vars
7383 protected prepareAppInfo ( appInfo : AppInfo ) : AppInfo {
7484 // codesign requires the filename to be normalized to the NFD form
@@ -303,15 +313,22 @@ export class MacPackager extends PlatformPackager<MacConfiguration> {
303313 let binaries = options . binaries || undefined
304314 if ( binaries ) {
305315 // Accept absolute paths for external binaries, else resolve relative paths from the artifact's app Contents path.
306- binaries = await Promise . all (
307- binaries . map ( async destination => {
308- if ( await statOrNull ( destination ) ) {
309- return destination
310- }
311- return path . resolve ( appPath , destination )
312- } )
313- )
314- log . info ( { binaries } , "signing additional user-defined binaries" )
316+ binaries = (
317+ await Promise . all (
318+ binaries . flatMap ( async destination => {
319+ const expandedDestination = this . expandArch ( destination , arch )
320+ return await Promise . all (
321+ expandedDestination . map ( async d => {
322+ if ( await statOrNull ( d ) ) {
323+ return d
324+ }
325+ return path . resolve ( appPath , d )
326+ } )
327+ )
328+ } )
329+ )
330+ ) . flat ( )
331+ log . info ( { binaries, arch : arch == null ? null : Arch [ arch ] } , "signing additional user-defined binaries for arch" )
315332 }
316333 const customSignOptions : MasConfiguration | MacConfiguration = ( isMas ? masOptions : this . platformSpecificBuildOptions ) || this . platformSpecificBuildOptions
317334
0 commit comments