Skip to content

Commit 4ec406c

Browse files
committed
fix: repair platform build issues and ci
1 parent ab11946 commit 4ec406c

14 files changed

Lines changed: 269 additions & 256 deletions

.github/workflows/build.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
paths:
7+
- 'include/**'
8+
- 'src/**'
9+
- 'tests/**'
10+
- 'examples/**'
11+
- 'cmake/**'
12+
- 'externals/**'
13+
- 'CMakeLists.txt'
14+
- '.github/workflows/**'
15+
pull_request:
16+
branches: [ master ]
17+
paths:
18+
- 'include/**'
19+
- 'src/**'
20+
- 'tests/**'
21+
- 'examples/**'
22+
- 'cmake/**'
23+
- 'externals/**'
24+
- 'CMakeLists.txt'
25+
- '.github/workflows/**'
26+
27+
permissions:
28+
contents: read
29+
30+
concurrency:
31+
group: ${{ github.workflow }}-${{ github.ref }}
32+
cancel-in-progress: true
33+
34+
jobs:
35+
build-test:
36+
name: ${{ matrix.name }}
37+
runs-on: ${{ matrix.os }}
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
include:
42+
- name: Linux (GCC 14)
43+
os: ubuntu-latest
44+
examples: 'ON'
45+
cmake_args: ''
46+
- name: macOS (Apple Clang)
47+
os: macos-15
48+
# The examples use std::println, and Apple Clang's libc++ does not
49+
# ship <print> yet. The library and unit tests use std::format and
50+
# std::expected, which this toolchain has.
51+
examples: 'OFF'
52+
cmake_args: ''
53+
- name: Windows (MSVC)
54+
os: windows-latest
55+
examples: 'ON'
56+
cmake_args: '-A x64'
57+
58+
steps:
59+
- uses: actions/checkout@v4
60+
with:
61+
submodules: recursive
62+
63+
- name: Install Linux dependencies
64+
if: runner.os == 'Linux'
65+
run: |
66+
sudo apt-get update
67+
sudo apt-get install -y g++-14 libx11-dev libxtst-dev libxrandr-dev
68+
echo "CC=gcc-14" >> "$GITHUB_ENV"
69+
echo "CXX=g++-14" >> "$GITHUB_ENV"
70+
71+
- name: Print CMake version
72+
run: cmake --version
73+
74+
- name: Configure
75+
run: >
76+
cmake -S . -B build ${{ matrix.cmake_args }}
77+
-DCMAKE_BUILD_TYPE=Release
78+
-DROBOT_BUILD_TESTS=ON
79+
-DROBOT_BUILD_EXAMPLES=${{ matrix.examples }}
80+
81+
- name: Build
82+
run: cmake --build build --config Release --parallel
83+
84+
- name: Unit tests
85+
run: ctest --test-dir build -C Release --output-on-failure
86+
87+
sanitizers:
88+
name: Sanitizers (ASan + UBSan)
89+
runs-on: ubuntu-latest
90+
91+
steps:
92+
- uses: actions/checkout@v4
93+
with:
94+
submodules: recursive
95+
96+
- name: Install dependencies
97+
run: |
98+
sudo apt-get update
99+
sudo apt-get install -y g++-14 libx11-dev libxtst-dev libxrandr-dev
100+
101+
- name: Configure
102+
env:
103+
CC: gcc-14
104+
CXX: g++-14
105+
run: >
106+
cmake -S . -B build
107+
-DCMAKE_BUILD_TYPE=RelWithDebInfo
108+
-DROBOT_BUILD_TESTS=ON
109+
-DROBOT_BUILD_EXAMPLES=OFF
110+
-DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -fno-sanitize-recover=all"
111+
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address,undefined"
112+
113+
- name: Build
114+
run: cmake --build build --parallel
115+
116+
- name: Unit tests
117+
env:
118+
UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1
119+
ASAN_OPTIONS: detect_leaks=1
120+
run: ctest --test-dir build --output-on-failure

.github/workflows/test-macos.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/test-windows.yml

Lines changed: 0 additions & 103 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ else()
2323
endif()
2424

