Meson: Avoid UAC on 32-bit Windows for gtk-update-icon-cache

As the program executable name has 'update' in its filename,
gtk-update-icon-cache.exe is considered to be an installer program on 32-bit
Windows [1], which will cause the program to fail to run unless it is running
with elevated privileges (i.e. UAC).

Avoid this situation by embedding a manifest file into the final executable
that tells Windows that this is not a program that requires elevation.

Also make the autotools build files dist the new script and use the new script
to generate the manifest and rc files, instead of hardcoding the generating
bits in gtk/Makefile.am

Fixes issue #3632.

[1]: https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-vista/cc709628(v=ws.10)?redirectedfrom=MSDN,
under section "Installer Detection  Technology"
This commit is contained in:
Chun-wei Fan
2021-02-03 11:30:15 +08:00
parent ddb9bae3d4
commit a612a42c11
3 changed files with 137 additions and 20 deletions

View File

@ -1065,9 +1065,32 @@ gtk_builder_tool = executable(
install: true
)
extra_update_icon_cache_objs = []
if win32_enabled
gen_uac_manifest = find_program('generate-uac-manifest.py')
uac_exe_pkg = 'gtk3'
uac_exe_name = 'gtk-update-icon-cache'
# Well, we have to forgo the xxx.exe.manifest in the output listing, since
# compile_resources doesn't like to consume targets with multiple outputs,
# and the xxx.exe.manifest and xxx.rc are tied together
uac_rc = custom_target(
'gtk/@0@.rc'.format(uac_exe_name),
output: ['@0@.rc'.format(uac_exe_name)],
command: [gen_uac_manifest,
'-p=@0@'.format(uac_exe_pkg),
'-n=@0@'.format(uac_exe_name),
'--pkg-version=@0@'.format(meson.project_version()),
'--output-dir=@OUTDIR@'],
)
extra_update_icon_cache_objs = import('windows').compile_resources(uac_rc)
endif
gtk_update_icon_cache = executable(
'gtk-update-icon-cache',
'updateiconcache.c',
extra_update_icon_cache_objs,
c_args: gtk_cargs,
dependencies: libgtk_dep,
install: true