meson, build/windows: generate .pdb (CodeView) debug symbols

This makes possible to debug with DIA SDK, if wanted by the developer.
Also, this is needed to create .appxsym files for MS Store debugging.

Ideally meson should be able to install for us, but apparently it doesn't.
See https://github.com/mesonbuild/meson/issues/12977
This commit is contained in:
Jehan 2024-04-07 13:47:09 +02:00 committed by Bruno Lopes
parent 184e2704a4
commit 8cf688ac16
3 changed files with 42 additions and 1 deletions

View File

@ -139,6 +139,13 @@ for exe in "${binArray[@]}"; do
cp -fr $exe ${GIMP_DISTRIB}/bin/
done
### .pdb (CodeView) debug symbols
### TODO: REMOVE 'if [[ "$MSYSTEM...' WHEN GCC 14 IS ON MSYS2
### crossroad don't have LLVM/Clang backend yet
if [[ "$MSYSTEM_CARCH" != "i686" ]] && [[ "$BUILD_TYPE" != "CI_CROSS" ]]; then
cp -fr ${GIMP_PREFIX}/bin/*.pdb ${GIMP_DISTRIB}/bin/
fi
## Optional executables, .DLLs and resources for GObject Introspection support
if [[ "$BUILD_TYPE" != "CI_CROSS" ]]; then
cp -fr ${MSYS_PREFIX}/bin/libgirepository-*.dll ${GIMP_DISTRIB}/bin/

View File

@ -289,6 +289,13 @@ if platform_windows and cc.get_id() == 'gcc'
compiler_args += msvc_compat_args
endif
# Generate .pdb (CodeView) debug symbols (makes possible to debug with DIA SDK)
pdb_support = cc.has_argument('-gcodeview') and cc.has_link_argument('-Wl,--pdb=')
if platform_windows and pdb_support
compiler_args += '-gcodeview'
linker_args += '-Wl,--pdb='
endif
conf.set('HAVE__NL_MEASUREMENT_MEASUREMENT',
cc.compiles('''
@ -2017,7 +2024,14 @@ pkgconfig.generate(libgimpui,
],
)
################################################################################
# Install native debug data (.pdb) on Windows
# Ideally meson should take care of it automatically.
# See: https://github.com/mesonbuild/meson/issues/12977
if platform_windows and pdb_support
install_win_debug_script = find_program('./meson_install_win_debug.sh')
meson.add_install_script(install_win_debug_script)
endif
################################################################################
# Subdir installations

View File

@ -0,0 +1,20 @@
#!/bin/sh
find . \( -iname '*.dll' -or -iname '*.exe' \) | \
while IFS= read -r build_bin;
do
build_bin_name="${build_bin##*/}"
installed_bin=$(find ${MESON_INSTALL_DESTDIR_PREFIX} -iname "$build_bin_name")
if [ x"$installed_bin" != "x" ]; then
install_dir=$(dirname ${installed_bin})
pdb_debug=$(echo $build_bin|sed 's/\.\(dll\|exe\)$/.pdb/')
if [ -f "$pdb_debug" ]; then
# Note: meson hides script outputs anyway on success. But this can be
# useful when debugging.
echo Installing $pdb_debug to $install_dir
if [ -z "$MESON_INSTALL_DRY_RUN" ]; then
cp -f $pdb_debug $install_dir
fi
fi
fi
done;