diff --git a/.github/build.sh b/.github/build.sh index 9e410847f..4d4ed695d 100755 --- a/.github/build.sh +++ b/.github/build.sh @@ -309,6 +309,9 @@ if [[ $RELEASE_TYPE != dev ]]; then fi if [[ "$BSH_HOST_PLATFORM-$BSH_HOST_LIBC" == "windows-mingw" ]]; then meson_configure+=$'\t'--cross-file=.github/mingw-ghactions.ini + # there is some mingw bug that only ever manifests on ghactions which makes MakeIco.exe use tons of memory and fail + # TODO: remove this hack once we figure out how to fix that + meson_configure+=$'\t'-Dwindows_icons=false fi if [[ $BSH_DEBUG_RELEASE-$BSH_STATIC_DYNAMIC == release-static ]]; then meson_configure+=$'\t'-Db_lto=true diff --git a/meson_options.txt b/meson_options.txt index 3ea9c0af6..eee6a57be 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -293,3 +293,9 @@ option( value: 'auto', description: 'Show blue error screen upon unhandled signals and exceptions' ) +option( + 'windows_icons', + type: 'boolean', + value: true, + description: 'Add icon resources to the executable on Windows' +) diff --git a/resources/meson.build b/resources/meson.build index 44a470ce2..c493f5864 100644 --- a/resources/meson.build +++ b/resources/meson.build @@ -32,42 +32,52 @@ else endif if host_platform == 'windows' - make_ico = executable('makeico', sources: 'MakeIco.cpp', native: true) - generated_win_icos = {} - win_icos = { - 'icon_exe': [ 'icon_exe', 'icon_exe_48', 'icon_exe_32', 'icon_exe_16' ], - 'icon_cps': [ 'icon_cps', 'icon_cps_48', 'icon_cps_32', 'icon_cps_16' ], - } - foreach key, icons : win_icos - command = [ - make_ico, - '@OUTPUT@', - ] - foreach ikey : icons - command += [ rendered_icons[ikey] ] + windows_icons = get_option('windows_icons') + rc_conf_depends = [] + icon_exe_ico_path = '' + icon_cps_ico_path = '' + if windows_icons + make_ico = executable('makeico', sources: 'MakeIco.cpp', native: true) + generated_win_icos = {} + win_icos = { + 'icon_exe': [ 'icon_exe', 'icon_exe_48', 'icon_exe_32', 'icon_exe_16' ], + 'icon_cps': [ 'icon_cps', 'icon_cps_48', 'icon_cps_32', 'icon_cps_16' ], + } + foreach key, icons : win_icos + command = [ + make_ico, + '@OUTPUT@', + ] + foreach ikey : icons + command += [ rendered_icons[ikey] ] + endforeach + generated_win_icos += { key: custom_target( + key + '-ico', + output: key + '.ico', + command: command, + ) } endforeach - generated_win_icos += { key: custom_target( - key + '-ico', - output: key + '.ico', - command: command, - ) } - endforeach + rc_conf_depends += [ + generated_win_icos['icon_exe'], + generated_win_icos['icon_cps'], + ] + icon_exe_ico_path = join_paths(meson.current_build_dir(), 'icon_exe.ico') + icon_cps_ico_path = join_paths(meson.current_build_dir(), 'icon_cps.ico') + endif rc_conf_data = configuration_data() rc_conf_data.merge_from(conf_data) + rc_conf_data.set('HAVE_ICONS', windows_icons ? 1 : 0) rc_conf_data.set('RESOUCE_H', join_paths(meson.current_source_dir(), 'resource.h')) rc_conf_data.set('WINUTF8_XML', join_paths(meson.current_source_dir(), 'winutf8.xml')) - rc_conf_data.set('ICON_EXE_ICO', join_paths(meson.current_build_dir(), 'icon_exe.ico')) - rc_conf_data.set('ICON_CPS_ICO', join_paths(meson.current_build_dir(), 'icon_cps.ico')) + rc_conf_data.set('ICON_EXE_ICO', icon_exe_ico_path) + rc_conf_data.set('ICON_CPS_ICO', icon_cps_ico_path) powder_files += windows_mod.compile_resources( configure_file( input: 'powder-res.template.rc', output: 'powder-res.rc', configuration: rc_conf_data, ), - depends: [ - generated_win_icos['icon_exe'], - generated_win_icos['icon_cps'], - ], + depends: rc_conf_depends, depend_files: [ 'resource.h', 'winutf8.xml', diff --git a/resources/powder-res.template.rc b/resources/powder-res.template.rc index 1dc26c785..afee63ac0 100644 --- a/resources/powder-res.template.rc +++ b/resources/powder-res.template.rc @@ -5,8 +5,11 @@ #include #include +#define HAVE_ICONS @HAVE_ICONS@ +#if HAVE_ICONS IDI_ICON ICON DISCARDABLE "@ICON_EXE_ICO@" IDI_DOC_ICON ICON DISCARDABLE "@ICON_CPS_ICO@" +#endif CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "@WINUTF8_XML@" VS_VERSION_INFO VERSIONINFO