diff mbox series

Set icon for QEMU binary on Mac OS

Message ID 20210202134410.9274-1-programmingkidx@gmail.com
State New
Headers show
Series Set icon for QEMU binary on Mac OS | expand

Commit Message

Programmingkid Feb. 2, 2021, 1:44 p.m. UTC
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(+)

Comments

Programmingkid Feb. 4, 2021, 3:39 p.m. UTC | #1
> 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?
Peter Maydell Feb. 4, 2021, 3:42 p.m. UTC | #2
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
Paolo Bonzini Feb. 4, 2021, 5:48 p.m. UTC | #3
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
diff mbox series

Patch

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,