Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Checks: >
-cppcoreguidelines-non-private-member-variables-in-classes,
CheckOptions:
cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor: true
cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams: true
misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: true

readability-identifier-naming.GlobalConstantCase: UPPER_CASE
Expand Down
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "git@github.com:bl-sdk/common_dotfiles.git",
"commit": "a66f9767ed477bfa89d6ca505392d226ebdd4275",
"commit": "fb06ff8c773806b3f8cc69dbda60c0a7b481c6de",
"checkout": null,
"context": {
"cookiecutter": {
Expand Down
40 changes: 27 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ env:
# Important to pin the clang version, cause we also use it for linting
CLANG_VERSION: 17
CLANG_TIDY_JOBS: 4
# Since we use rather new c++ features, we need a rather new version of MinGW
# LLVM MinGW seems to be the newest prebuilt binaries around
LLVM_MINGW_VERSION: llvm-mingw-20230919-msvcrt-ubuntu-20.04-x86_64
LLVM_MINGW_DOWNLOAD: https://github.com/mstorsjo/llvm-mingw/releases/download/20230919/llvm-mingw-20230919-msvcrt-ubuntu-20.04-x86_64.tar.xz
# LLVM MinGW download
LLVM_MINGW_VERSION: llvm-mingw-20231128-msvcrt-ubuntu-20.04-x86_64
LLVM_MINGW_DOWNLOAD: https://github.com/mstorsjo/llvm-mingw/releases/download/20231128/llvm-mingw-20231128-msvcrt-ubuntu-20.04-x86_64.tar.xz
# xwin settings
XWIN_VERSION: xwin-0.3.1-x86_64-unknown-linux-musl
XWIN_DOWNLOAD: https://github.com/Jake-Shadle/xwin/releases/download/0.3.1/xwin-0.3.1-x86_64-unknown-linux-musl.tar.gz
XWIN_VERSION: xwin-0.5.0-x86_64-unknown-linux-musl
XWIN_DOWNLOAD: https://github.com/Jake-Shadle/xwin/releases/download/0.5.0/xwin-0.5.0-x86_64-unknown-linux-musl.tar.gz

jobs:
cache-clang:
Expand Down Expand Up @@ -55,15 +54,15 @@ jobs:

steps:
- name: Restore Clang Cache
if: contains(matrix.preset, 'clang')
if: startswith(matrix.preset, 'clang')
uses: actions/cache/restore@v3
with:
path: C:\Program Files\LLVM
key: ${{ runner.os }}-clang-${{ env.CLANG_VERSION }}
fail-on-cache-miss: true

- name: Add MSVC to PATH
if: contains(matrix.preset, 'msvc')
if: startswith(matrix.preset, 'msvc')
uses: TheMrMilchmann/setup-msvc-dev@v2
with:
arch: ${{ fromJSON('["x86", "x64"]')[contains(matrix.preset, 'x64')] }}
Expand Down Expand Up @@ -97,10 +96,12 @@ jobs:
fail-fast: false
matrix:
preset: [
"mingw-x86-release",
"mingw-x64-release",
"clang-cross-x86-release",
"clang-cross-x64-release",
"llvm-mingw-x86-release",
"llvm-mingw-x64-release",
"mingw-x86-release",
"mingw-x64-release",
]

steps:
Expand All @@ -111,7 +112,7 @@ jobs:
# Caching would also lose the +x - so we'd have to tar before caching/untar after, making it
# even slower
- name: Setup Clang
if: contains(matrix.preset, 'clang')
if: startswith(matrix.preset, 'clang')
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
Expand All @@ -133,13 +134,19 @@ jobs:
/usr/bin/llvm-rc-${{ env.CLANG_VERSION }} \
200

- name: Setup MinGW
if: contains(matrix.preset, 'mingw')
- name: Setup LLVM MinGW
if: startswith(matrix.preset, 'llvm-mingw')
run: |
wget -nv ${{ env.LLVM_MINGW_DOWNLOAD }}
tar -xf ${{ env.LLVM_MINGW_VERSION }}.tar.xz -C ~/
echo $(readlink -f ~/${{ env.LLVM_MINGW_VERSION }}/bin) >> $GITHUB_PATH

- name: Set up MinGW
if: startswith(matrix.preset, 'mingw')
uses: egor-tensin/setup-mingw@v2
with:
platform: ${{ fromJSON('["x86", "x64"]')[contains(matrix.preset, 'x64')] }}

# xwin does take long enough that caching's worth it
- name: Restore xwin cache
if: contains(matrix.preset, 'cross')
Expand Down Expand Up @@ -223,6 +230,13 @@ jobs:
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: cmake . --preset ${{ matrix.preset }} -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On

- name: Remove `.modmap`s from compile commands
run: |
(Get-Content "out\build\${{ matrix.preset }}\compile_commands.json") `
-replace "@CMakeFiles.+?\.modmap", "" `
| Set-Content `
-Path "out\build\${{ matrix.preset }}\compile_commands.json"

- name: Run clang-tidy
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: |
Expand Down
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.24)

project(pluginloader VERSION 1.0.1)
project(pluginloader VERSION 1.0.2)

add_library(_pluginloader_base INTERFACE)
set(CMAKE_EXPORT_COMPILE_COMMANDS True)
Expand All @@ -10,11 +10,16 @@ set_target_properties(_pluginloader_base PROPERTIES
COMPILE_WARNING_AS_ERROR True
INTERPROCEDURAL_OPTIMIZATION True
)

if(MSVC)
target_compile_options(_pluginloader_base INTERFACE /W4)
else()
target_compile_options(_pluginloader_base INTERFACE -Wall -Wextra -Wpedantic)
endif()
# CMake doesn't understand warnings as errors for MinGW yet
if(MINGW)
target_compile_options(_pluginloader_base INTERFACE -Werror)
endif()

set(CONFIGURE_FILES_DIR "${CMAKE_CURRENT_BINARY_DIR}/configure")

Expand Down
56 changes: 56 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@
},
"toolchainFile": "common_cmake/clang-cross-x64.cmake"
},
{
"name": "_llvm_mingw_x86",
"hidden": true,
"condition": {
"type": "notEquals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"toolchainFile": "common_cmake/llvm-i686-w64-mingw32.cmake"
},
{
"name": "_llvm_mingw_x64",
"hidden": true,
"condition": {
"type": "notEquals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"toolchainFile": "common_cmake/llvm-x86_64-w64-mingw32.cmake"
},
{
"name": "_mingw_x86",
"hidden": true,
Expand Down Expand Up @@ -193,6 +213,42 @@
"_release"
]
},
{
"name": "llvm-mingw-x86-debug",
"displayName": "x86 Debug (LLVM MinGW)",
"inherits": [
"_base",
"_llvm_mingw_x86",
"_debug"
]
},
{
"name": "llvm-mingw-x86-release",
"displayName": "x86 Release (LLVM MinGW)",
"inherits": [
"_base",
"_llvm_mingw_x86",
"_release"
]
},
{
"name": "llvm-mingw-x64-debug",
"displayName": "x64 Debug (LLVM MinGW)",
"inherits": [
"_base",
"_llvm_mingw_x64",
"_debug"
]
},
{
"name": "llvm-mingw-x64-release",
"displayName": "x64 Release (LLVM MinGW)",
"inherits": [
"_base",
"_llvm_mingw_x64",
"_release"
]
},
{
"name": "mingw-x86-debug",
"displayName": "x86 Debug (MinGW)",
Expand Down
2 changes: 1 addition & 1 deletion common_cmake
8 changes: 4 additions & 4 deletions src/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ using std::uint8_t;

#endif

#if defined(_MSC_VER)
#define DLL_EXPORT extern "C" __declspec(dllexport)
#elif defined(__clang__)
#if defined(__clang__) || defined(__MINGW32__)
#define DLL_EXPORT extern "C" [[gnu::dllexport]]
#elif defined(_MSC_VER)
#define DLL_EXPORT extern "C" __declspec(dllexport)
#else
#error Unknown DLL export attribute
#error Unknown dllexport attribute
#endif

#endif /* PCH_H */
14 changes: 12 additions & 2 deletions src/proxy/d3d11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@ FARPROC d3d11_core_create_device_ptr = nullptr;
FARPROC d3d11_create_device_ptr = nullptr;
FARPROC d3d11_create_device_and_swap_chain_ptr = nullptr;

} // namespace

// NOLINTBEGIN(readability-identifier-naming, readability-identifier-length)

#if defined(__MINGW32__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
#endif

DLL_EXPORT HRESULT D3D11CoreCreateDevice(void* fact,
void* adapt,
unsigned int flag,
Expand Down Expand Up @@ -56,9 +63,12 @@ DLL_EXPORT HRESULT D3D11CreateDeviceAndSwapChain(void* adapt,
d3d11_create_device_and_swap_chain_ptr)(adapt, dt, soft, flags, ft, fl, ver, swapChainDesc,
swapChain, ppDevice, featureLevel, context);
}
// NOLINTEND(readability-identifier-naming, readability-identifier-length)

} // namespace
#if defined(__MINGW32__)
#pragma GCC diagnostic pop
#endif

// NOLINTEND(readability-identifier-naming, readability-identifier-length)

void init(HMODULE /*this_dll*/) {
// Suspend all other threads to prevent a giant race condition
Expand Down
15 changes: 12 additions & 3 deletions src/proxy/xinput1_3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ FARPROC xinput_set_state_ptr = nullptr;
const constexpr auto XINPUT_GET_STATE_EX_ORDINAL = 100;
FARPROC xinput_get_state_ex_ptr = nullptr;

// NOLINTBEGIN(readability-identifier-naming, readability-identifier-length)
} // namespace

// NOLINTBEGIN(readability-identifier-naming)

#if defined(__MINGW32__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
#endif

DLL_EXPORT void XInputEnable(BOOL enable) {
return reinterpret_cast<decltype(&XInputEnable)>(xinput_enable_ptr)(enable);
Expand Down Expand Up @@ -65,9 +72,11 @@ DLL_EXPORT DWORD XInputGetStateEx(DWORD dwUserIndex, void* pState) {
pState);
}

// NOLINTEND(readability-identifier-naming, readability-identifier-length)
#if defined(__MINGW32__)
#pragma GCC diagnostic pop
#endif

} // namespace
// NOLINTEND(readability-identifier-naming)

void init(HMODULE /*this_dll*/) {
// Suspend all other threads to prevent a giant race condition
Expand Down
3 changes: 0 additions & 3 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ void adjust_running_status(bool resume) {
HANDLE thread = OpenThread(THREAD_GET_CONTEXT | THREAD_SET_CONTEXT | THREAD_SUSPEND_RESUME,
0, te32.th32ThreadID);
if (thread != nullptr) {
CONTEXT context;
context.ContextFlags = CONTEXT_DEBUG_REGISTERS;

if (resume) {
ResumeThread(thread);
} else {
Expand Down