Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zig logo the the compiler binary on Windows #23395

Closed
wants to merge 2 commits into from

Conversation

LucasSantos91
Copy link
Contributor

On Windows, an image can be embedded into an executable and displayed by the operating system. This PR adds the zig logo to the zig binary. This gives Zig a more polished look.
This is how it looks in light and dark mode:
Zig logo dark mode
Zig logo light mode

The logo was taken from here. The source svg file was transformed into a .ico file via svg2ico.com.
The .ico file is an archive. It contains 4 renditions of the logo as PNG files, for different sizes: 16x16 pixels, 32x32, 48x48 and 256x256, which are the sizes recommended by microsoft.

Copy link
Collaborator

@squeek502 squeek502 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about doing this sort of thing as well when first adding support for Windows resources 🙃.

The CI failure is due to zig2 disabling support for win32 resources (and all JIT commands). The easy solution would be to only add the resource file when compiling a stage4 compiler, but unsure how to go about that at the moment.

@alexrp
Copy link
Member

alexrp commented Mar 28, 2025

This should probably come with a *.ico binary entry in .gitattributes?

@@ -0,0 +1 @@
MAINICON ICON "zig-mark.ico"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Missing a trailing newline.

@LucasSantos91
Copy link
Contributor Author

I still haven't figured out a way to know which stage we are currently executing, in order to skip the addWin32Resource call in stage 2. This is harder than it looks.

@Rexicon226
Copy link
Contributor

The zig_backend is the same, you want to check the dev environment if rc is included.

@squeek502
Copy link
Collaborator

squeek502 commented Mar 28, 2025

Unless I'm thinking about it wrong, it's the dev environment of the zig binary that's being used to compile that's relevant, which can't currently be queried by build.zig I don't think.

I guess you could spawn <current zig binary> rc /? and see if it fails or something like that, but seems like something better should be possible (and due to the JIT compilation of the rc subcommand, that way of querying the capability could take a while).

EDIT: Spawning <current zig binary> --help or <current zig binary> version would be a way of querying it. Those fail with zig2

@Rexicon226
Copy link
Contributor

Ah, I misunderstood the issue.
Then what about adding a @import("builtin") flag for checking whether rc was included?

@LucasSantos91
Copy link
Contributor Author

Well, messing with builtin would be more intrusive than I was expecting for this PR.
Having to rely on something failing would also be more complex than this feature should be.
Perhaps importing builtin and checking if the zig_backend field is greater than 11. Apparently all stage 2 backends are between 1 and 11.

@Rexicon226
Copy link
Contributor

Rexicon226 commented Mar 29, 2025

When would the value be greater than 11?
Anyways, I think the best solution here is to just add an option for including the logo and disabling it in the CI or maybe only include it for the stage4 build.

EDIT: actually that wouldn't work obviously, since we byte-compare stage3 and stage4. Do we really need to test adding it in CI?
EDIT2: do we byte-compare on windows CI?

@LucasSantos91
Copy link
Contributor Author

When would the value be greater than 11?

Yeah... the documentation doesn't say. There are no enums for stage3 or 4, I just assumed these stages would set a different value...

@Rexicon226
Copy link
Contributor

They do not, since the zig backend remains the same.

@LucasSantos91
Copy link
Contributor Author

I don't think this is possible. Stages 3 and 4 need to be identical. Stage 3 is compiled from stage 2. Stage 2 doesn't support resources.
Not a huge deal, just a bit sad. It looked neat.

@marler8997
Copy link
Contributor

If/when someone makes another attempt at this, let's try to avoid unnecessary antialiasing along "orthogonally aligned boundaries". In general this can't or at least is very hard to do automatically from and SVG, you might need to do some fixes by hand after such a conversion.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants