Set icon for QEMU binary on Mac OS
PATCH 1/1 Set icon for QEMU binary on Mac OS
Hi Paolo, I was told you were the one who I should send this patch to. Please let me know if you feel otherwise.
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.
--- meson.build | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
meson.build +20 -0
@@ -2183,6 +2183,26 @@ foreach target : target_dirs link_args: link_args, gui_app: exe['gui']) +# set QEMU's icon on Mac OS +if targetos == 'darwin' + newiconpart1 = custom_target('Icon for ' + exe_name + ' - part 1', + depends : emulator, + input : emulator, + output : 'new icon for ' + exe_name + ' - 1', + command : ['Rez', '-append', + meson.source_root() + '/pc-bios/qemu.rsrc', '-o', + meson.current_build_dir() / exe['name']], + build_by_default : true) + + custom_target('Icon for ' + exe_name + ' - part 2', + depends : newiconpart1, + input : emulator, + output : 'new icon for ' + exe_name + ' - 2', + command : ['SetFile', '-a', 'C', + meson.current_build_dir() / exe['name']], + build_by_default : true) +endif + if exe_sign emulators += {exe['name'] : custom_target(exe['name'], install: true,
Signature · 1 line
2.24.3 (Apple Git-128)
Quoted 1 line · Programmingkid
Hi Paolo, I was told you were the one who I should send this patch to. Please let me know if you feel otherwise.
Absolutely, thanks. Removing the icon was mostly done out of lack of a machine to test it on, and it's nice to add it back.
Review
Quoted 10 lines
(quoted diff) +10
-0+# set QEMU's icon on Mac OS +if targetos == 'darwin' + newiconpart1 = custom_target('Icon for ' + exe_name + ' - part 1', + depends : emulator, + input : emulator, + output : 'new icon for ' + exe_name + ' - 1', + command : ['Rez', '-append', + meson.source_root() + '/pc-bios/qemu.rsrc', '-o', + meson.current_build_dir() / exe['name']], + build_by_default : true)
I think having a command that never actually creates the "new icon for ... - 1" file will cause the command to be run over and over.
We already have scripts/entitlement.sh to do (possibly) in-place changes to the executable on Darwin. I suggest something like this:
meson.build +10 -5
@@ -2505,8 +2505,7 @@ foreach target : target_dirs endif foreach exe: execs exe_name = exe['name'] - exe_sign = 'CONFIG_HVF' in config_target - if exe_sign + if targetos == 'darwin' exe_name += '-unsigned' endif
@@ -2520,7 +2519,13 @@ foreach target : target_dirs link_args: link_args, win_subsystem: exe['win_subsystem']) - if exe_sign + if 'CONFIG_HVF' in config_target + entitlement = meson.current_source_dir() / 'accel/hvf/entitlements.plist' + else + entitlement = '/dev/null' + endif + if targetos == 'darwin' + icon = '...' emulators += {exe['name'] : custom_target(exe['name'], depends: emulator, output: exe['name'],
@@ -2528,14 +2534,14 @@ foreach target : target_dirs meson.current_source_dir() / 'scripts/entitlement.sh', 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', get_option('bindir') / exe_name, get_option('bindir') / exe['name'], - meson.current_source_dir() / 'accel/hvf/entitlements.plist') + entitlements, icon) else emulators += {exe['name']: emulator} endif
scripts/entitlement.sh +5 -1
@@ -11,6 +11,7 @@ fi SRC="$1" DST="$2" ENTITLEMENT="$3" +ICON="$4" if $in_place; then trap 'rm "$DST.tmp"' exit
@@ -20,6 +21,9 @@ else cd "$MESON_INSTALL_DESTDIR_PREFIX" fi -codesign --entitlements "$ENTITLEMENT" --force -s - "$SRC" +if test "$ENTITLEMENT" != '/dev/null'; then + codesign --entitlements "$ENTITLEMENT" --force -s - "$SRC" +fi +# icon stuff here mv -f "$SRC" "$DST" trap '' exit
Paolo