2525
option(ROBOT_BUILD_TESTS "Build robot-cpp tests" ${ROBOT_IS_TOPLEVEL})
26-
option(ROBOT_BUILD_INTERACTIVE_TESTS
27-
"Build the SDL-driven interactive injection tests (needs a live display)" OFF)
2826
option(ROBOT_BUILD_EXAMPLES "Build robot-cpp examples" ${ROBOT_IS_TOPLEVEL})
2927
option(ROBOT_WERROR "Treat warnings as errors" OFF)
3028
option(ROBOT_LINUX_ENABLE_UINPUT "Build the Linux uinput backend" ON)
@@ -88,7 +86,7 @@ elseif(WIN32)
8886
src/platform/windows/WinScreenBackend.cpp
8987
src/platform/windows/WinEventTapBackend.cpp
9088
)
91-
elseif(UNIX)
89+
elseif(UNIX AND NOT APPLE)
9290
set(ROBOT_PLATFORM_SOURCES
9391
src/platform/linux/LinuxBackendFactory.cpp
9492
src/platform/linux/LinuxPlatformBackend.cpp
@@ -148,8 +146,14 @@ elseif(WIN32)
148146
target_link_libraries(robot PRIVATE user32 gdi32)
149147
target_compile_definitions(robot PRIVATE
150148
WIN32_LEAN_AND_MEAN NOMINMAX UNICODE _UNICODE)
151-
elseif(UNIX)
149+
elseif(UNIX AND NOT APPLE)
152150
find_package(X11 REQUIRED)
151+
if(NOT TARGET X11::Xtst)
152+
message(FATAL_ERROR "robot-cpp: XTest development files are required")
153+
endif()
154+
if(NOT TARGET X11::Xrandr)
155+
message(FATAL_ERROR "robot-cpp: XRandR development files are required")
156+
endif()
153157
# X11 headers are used only in platform .cpp files -> PRIVATE. XTest and
154158
# Xrandr components ship with X11; XRecord lives in libXtst as well.
155159
target_link_libraries(robot PRIVATE
@@ -199,6 +203,12 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/robotConfig.cmake"
199203
"include(CMakeFindDependencyMacro)\n\
200204
if(UNIX AND NOT APPLE)\n\
201205
find_dependency(X11)\n\
206+
if(NOT TARGET X11::Xtst)\n\
207+
message(FATAL_ERROR \"robot-cpp: XTest development files are required\")\n\
208+
endif()\n\
209+
if(NOT TARGET X11::Xrandr)\n\
210+
message(FATAL_ERROR \"robot-cpp: XRandR development files are required\")\n\
211+
endif()\n\
202212
endif()\n\
203213
include(\"\${CMAKE_CURRENT_LIST_DIR}/robotTargets.cmake\")\n")
204214

src/platform/linux/LinuxEvdevKeymap.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace {
1010

1111
using robot::Key;
1212

13-
constexpr std::array<std::pair<Key, std::uint16_t>, 100> kTable{{
13+
constexpr auto kTable = std::to_array<std::pair<Key, std::uint16_t>>({
1414
{Key::A, KEY_A}, {Key::B, KEY_B}, {Key::C, KEY_C}, {Key::D, KEY_D},
1515
{Key::E, KEY_E}, {Key::F, KEY_F}, {Key::G, KEY_G}, {Key::H, KEY_H},
1616
{Key::I, KEY_I}, {Key::J, KEY_J}, {Key::K, KEY_K}, {Key::L, KEY_L},
@@ -52,7 +52,7 @@ constexpr std::array<std::pair<Key, std::uint16_t>, 100> kTable{{
5252
{Key::LeftAlt, KEY_LEFTALT}, {Key::LeftMeta, KEY_LEFTMETA},
5353
{Key::RightControl, KEY_RIGHTCTRL}, {Key::RightShift, KEY_RIGHTSHIFT},
5454
{Key::RightAlt, KEY_RIGHTALT}, {Key::RightMeta, KEY_RIGHTMETA},
55-
}};
55+
});
5656

5757
} // namespace
5858

@@ -70,4 +70,4 @@ std::optional<std::uint16_t> keyToEvdev(const Key key) {
7070
return it->second;
7171
}
7272

73-
} // namespace robot::linux_evdev
73+
} // namespace robot::linux_evdev

0 commit comments

Comments
 (0)