Makefile.target: set icon for binary file on Mac OS X
PATCH 1/1 Makefile.target: set icon for binary file on Mac OS X
This patch adds the instruction to have the build commands give QEMU an icon. This code runs on Mac OS X.
--- Makefile.target | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-) mode change 100644 => 100755 Makefile.target
Makefile.target +20 -1
@@ -75,7 +75,7 @@ else stap: endif -all: $(PROGS) stap +all: $(PROGS) stap give_icon # Dummy command so that make thinks it has done something @true
@@ -208,3 +208,22 @@ endif GENERATED_HEADERS += config-target.h Makefile: $(GENERATED_HEADERS) + +# Set the icon for QEMU on Macintosh +give_icon: + ifdef CONFIG_DARWIN + # Take an image and make the image its own icon: + sips -i ../pc-bios/qemu-nsis.ico + + # Extract the icon to its own resource file: + DeRez -only icns ../pc-bios/qemu-nsis.ico > tmpicns.rsrc + + # append this resource to the file you want to icon-ize. + Rez -append tmpicns.rsrc -o $(QEMU_PROG) + + # Use the resource to set the icon. + SetFile -a C $(QEMU_PROG) + + # clean up. + rm tmpicns.rsrc + endif
Signature · 1 line
1.7.5.4
Makefile.target endif · line 219
Quoted 4 lines · Programmingkid
Makefile.target +4
-0+ # Take an image and make the image its own icon: + sips -i ../pc-bios/qemu-nsis.ico + # Extract the icon to its own resource file: + DeRez -only icns ../pc-bios/qemu-nsis.ico > tmpicns.rsrc
IIUC sips modifies ../pc-bios/qemu-nsis.ico (adding a resource fork?), so it's not possible to put it in Makefile.target. If "sips" is invoked twice by two different recursive invocations of Makefile.target, bad things can happen.
I think we can simply distribute tmpicns.rsrc as pc-bios/qemu.rsrc instead.
Makefile.target endif · line 225
Quoted 5 lines
Makefile.target +5
-0+ # append this resource to the file you want to icon-ize. + Rez -append tmpicns.rsrc -o $(QEMU_PROG) + + # Use the resource to set the icon. + SetFile -a C $(QEMU_PROG)
These two commands can be added after
$(QEMU_PROG_BUILD): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
$(call LINK,$^)
instead of adding a new rule. There is no need for the comments.
Paolo
Quoted 23 lines · Paolo Bonzini
Makefile.target endif · line 219
Quoted 4 lines · Programmingkid
Makefile.target +4
-0+ # Take an image and make the image its own icon: + sips -i ../pc-bios/qemu-nsis.ico + # Extract the icon to its own resource file: + DeRez -only icns ../pc-bios/qemu-nsis.ico > tmpicns.rsrcIIUC sips modifies ../pc-bios/qemu-nsis.ico (adding a resource fork?), so it's not possible to put it in Makefile.target. If "sips" is invoked twice by two different recursive invocations of Makefile.target, bad things can happen.
I think we can simply distribute tmpicns.rsrc as pc-bios/qemu.rsrc instead.
Makefile.target endif · line 225
Quoted 5 lines
Makefile.target +5
-0+ # append this resource to the file you want to icon-ize. + Rez -append tmpicns.rsrc -o $(QEMU_PROG) + + # Use the resource to set the icon. + SetFile -a C $(QEMU_PROG)These two commands can be added after
Quoted 6 lines
$(QEMU_PROG_BUILD): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
$(call LINK,$^)instead of adding a new rule. There is no need for the comments.
Paolo
Ok. Will implement your suggested changes. Thank you.
Quoted 8 lines · Paolo Bonzini
Makefile.target endif · line 219
Quoted 4 lines · Programmingkid
Makefile.target +4
-0+ # Take an image and make the image its own icon: + sips -i ../pc-bios/qemu-nsis.ico + # Extract the icon to its own resource file: + DeRez -only icns ../pc-bios/qemu-nsis.ico > tmpicns.rsrc
Quoted 6 lines
IIUC sips modifies ../pc-bios/qemu-nsis.ico (adding a resource fork?), so it's not possible to put it in Makefile.target. If "sips" is invoked twice by two different recursive invocations of Makefile.target, bad things can happen.
I think we can simply distribute tmpicns.rsrc as pc-bios/qemu.rsrc instead.
Why not just use the sips --out option to specify a different output file? That way we automatically put the current icon into the executable, and don't have to update a hand-created qemu.rsrc file in git if we change the icon in future (and I bet if we don't have the rules for doing this in the makefile then nobody will remember how to do it).
As a bonus we don't have to keep that file full of ugly high-bit-set characters in C comments in git :-)
-- PMM
Quoted 6 lines · Peter Maydell
Why not just use the sips --out option to specify a different output file? That way we automatically put the current icon into the executable, and don't have to update a hand-created qemu.rsrc file in git if we change the icon in future (and I bet if we don't have the rules for doing this in the makefile then nobody will remember how to do it).
I suspect the Windows icon is not a great match for Mac OS X which likes to have big sizes (48x48 or 128x128). If you want to generate the .rsrc file automatically, the right source probably would be the .svg file, and doing the conversion in the Makefile probably isn't entirely feasible. It would need extra build dependency and rounding errors would make it harder to achieve reproducible builds.
Paolo
Quoted 10 lines · Paolo Bonzini
Quoted 6 lines · Peter Maydell
Why not just use the sips --out option to specify a different output file? That way we automatically put the current icon into the executable, and don't have to update a hand-created qemu.rsrc file in git if we change the icon in future (and I bet if we don't have the rules for doing this in the makefile then nobody will remember how to do it).
Quoted 6 lines
I suspect the Windows icon is not a great match for Mac OS X which likes to have big sizes (48x48 or 128x128). If you want to generate the .rsrc file automatically, the right source probably would be the .svg file, and doing the conversion in the
Makefileprobably isn't entirely feasible. It would need extra build dependency and rounding errors would make it harder to achieve reproducible builds.
And depending on the complexity of the SVG not all methods produce the same result. Although it was years ago I recall having a hard time getting gradients to render correctly with ImageMagick. You'll want to compare the ImageMagick/GraphicsMagick and rsvg (apt:librsvg2-bin on Debian) outputs.
Although the current ImageMagick seems to work fine on the logo here. But you'll have to find how to properly specify the size of the SVG (and not use -scale since it'll resize the bitmap, and make it 128x127).
OTOH:
rsvg-convert -w 128 -h 128 ./pc-bios/qemu_logo_no_text.svg > qemu-r.png
seems to generate a proper png with transparency.
It seems inkscape can do it as well, but it's probably a larger dependency:
http://stackoverflow.com/questions/9853325/how-to-convert-a-svg-to-a-png-with-image-magick
François.
Quoted 10 lines · Paolo Bonzini
Quoted 6 lines · Peter Maydell
Why not just use the sips --out option to specify a different output file? That way we automatically put the current icon into the executable, and don't have to update a hand-created qemu.rsrc file in git if we change the icon in future (and I bet if we don't have the rules for doing this in the makefile then nobody will remember how to do it).
Quoted 2 lines
I suspect the Windows icon is not a great match for Mac OS X which likes to have big sizes (48x48 or 128x128).
Definitely true.
Quoted 5 lines
If you want to generate the .rsrc
file automatically, the right source probably would be the .svg file, and doing the conversion in theMakefileprobably isn't entirely feasible. It would need extra build dependency and rounding errors would make it harder to achieve reproducible builds.
Plus the sips command doesn't work with svg files.
Quoted 5 lines · Programmingkid
Quoted 2 lines
I suspect the Windows icon is not a great match for Mac OS X which likes to have big sizes (48x48 or 128x128).
Definitely true.
Quoted 7 lines
Quoted 5 lines
If you want to generate the .rsrc
file automatically, the right source probably would be the .svg file, and doing the conversion in theMakefileprobably isn't entirely feasible. It would need extra build dependency and rounding errors would make it harder to achieve reproducible builds.Plus the sips command doesn't work with svg files.
Ok, so I'll apply v3 to my tree as soon as I get a Tested-by. Please take a look into providing a .rsrc file with larger-sized icons (I think you can add more than one to a single .rsrc file?) and, when you do that, document in pc-bios/README how the resources were built.
Thanks,
Paolo
Quoted 14 lines · Paolo Bonzini
Quoted 11 lines · Programmingkid
Quoted 2 lines
I suspect the Windows icon is not a great match for Mac OS X which likes to have big sizes (48x48 or 128x128).
Definitely true.
Quoted 5 lines
If you want to generate the .rsrc
file automatically, the right source probably would be the .svg file, and doing the conversion in theMakefileprobably isn't entirely feasible. It would need extra build dependency and rounding errors would make it harder to achieve reproducible builds.
Quoted 6 lines
Quoted 1 line
Plus the sips command doesn't work with svg files.
Ok, so I'll apply v3 to my tree as soon as I get a Tested-by. Please take a look into providing a .rsrc file with larger-sized icons (I think you can add more than one to a single .rsrc file?) and, when you do that, document in pc-bios/README how the resources were built.
When I was inspecting the icon using the genie feature of Mac OS X's dock, the icon looked very sharp at full size, so I didn't see a problem with it. What size do you have in mind?
Quoted 9 lines · Programmingkid
Quoted 5 lines
Ok, so I'll apply v3 to my tree as soon as I get a Tested-by. Please take a look into providing a .rsrc file with larger-sized icons (I think you can add more than one to a single .rsrc file?) and, when you do that, document in pc-bios/README how the resources were built.
When I was inspecting the icon using the genie feature of Mac OS X's dock, the icon looked very sharp at full size, so I didn't see a problem with it. What size do you have in mind?
I was thinking of 16x16, 32x32, 48x48 and 128x128.
Paolo
Quoted 9 lines · Paolo Bonzini
Quoted 6 lines · Programmingkid
Quoted 5 lines
Ok, so I'll apply v3 to my tree as soon as I get a Tested-by. Please take a look into providing a .rsrc file with larger-sized icons (I think you can add more than one to a single .rsrc file?) and, when you do that, document in pc-bios/README how the resources were built.
Quoted 5 lines
Quoted 3 lines
When I was inspecting the icon using the genie feature of Mac OS X's dock, the icon looked very sharp at full size, so I didn't see a problem with it. What size do you have in mind?
I was thinking of 16x16, 32x32, 48x48 and 128x128.
What advantages do you think this would give us? Doesn't Mac OS X already resize the icon for you?
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
When I was inspecting the icon using the genie feature of Mac OS X's dock, the icon looked very sharp at full size, so I didn't see a problem with it. What size do you have in mind?
I was thinking of 16x16, 32x32, 48x48 and 128x128.
What advantages do you think this would give us? Doesn't Mac OS X already resize the icon for you?
128x128 is used in the Finder in some cases IIRC. Downsizing from 128x128 to 16x16 isn't great, so whatever sizes are already in the .ico file should be kept (these are 16x16, 32x32 and 48x48) especially if you saw that the 48x48 icon is sharp in the dock. But remember that this is just a nit.
Paolo