Skip to content

Commit 667d11e

Browse files
committed
Embed the app icon, for Windows so that it displays correctly as a program shortcut.
1 parent 9c77186 commit 667d11e

5 files changed

Lines changed: 70 additions & 8 deletions

File tree

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Debug with Meson",
66
"type": "cppdbg",
77
"request": "launch",
8-
"program": "${workspaceFolder}/build/galaxy_visualization_raylib",
8+
"program": "${workspaceFolder}/build/Galaxy_Visualization_Linux_v0.5.2",
99
"args": [],
1010
"stopAtEntry": false,
1111
"cwd": "${workspaceFolder}",

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,20 @@ This project can be built using clang/gcc through build.sh (raylib is the only d
2727
- **Meson** (optional)
2828
- **Python3** (optional, for embedded build compression)
2929
- **gdb** (optional)
30+
- **ImageMagick** (required for Windows icon embedding in mingw builds)
3031

3132
## Installation Commands
3233

3334
### Arch Linux
3435

3536
```bash
36-
sudo pacman -S raylib base-devel meson git clang python
37+
sudo pacman -S raylib base-devel meson git clang python imagemagick
3738
```
3839

3940
### Ubuntu
4041

4142
```bash
42-
sudo apt-get install -y raylib build-essential meson git clang python3
43+
sudo apt-get install -y raylib build-essential meson git clang python3 imagemagick
4344
```
4445

4546
## Building
@@ -119,6 +120,9 @@ meson setup build_mingw_embedded_static --cross-file ./cross/mingw64.ini -Dembed
119120
meson compile -C build_mingw_embedded_static
120121
```
121122

123+
Notes:
124+
- Windows builds embed the app icon into the .exe using ImageMagick during the build.
125+
122126
Or using build.sh:
123127

124128
```bash

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ if [ "$STATIC_RAYLIB" = true ]; then
6969

7070
if [ ! -f "$RAYLIB_STATIC_LIB" ]; then
7171
echo "=== Building raylib static library (subproject)... ==="
72-
make -C "$RAYLIB_MAKE_DIR" PLATFORM=PLATFORM_DESKTOP CC="$CC"
72+
make -C "$RAYLIB_MAKE_DIR" PLATFORM=PLATFORM_DESKTOP CC="$CC" CFLAGS="-w"
7373
fi
7474

7575
INCLUDE_DIRS="$INCLUDE_DIRS -I$RAYLIB_SUBPROJECT_DIR/src"

meson.build

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project('galaxy_visualization_raylib', 'c',
2-
version : '0.5.1',
2+
version : '0.5.2',
33
default_options : [
44
'c_std=c99',
55

@@ -13,15 +13,18 @@ project('galaxy_visualization_raylib', 'c',
1313
'warning_level=3',
1414
'c_args=-Wall',
1515
'c_args=-Wextra',
16-
'c_args=-Werror',
1716
'c_args=-Wpedantic',
1817
]
1918
)
2019

2120
raylib_static = get_option('raylib_static')
2221

2322
if raylib_static
24-
raylib_sub = subproject('raylib')
23+
raylib_sub = subproject('raylib', default_options: [
24+
'warning_level=0',
25+
'werror=false',
26+
'c_args=-w',
27+
])
2528
raylib_dep = raylib_sub.get_variable('raylib_dep')
2629
else
2730
raylib_dep = dependency('raylib', required: true, static: false)
@@ -35,6 +38,12 @@ if host_machine.system() != 'windows'
3538
platform_c_args += ['-march=native']
3639
endif
3740

41+
extra_c_args += ['-Werror']
42+
43+
if host_machine.system() == 'windows'
44+
extra_c_args += ['-Wno-error=type-limits']
45+
endif
46+
3847
# Generate embedded asset headers at configure time
3948
if embed_assets
4049
message('EMBED_ASSETS enabled - generating embedded headers...')
@@ -48,8 +57,37 @@ sources = [
4857
'src/unity_build.c',
4958
]
5059

60+
if host_machine.system() == 'windows'
61+
magick_prog = find_program('magick', 'convert', required: true)
62+
icon_resources = custom_target(
63+
'app_icon_resources',
64+
input: files('assets/images/app_icon.png'),
65+
output: ['app_icon.ico', 'app.rc'],
66+
command: [
67+
'bash',
68+
meson.project_source_root() / 'scripts/generate_windows_icon_resources.sh',
69+
'@INPUT@',
70+
'@OUTDIR@',
71+
magick_prog,
72+
],
73+
build_by_default: true,
74+
)
75+
76+
windows_mod = import('windows')
77+
sources += windows_mod.compile_resources(icon_resources[1])
78+
endif
79+
80+
platform_label = host_machine.system()
81+
if platform_label == 'windows'
82+
platform_label = 'Win64'
83+
elif platform_label == 'linux'
84+
platform_label = 'Linux'
85+
endif
86+
87+
exe_name = 'Galaxy_Visualization_' + platform_label + '_v' + meson.project_version()
88+
5189
exe = executable(
52-
'galaxy_visualization_raylib',
90+
exe_name,
5391
sources,
5492
dependencies: raylib_dep,
5593
c_args: [
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
if [[ $# -lt 3 ]]; then
6+
echo "Usage: $0 <input_png> <output_dir> <magick_path>" >&2
7+
exit 1
8+
fi
9+
10+
input_png="$1"
11+
output_dir="$2"
12+
magick_bin="$3"
13+
14+
mkdir -p "$output_dir"
15+
16+
"$magick_bin" "$input_png" -define icon:auto-resize=256,128,64,48,32,16 "$output_dir/app_icon.ico"
17+
18+
cat > "$output_dir/app.rc" <<'EOF'
19+
APP_ICON ICON "app_icon.ico"
20+
EOF

0 commit comments

Comments
 (0)