From a63dd47f2d8e93fd7bdc048593f75333f1538448 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Mon, 28 May 2018 22:26:32 +0200 Subject: [PATCH] Make CreateProcess() flags depend on "noconsole" On Windows, display the output of external commands (adb) when a console is available. --- app/meson.build | 3 +++ app/src/sys/win/command.c | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/meson.build b/app/meson.build index e092ce97..2863ebff 100644 --- a/app/meson.build +++ b/app/meson.build @@ -126,6 +126,9 @@ conf.set('SKIP_FRAMES', get_option('skip_frames')) # enable High DPI support conf.set('HIDPI_SUPPORT', get_option('hidpi_support')) +# disable console on Windows +conf.set('WINDOWS_NOCONSOLE', get_option('windows_noconsole')) + configure_file(configuration: conf, output: 'config.h') src_dir = include_directories('src') diff --git a/app/src/sys/win/command.c b/app/src/sys/win/command.c index 719d985d..32d2a8b8 100644 --- a/app/src/sys/win/command.c +++ b/app/src/sys/win/command.c @@ -1,5 +1,6 @@ #include "command.h" +#include "config.h" #include "log.h" #include "strutil.h" @@ -20,7 +21,12 @@ HANDLE cmd_execute(const char *path, const char *const argv[]) { return NULL; } - if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) { +#ifdef WINDOWS_NOCONSOLE + int flags = CREATE_NO_WINDOW; +#else + int flags = 0; +#endif + if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, flags, NULL, NULL, &si, &pi)) { return NULL; }