Dynamically load Dr.Mingw

This improves compatibility with older systems, notably 32bit WinXP.
This commit is contained in:
Robin Gareus 2021-01-02 23:19:40 +01:00
parent 9ff3dc8251
commit caf55e105e
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 23 additions and 10 deletions

View File

@ -74,10 +74,6 @@
#include <shellapi.h> // console
#endif
#ifdef HAVE_DRMINGW
#include <exchndl.h>
#endif
#ifdef WAF_BUILD
#include "gtk2ardour-version.h"
#endif
@ -342,7 +338,12 @@ int main (int argc, char *argv[])
}
#ifdef HAVE_DRMINGW
if (true) {
/* prevent missing libs popups */
UINT prev_error_mode = SetErrorMode (SEM_FAILCRITICALERRORS);
SetErrorMode (prev_error_mode | SEM_FAILCRITICALERRORS);
HMODULE exchndl = LoadLibraryA ("exchndl.dll");
if (exchndl) {
/* %localappdata%\Ardour<X>\CrashLog\ */
string crash_dir = Glib::build_filename (Glib::get_user_data_dir (), string_compose ("%1%2", PROGRAM_NAME, PROGRAM_VERSION), "CrashLog");
g_mkdir_with_parents (crash_dir.c_str(), 0700);
@ -351,10 +352,23 @@ int main (int argc, char *argv[])
string crash_file = string_compose ("%1-%2-crash-%3.txt", PROGRAM_NAME, VERSIONSTRING, tm.format ("%s"));
string crash_path = Glib::build_filename (crash_dir, crash_file);
ExcHndlInit ();
ExcHndlSetLogFileNameA (crash_path.c_str());
cout << "Crash Log: " << crash_path << endl;
typedef void (*exc_init_fn_t) (void);
typedef bool (*exc_path_fn_t) (const char *);
exc_init_fn_t exchndl_init = (exc_init_fn_t) GetProcAddress (exchndl, "ExcHndlInit");
exc_path_fn_t exchndl_path = (exc_path_fn_t) GetProcAddress (exchndl, "ExcHndlSetLogFileNameA");
if (exchndl_init && exchndl_path) {
exchndl_init ();
exchndl_path (crash_path.c_str());
cout << "Crash Log: " << crash_path << endl;
} else {
cout << "Cannot initialize crash reporter" << endl;
}
} else {
cout << "Crash reporter is not compatible with this system" << endl;
}
SetErrorMode (prev_error_mode);
#endif
if (!ARDOUR::init (ARDOUR_COMMAND_LINE::use_vst, ARDOUR_COMMAND_LINE::try_hw_optimization, localedir.c_str(), true)) {

View File

@ -678,7 +678,6 @@ def build(bld):
elif bld.env['build_target'] == 'mingw':
obj.source += [ 'bundle_env_mingw.cc' ]
obj.source += [ 'windows_icon.rc' ]
obj.uselib += ' DRMINGW '
else:
obj.source += [ 'bundle_env_linux.cc' ]

View File

@ -816,7 +816,7 @@ def options(opt):
help='Specify the target for cross-compiling [auto,none,x86,i386,i686,x86_64,tiger,leopard,mingw,msvc]')
opt.add_option('--dr-mingw', action='store_true', default=True, dest='drmingw',
help='Write crashdumps using Dr.Mingw (Windows Only)')
opt.add_option('--no-dr-mingw', action='store_true', dest='drmingw')
opt.add_option('--no-dr-mingw', action='store_false', dest='drmingw')
opt.add_option('--fpu-optimization', action='store_true', default=True, dest='fpu_optimization',
help='Build runtime checked assembler code (default)')
opt.add_option('--no-fpu-optimization', action='store_false', dest='fpu_optimization')