Set icon for QEMU binary on Mac OS

Before switching the build system over to Meson, an icon was
added to the QEMU binary on Mac OS. This patch adds back that
feature; it piggybacks on the existing scripts/entitlement.sh,
which already does in-place changes to the executable on Darwin.

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
Message-Id: <20210705195328.36442-1-programmingkidx@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
master
John Arbuckle 2021-07-05 15:53:28 -04:00 committed by Paolo Bonzini
parent 904806c69b
commit 3983a767e3
2 changed files with 19 additions and 6 deletions

View File

@ -2507,8 +2507,7 @@ foreach target : target_dirs
endif endif
foreach exe: execs foreach exe: execs
exe_name = exe['name'] exe_name = exe['name']
exe_sign = 'CONFIG_HVF' in config_target if targetos == 'darwin'
if exe_sign
exe_name += '-unsigned' exe_name += '-unsigned'
endif endif
@ -2522,7 +2521,13 @@ foreach target : target_dirs
link_args: link_args, link_args: link_args,
gui_app: exe['gui']) gui_app: exe['gui'])
if exe_sign if 'CONFIG_HVF' in config_target
entitlements = meson.current_source_dir() / 'accel/hvf/entitlements.plist'
else
entitlements = '/dev/null'
endif
if targetos == 'darwin'
icon = meson.current_source_dir() / 'pc-bios/qemu.rsrc'
emulators += {exe['name'] : custom_target(exe['name'], emulators += {exe['name'] : custom_target(exe['name'],
depends: emulator, depends: emulator,
output: exe['name'], output: exe['name'],
@ -2530,14 +2535,14 @@ foreach target : target_dirs
meson.current_source_dir() / 'scripts/entitlement.sh', meson.current_source_dir() / 'scripts/entitlement.sh',
meson.current_build_dir() / exe_name, meson.current_build_dir() / exe_name,
meson.current_build_dir() / exe['name'], meson.current_build_dir() / exe['name'],
meson.current_source_dir() / 'accel/hvf/entitlements.plist' entitlements, icon
]) ])
} }
meson.add_install_script('scripts/entitlement.sh', '--install', meson.add_install_script('scripts/entitlement.sh', '--install',
get_option('bindir') / exe_name, get_option('bindir') / exe_name,
get_option('bindir') / exe['name'], get_option('bindir') / exe['name'],
meson.current_source_dir() / 'accel/hvf/entitlements.plist') entitlements, icon)
else else
emulators += {exe['name']: emulator} emulators += {exe['name']: emulator}
endif endif

View File

@ -11,6 +11,7 @@ fi
SRC="$1" SRC="$1"
DST="$2" DST="$2"
ENTITLEMENT="$3" ENTITLEMENT="$3"
ICON="$4"
if $in_place; then if $in_place; then
trap 'rm "$DST.tmp"' exit trap 'rm "$DST.tmp"' exit
@ -20,6 +21,13 @@ else
cd "$MESON_INSTALL_DESTDIR_PREFIX" cd "$MESON_INSTALL_DESTDIR_PREFIX"
fi fi
codesign --entitlements "$ENTITLEMENT" --force -s - "$SRC" if test "$ENTITLEMENT" != '/dev/null'; then
codesign --entitlements "$ENTITLEMENT" --force -s - "$SRC"
fi
# Add the QEMU icon to the binary on Mac OS
Rez -append "$ICON" -o "$SRC"
SetFile -a C "$SRC"
mv -f "$SRC" "$DST" mv -f "$SRC" "$DST"
trap '' exit trap '' exit