mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-25 05:48:03 -04:00
Merge branch 'master' of https://github.com/fabiangreffrath/woof
This commit is contained in:
commit
92d295da3c
14
.github/workflows/main.yml
vendored
14
.github/workflows/main.yml
vendored
@ -3,6 +3,8 @@ name: build
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
tags-ignore: ['*']
|
||||
paths-ignore: ['**.md']
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
@ -18,7 +20,7 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: sudo apt-get update && sudo apt-get install libfluidsynth-dev libsdl2-dev libsdl2-mixer-dev libsdl2-net-dev ninja-build
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Configure
|
||||
env:
|
||||
@ -40,7 +42,7 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: sudo apt-get update && sudo apt-get install cppcheck
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Run cppcheck
|
||||
shell: bash
|
||||
@ -68,7 +70,7 @@ jobs:
|
||||
mingw-w64-x86_64-SDL2_mixer
|
||||
mingw-w64-x86_64-SDL2_net
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Configure
|
||||
run: cmake -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DENABLE_WERROR=ON
|
||||
@ -82,7 +84,7 @@ jobs:
|
||||
cpack -G ZIP
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Win64
|
||||
path: build/*.zip
|
||||
@ -91,7 +93,7 @@ jobs:
|
||||
runs-on: windows-2019
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Configure
|
||||
run: cmake -B build -T v141_xp -A Win32 -DENABLE_WERROR=ON
|
||||
@ -109,7 +111,7 @@ jobs:
|
||||
cpack -G ZIP
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: WinXP
|
||||
path: build/Woof*.zip
|
||||
|
10
.github/workflows/release.yml
vendored
10
.github/workflows/release.yml
vendored
@ -11,14 +11,13 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Version
|
||||
id: get_version
|
||||
run: echo ::set-output name=VERSION::${GITHUB_REF##*_}
|
||||
run: echo "VERSION=${GITHUB_REF##*_}" >> $GITHUB_ENV
|
||||
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
name: Woof! ${{ steps.get_version.outputs.VERSION }}
|
||||
name: Woof! ${{ env.VERSION }}
|
||||
|
||||
win64_msys2:
|
||||
runs-on: windows-latest
|
||||
@ -40,7 +39,8 @@ jobs:
|
||||
mingw-w64-x86_64-SDL2
|
||||
mingw-w64-x86_64-SDL2_mixer
|
||||
mingw-w64-x86_64-SDL2_net
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Configure
|
||||
run: cmake -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DENABLE_WERROR=ON
|
||||
@ -64,7 +64,7 @@ jobs:
|
||||
runs-on: windows-2019
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Configure
|
||||
run: cmake -B build -T v141_xp -A Win32 -DENABLE_WERROR=ON
|
||||
|
@ -139,19 +139,55 @@ if (WIN32)
|
||||
list(APPEND WOOF_LIBRARIES winmm)
|
||||
endif()
|
||||
|
||||
# Some platforms have SDL2main, others don't.
|
||||
if(SDL2_MAIN_LIBRARY)
|
||||
list(APPEND WOOF_LIBRARIES SDL2::SDL2main)
|
||||
endif()
|
||||
|
||||
# Standard target definition
|
||||
if(WIN32)
|
||||
add_library(woof SHARED EXCLUDE_FROM_ALL ${WOOF_SOURCES})
|
||||
target_compile_definitions(woof PRIVATE WIN_LAUNCHER)
|
||||
# Some platforms have SDL2main, others don't.
|
||||
if(SDL2_MAIN_LIBRARY)
|
||||
list(APPEND WIN_LAUNCHER_LIBS SDL2::SDL2main)
|
||||
endif()
|
||||
list(APPEND WIN_LAUNCHER_LIBS SDL2::SDL2 woof)
|
||||
|
||||
add_executable(woof-com WIN32 ../win32/win_launcher.c)
|
||||
target_woof_settings(woof-com)
|
||||
target_link_libraries(woof-com PRIVATE ${WIN_LAUNCHER_LIBS})
|
||||
if(MSVC)
|
||||
# MSVC tries to supply a default manifest and complains when it finds
|
||||
# ours unless we specifically tell it not to.
|
||||
target_link_options(woof-com PRIVATE "/MANIFEST:NO" "/SUBSYSTEM:CONSOLE")
|
||||
else()
|
||||
target_link_options(woof-com PRIVATE "-mconsole")
|
||||
endif()
|
||||
set_target_properties(woof-com PROPERTIES
|
||||
RUNTIME_OUTPUT_NAME "woof"
|
||||
SUFFIX ".com"
|
||||
)
|
||||
|
||||
# Stamp out and compile resource file on Windows.
|
||||
configure_file(resource.rc.in "${CMAKE_CURRENT_BINARY_DIR}/resource.rc")
|
||||
list(APPEND WOOF_SOURCES "${CMAKE_CURRENT_BINARY_DIR}/resource.rc")
|
||||
add_executable(woof-exe WIN32
|
||||
../win32/win_launcher.c
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/resource.rc"
|
||||
)
|
||||
target_woof_settings(woof-exe)
|
||||
target_link_libraries(woof-exe PRIVATE ${WIN_LAUNCHER_LIBS})
|
||||
if(MSVC)
|
||||
# MSVC tries to supply a default manifest and complains when it finds
|
||||
# ours unless we specifically tell it not to.
|
||||
target_link_options(woof-exe PRIVATE "/MANIFEST:NO")
|
||||
endif()
|
||||
set_target_properties(woof-exe PROPERTIES
|
||||
RUNTIME_OUTPUT_NAME "woof"
|
||||
SUFFIX ".exe"
|
||||
)
|
||||
else()
|
||||
# Some platforms have SDL2main, others don't.
|
||||
if(SDL2_MAIN_LIBRARY)
|
||||
list(APPEND WOOF_LIBRARIES SDL2::SDL2main)
|
||||
endif()
|
||||
add_executable(woof ${WOOF_SOURCES})
|
||||
endif()
|
||||
|
||||
# Standard target definition
|
||||
add_executable(woof WIN32 ${WOOF_SOURCES})
|
||||
target_woof_settings(woof)
|
||||
target_include_directories(woof PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../")
|
||||
|
||||
@ -168,14 +204,6 @@ endif()
|
||||
target_link_libraries(woof PRIVATE ${WOOF_LIBRARIES}
|
||||
SDL2::SDL2 SDL2::mixer SDL2::net opl textscreen)
|
||||
|
||||
if(MSVC)
|
||||
# MSVC tries to supply a default manifest and complains when it finds ours
|
||||
# unless we specifically tell it not to.
|
||||
set_target_properties(woof PROPERTIES LINK_FLAGS "/MANIFEST:NO")
|
||||
# Enable console for debug build.
|
||||
set_target_properties(woof PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
|
||||
endif()
|
||||
|
||||
# Optional features.
|
||||
#
|
||||
# Our defines are not namespaced, so we pass them at compile-time instead of
|
||||
@ -224,23 +252,6 @@ target_link_libraries(woof-setup PRIVATE ${SETUP_LIBRARIES}
|
||||
|
||||
if(MSVC)
|
||||
set_target_properties(woof-setup PROPERTIES LINK_FLAGS "/MANIFEST:NO")
|
||||
set_target_properties(woof-setup PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
add_executable(conredir WIN32 "../win32/win_console_wrapper.c")
|
||||
target_woof_settings(conredir)
|
||||
if(MSVC)
|
||||
set_target_properties(conredir PROPERTIES
|
||||
LINK_FLAGS "/MANIFEST:NO /SUBSYSTEM:CONSOLE")
|
||||
else()
|
||||
set_target_properties(conredir PROPERTIES LINK_FLAGS "-municode -mconsole")
|
||||
endif()
|
||||
|
||||
add_custom_command(TARGET conredir POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy
|
||||
"$<TARGET_FILE_DIR:woof>/conredir.exe"
|
||||
"$<TARGET_FILE_DIR:woof>/woof.com" VERBATIM)
|
||||
endif()
|
||||
|
||||
# Install
|
||||
@ -275,8 +286,7 @@ endforeach()
|
||||
|
||||
# Files to package in our distribution.
|
||||
if(WIN32)
|
||||
install(TARGETS woof woof-setup RUNTIME DESTINATION .)
|
||||
install(FILES "$<TARGET_FILE_DIR:woof>/woof.com" DESTINATION .)
|
||||
install(TARGETS woof woof-exe woof-com woof-setup RUNTIME DESTINATION .)
|
||||
else()
|
||||
install(TARGETS woof woof-setup RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
|
@ -103,15 +103,15 @@ static void I_Signal(void)
|
||||
|
||||
void D_DoomMain(void);
|
||||
|
||||
#if defined(WIN_LAUNCHER)
|
||||
__declspec(dllexport) int Woof_Main(int argc, char **argv)
|
||||
#else
|
||||
int main(int argc, char **argv)
|
||||
#endif
|
||||
{
|
||||
myargc = argc;
|
||||
myargv = argv;
|
||||
|
||||
#ifdef _WIN32
|
||||
I_WinConsole();
|
||||
#endif
|
||||
|
||||
//!
|
||||
//
|
||||
// Print the program version and exit.
|
||||
|
@ -121,43 +121,6 @@ static boolean I_ConsoleStdout(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
static void ReopenConsoleHandle(DWORD std, FILE *stream)
|
||||
{
|
||||
HANDLE handle = GetStdHandle(std);
|
||||
DWORD lpmode = 0;
|
||||
|
||||
if (GetConsoleMode(handle, &lpmode))
|
||||
{
|
||||
freopen("CONOUT$", "wt", stream);
|
||||
}
|
||||
}
|
||||
|
||||
boolean I_WinConsole(void)
|
||||
{
|
||||
wchar_t console_env[4] = {0};
|
||||
|
||||
if (!GetEnvironmentVariableW(L"_started_from_console", console_env, 4))
|
||||
return false;
|
||||
|
||||
if (wcsncmp(console_env, L"yes", 4))
|
||||
return false;
|
||||
|
||||
SetEnvironmentVariableW(L"_started_from_console", NULL);
|
||||
|
||||
if (!AttachConsole(ATTACH_PARENT_PROCESS))
|
||||
return false;
|
||||
|
||||
// We have a console window. Redirect input/output streams to that console's
|
||||
// low-level handles, so things that use stdio work later on.
|
||||
|
||||
ReopenConsoleHandle(STD_OUTPUT_HANDLE, stdout);
|
||||
ReopenConsoleHandle(STD_ERROR_HANDLE, stderr);
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// I_Error
|
||||
//
|
||||
|
@ -1,98 +0,0 @@
|
||||
/*
|
||||
* conredir, a hack to get working console IO with Windows GUI applications
|
||||
*
|
||||
* Copyright (c) 2013, Martin Herkt
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
int wmain(int argc, wchar_t **argv, wchar_t **envp);
|
||||
|
||||
static void cr_perror(const wchar_t *prefix)
|
||||
{
|
||||
wchar_t *error;
|
||||
|
||||
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPWSTR)&error, 0, NULL);
|
||||
|
||||
fwprintf(stderr, L"%s: %s", prefix, error);
|
||||
LocalFree(error);
|
||||
}
|
||||
|
||||
static int cr_runproc(wchar_t *name, wchar_t *cmdline)
|
||||
{
|
||||
STARTUPINFOW si;
|
||||
STARTUPINFOW our_si;
|
||||
PROCESS_INFORMATION pi;
|
||||
DWORD retval = 1;
|
||||
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
si.cb = sizeof(si);
|
||||
si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
|
||||
si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
||||
si.dwFlags |= STARTF_USESTDHANDLES;
|
||||
|
||||
// Copy the list of inherited CRT file descriptors to the new process
|
||||
our_si.cb = sizeof(our_si);
|
||||
GetStartupInfoW(&our_si);
|
||||
si.lpReserved2 = our_si.lpReserved2;
|
||||
si.cbReserved2 = our_si.cbReserved2;
|
||||
|
||||
ZeroMemory(&pi, sizeof(pi));
|
||||
|
||||
if (!CreateProcessW(name, cmdline, NULL, NULL, TRUE, 0,
|
||||
NULL, NULL, &si, &pi)) {
|
||||
|
||||
cr_perror(L"CreateProcess");
|
||||
} else {
|
||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||
GetExitCodeProcess(pi.hProcess, &retval);
|
||||
CloseHandle(pi.hProcess);
|
||||
CloseHandle(pi.hThread);
|
||||
}
|
||||
|
||||
return (int)retval;
|
||||
}
|
||||
|
||||
int wmain(int argc, wchar_t **argv, wchar_t **envp)
|
||||
{
|
||||
wchar_t *cmd;
|
||||
wchar_t exe[MAX_PATH];
|
||||
UINT orig_code_page;
|
||||
int ret;
|
||||
|
||||
cmd = GetCommandLineW();
|
||||
GetModuleFileNameW(NULL, exe, MAX_PATH);
|
||||
wcscpy(wcsrchr(exe, '.') + 1, L"exe");
|
||||
|
||||
// Set an environment variable so the child process can tell whether it
|
||||
// was started from this wrapper and attach to the console accordingly
|
||||
SetEnvironmentVariableW(L"_started_from_console", L"yes");
|
||||
|
||||
orig_code_page = GetConsoleOutputCP();
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
|
||||
ret = cr_runproc(exe, cmd);
|
||||
|
||||
SetConsoleOutputCP(orig_code_page);
|
||||
|
||||
return ret;
|
||||
}
|
22
win32/win_launcher.c
Normal file
22
win32/win_launcher.c
Normal file
@ -0,0 +1,22 @@
|
||||
//
|
||||
// Copyright(C) 2022 Roman Fomin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
__declspec(dllexport) extern int Woof_Main(int argc, char** argv);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
return Woof_Main(argc, argv);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user