mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-23 11:39:53 +00:00
ui: Log std{out,err} to file, or console if available on Windows
This commit is contained in:
parent
26e43bbcfd
commit
68f7e11978
12
build.sh
12
build.sh
@ -9,23 +9,19 @@ project_source_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd
|
||||
package_windows() {
|
||||
rm -rf dist
|
||||
mkdir -p dist
|
||||
cp build/qemu-system-i386.exe dist/xemu.exe
|
||||
cp build/qemu-system-i386w.exe dist/xemuw.exe
|
||||
cp build/qemu-system-i386w.exe dist/xemu.exe
|
||||
# cp -r "${project_source_dir}/data" dist/
|
||||
python3 "${project_source_dir}/get_deps.py" dist/xemu.exe dist
|
||||
strip dist/xemu.exe
|
||||
strip dist/xemuw.exe
|
||||
}
|
||||
|
||||
package_wincross() {
|
||||
STRIP=${CROSSPREFIX}strip
|
||||
rm -rf dist
|
||||
mkdir -p dist
|
||||
cp build/qemu-system-i386.exe dist/xemu.exe
|
||||
cp build/qemu-system-i386w.exe dist/xemuw.exe
|
||||
cp build/qemu-system-i386w.exe dist/xemu.exe
|
||||
# cp -r "${project_source_dir}/data" dist/
|
||||
$STRIP dist/xemu.exe
|
||||
$STRIP dist/xemuw.exe
|
||||
}
|
||||
|
||||
package_macos() {
|
||||
@ -196,7 +192,7 @@ case "$platform" in # Adjust compilation options based on platform
|
||||
sys_cflags='-Wno-error'
|
||||
opts="$opts --disable-fortify-source"
|
||||
postbuild='package_windows' # set the above function to be called after build
|
||||
target="qemu-system-i386.exe qemu-system-i386w.exe"
|
||||
target="qemu-system-i386w.exe"
|
||||
;;
|
||||
win64-cross)
|
||||
echo 'Cross-compiling for Windows...'
|
||||
@ -204,7 +200,7 @@ case "$platform" in # Adjust compilation options based on platform
|
||||
sys_cflags='-Wno-error'
|
||||
opts="$opts --cross-prefix=$CROSSPREFIX --static --disable-fortify-source"
|
||||
postbuild='package_wincross' # set the above function to be called after build
|
||||
target="qemu-system-i386.exe qemu-system-i386w.exe"
|
||||
target="qemu-system-i386w.exe"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported platform $platform, aborting" >&2
|
||||
|
22
ui/xemu.c
22
ui/xemu.c
@ -1475,6 +1475,28 @@ int main(int argc, char **argv)
|
||||
{
|
||||
QemuThread thread;
|
||||
|
||||
#ifdef _WIN32
|
||||
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
|
||||
// Launched with a console. If stdout and stderr are not associated with
|
||||
// an output stream, redirect to parent console.
|
||||
if (_fileno(stdout) == -2) {
|
||||
freopen("CONOUT$", "w+", stdout);
|
||||
}
|
||||
if (_fileno(stderr) == -2) {
|
||||
freopen("CONOUT$", "w+", stderr);
|
||||
}
|
||||
} else {
|
||||
// Launched without a console. Redirect stdout and stderr to a log file.
|
||||
HANDLE logfile = CreateFileA("xemu.log",
|
||||
GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ,
|
||||
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (logfile != INVALID_HANDLE_VALUE) {
|
||||
freopen("xemu.log", "a", stdout);
|
||||
freopen("xemu.log", "a", stderr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
DPRINTF("Entered main()\n");
|
||||
gArgc = argc;
|
||||
gArgv = argv;
|
||||
|
Loading…
Reference in New Issue
Block a user