Add a .ico or .png to the .exe file in vlang?
Describe the feature
Pass a parameter via terminal/cmd -icon= or --icon= or --seticon= to set a .ico or .png into/within the .exe file.
Use Case
./v --icon=my_icon.ico file.v
Proposed Solution
Idk if this will help, but Nim lang and Python's Pyinstaller and Nuitka do this, rcedit maybe looking how they do can give insights
Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
Version used
weekly.2023.33
Environment details (OS name and version, etc.)
OS: windows, Microsoft Windows 10 Pro v19045 64 bits Processor: 6 cpus, 64bit, little endian,
getwd: C:\Users\dutr4\Desktop\v vexe: C:\Users\dutr4\Desktop\v\v.exe vexe mtime: 2023-08-15 23:36:18
vroot: OK, value: C:\Users\dutr4\Desktop\v VMODULES: OK, value: C:\Users\dutr4.vmodules VTMP: OK, value: C:\Users\dutr4\AppData\Local\Temp\v_0
Git version: git version 2.35.1.windows.1 Git vroot status: Error: fatal: not a git repository (or any of the parent directories): .git .git/config present: false
CC version: Error: exec failed (CreateProcess) with code 2: O sistema não pode encontrar o arquivo especificado. cmd: cc --version thirdparty/tcc: N/A
I like this idea. But I think instead of a command V should just automatically check if a file exists in the directory being compiled. If executable_icon.ico exists, then add it. If not, proceed as normal.
I use these steps to create an Icon file, a resource file and add them all to the exe. Then the Details page of the exe file is also filled:
- Take an png file with a resolution of 256x256
- Download imagemagic and use the convert.exe to create an icon file with icons in different sizes. convert.exe icon.png -define icon:auto-resize=16,24,32,48,64,256 -compress zip icon.ico
- Create a resource file. For example prg.rc with following content (adjust it as needed)
ID ICON "Full path to your icon file/ICON.ico"
1 VERSIONINFO
FILEVERSION 2023, 8, 25, 0
PRODUCTVERSION 2023, 8, 25, 0
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "H. F."
VALUE "FileDescription", "Tool collection"
VALUE "FileVersion", "1.0.1.1"
VALUE "InternalName", "HFTools"
VALUE "LegalCopyright", "(c) H. F. Copyright 2023"
VALUE "OriginalFilename", "HFTools.exe"
VALUE "ProductName", "HFTools"
VALUE "ProductVersion", "1.0.1.0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0, 1200
END
END
- Take the windres.exe from the mingw installation and convert the .rc file to a .res file: windres src\prg.rc -O coff -o src\prg.res
- Add the res file with the -cflag Option to the V compiling: v -b c -cflags "Full path to your res file\prg.res" -o .\distribution\prg.exe -prod .
It would be cool if someone added a PR for examples/ folder doing this. I suppose the solution above only makes sense on Windows. But it's only there where executables have icons as far as I know. Linux uses .desktop files which is metadata collection referencing the icon data outside the ELF binary itself.
Mac OS?