All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Set icon for QEMU binary on Mac OS
@ 2021-07-05 13:54 Programmingkid
  2021-07-05 16:56 ` Paolo Bonzini
  0 siblings, 1 reply; 6+ messages in thread
From: Programmingkid @ 2021-07-05 13:54 UTC (permalink / raw)
  To: Paolo Bonzini, QEMU devel list

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.

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
---
 meson.build | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/meson.build b/meson.build
index f00b7754fd..7f534f4e75 100644
--- a/meson.build
+++ b/meson.build
@@ -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,
-- 
2.24.3 (Apple Git-128)




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Set icon for QEMU binary on Mac OS
  2021-07-05 13:54 [PATCH] Set icon for QEMU binary on Mac OS Programmingkid
@ 2021-07-05 16:56 ` Paolo Bonzini
  0 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2021-07-05 16:56 UTC (permalink / raw)
  To: Programmingkid, QEMU devel list

On 05/07/21 15:54, Programmingkid wrote:
> 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.

> +# 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:

diff --git a/meson.build b/meson.build
index 380b40ba07..5313cf4a32 100644
--- a/meson.build
+++ b/meson.build
@@ -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
diff --git a/scripts/entitlement.sh b/scripts/entitlement.sh
index f7aaaf2766..573bed0c2f 100755
--- a/scripts/entitlement.sh
+++ b/scripts/entitlement.sh
@@ -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



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Set icon for QEMU binary on Mac OS
  2021-02-04 15:42     ` Peter Maydell
@ 2021-02-04 17:48       ` Paolo Bonzini
  0 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2021-02-04 17:48 UTC (permalink / raw)
  To: Peter Maydell, Programmingkid; +Cc: QEMU Developers

On 04/02/21 16:42, Peter Maydell wrote:
> On Thu, 4 Feb 2021 at 15:39, Programmingkid <programmingkidx@gmail.com> wrote:
>>
>>
>>
>>> On Feb 4, 2021, at 3:54 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
>>>
>>> On 02/02/21 14:44, John Arbuckle wrote:
>>>> 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.
>>>> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
>>>> ---
>>>>   meson.build | 20 ++++++++++++++++++++
>>>>   1 file changed, 20 insertions(+)
>>>> diff --git a/meson.build b/meson.build
>>>> index f00b7754fd..7f534f4e75 100644
>>>> --- a/meson.build
>>>> +++ b/meson.build
>>>> @@ -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,
>>>
>>> Maybe you can do it on install, using add_install_script instead?
> 
> Why would we want to only do it on install? A QEMU which
> you run from the build tree ought to still have its icon,
> surely ?

Mostly because edit-in-place commands are not very well suited to a 
"make" workflow, while they're common at install time (e.g. strip).

But since we already have scripts/entitlement.sh, and it's only Apple 
that like in-place build steps it is even better to combine all the 
in-place adjustment to the executable in scripts/entitlement.sh.  For 
example if no entitlements are needed, you pass an empty third argument 
and scripts/entitlement.sh (now scripts/postprocess-darwin-executable.sh 
or something like that?) can do Rez+SetFile but not codesign.  The 
existing "if exe_sign" becomes an "if targetos == 'darwin'".

Paolo



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Set icon for QEMU binary on Mac OS
  2021-02-04 15:39   ` Programmingkid
@ 2021-02-04 15:42     ` Peter Maydell
  2021-02-04 17:48       ` Paolo Bonzini
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2021-02-04 15:42 UTC (permalink / raw)
  To: Programmingkid; +Cc: Paolo Bonzini, QEMU Developers

On Thu, 4 Feb 2021 at 15:39, Programmingkid <programmingkidx@gmail.com> wrote:
>
>
>
> > On Feb 4, 2021, at 3:54 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> >
> > On 02/02/21 14:44, John Arbuckle wrote:
> >> 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.
> >> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
> >> ---
> >>  meson.build | 20 ++++++++++++++++++++
> >>  1 file changed, 20 insertions(+)
> >> diff --git a/meson.build b/meson.build
> >> index f00b7754fd..7f534f4e75 100644
> >> --- a/meson.build
> >> +++ b/meson.build
> >> @@ -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,
> >
> > Maybe you can do it on install, using add_install_script instead?

Why would we want to only do it on install? A QEMU which
you run from the build tree ought to still have its icon,
surely ?

-- PMM


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Set icon for QEMU binary on Mac OS
       [not found] ` <2cdac45d-6a4d-dca1-4f32-2fc6b549f8d5@redhat.com>
@ 2021-02-04 15:39   ` Programmingkid
  2021-02-04 15:42     ` Peter Maydell
  0 siblings, 1 reply; 6+ messages in thread
From: Programmingkid @ 2021-02-04 15:39 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Peter Maydell, QEMU Developers



> On Feb 4, 2021, at 3:54 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> 
> On 02/02/21 14:44, John Arbuckle wrote:
>> 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.
>> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
>> ---
>>  meson.build | 20 ++++++++++++++++++++
>>  1 file changed, 20 insertions(+)
>> diff --git a/meson.build b/meson.build
>> index f00b7754fd..7f534f4e75 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -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,
> 
> Maybe you can do it on install, using add_install_script instead?
> 
> Paolo

The script would only be two lines long:

    Rez -append ./pc-bios/qemu.rsrc -o $(QEMU_BINARY)
    SetFile -a C $(QEMU_BINARY)

Is a separate script file still preferred?



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] Set icon for QEMU binary on Mac OS
@ 2021-02-02 13:44 John Arbuckle
       [not found] ` <2cdac45d-6a4d-dca1-4f32-2fc6b549f8d5@redhat.com>
  0 siblings, 1 reply; 6+ messages in thread
From: John Arbuckle @ 2021-02-02 13:44 UTC (permalink / raw)
  To: qemu-devel, peter.maydell; +Cc: John Arbuckle

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.

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
---
 meson.build | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/meson.build b/meson.build
index f00b7754fd..7f534f4e75 100644
--- a/meson.build
+++ b/meson.build
@@ -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,
-- 
2.24.3 (Apple Git-128)



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-05 16:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-05 13:54 [PATCH] Set icon for QEMU binary on Mac OS Programmingkid
2021-07-05 16:56 ` Paolo Bonzini
  -- strict thread matches above, loose matches on Subject: below --
2021-02-02 13:44 John Arbuckle
     [not found] ` <2cdac45d-6a4d-dca1-4f32-2fc6b549f8d5@redhat.com>
2021-02-04 15:39   ` Programmingkid
2021-02-04 15:42     ` Peter Maydell
2021-02-04 17:48       ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.