From ad330d7fba756accb803bffd8c1f6e2eeba1fb1d Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Fri, 6 Sep 2024 10:03:34 +0100 Subject: [PATCH] FreeBSD GitHub runner with `vmactions/freebsd-vm@v1` (#7474) * Add experimental BSD job to CI * Remove container * cd into ` synergy/synergy/` * Change unix to bsd * Use only run param and not prepare * Install python3 on FreeBSD * Add missing command to prepare param * Add all the Unix-like BSD-derived * Use latest python3 for NetBSD and DragonFly BSD * Use env for cmd and correct prepare commands * Add deps config for unix-like * Install Python deps on Unix-like * Return matching entry in `get_unix_like_os` * Add cmake dep for cmakelang py module * Back out Unix-like support in `install_deps.py` (Python is tricky on BSD) * Back out BSD from config * Create install_deps.sh script for BSD-derived * Use .sh script instead of .py for BSD-derived * Add other case and fixed syntax * Use /usr/bin/env * Use more available sh * Restore debian command * Fixed syntax error * Remove prepare args * Remove space * Use which instead of command * Add libX11 dep * Add other BSD-derivatives * Set CMAKE_REQUIRED_INCLUDES * Fixed bad separator for CMAKE_REQUIRED_INCLUDES * Add debug lines * Set CMAKE_REQUIRED_LIBRARIES to lib names * use CMAKE_REQUIRED_QUIET * Set CMAKE_REQUIRED_FLAGS for BSD * Message for BSD packaging * Make PKG_CONFIG_FOUND optional * Move debug to all OS * Remove solaris for now, too many missing packages * Add missing override to XWindowsScreen.h * Add PC_GLIB_INCLUDE_DIRS * Fixed glib include * Make libnotify optional * Set CMAKE_LIBRARY_PATH * Only run tests if toml++ available * Also run integ tests * Remove DragonFly (C++ version too old) * Fixed NetBSD command * Aww sucks. Well, I tried. Patches welcome * Update ChangeLog * Fixed README for OpenBSD, NetBSD, DragonFly BSD, Solaris * Add missing case for SunOS * Drop redundant virtual specifiers * Print libs on FreeBSD * Restore link_directories * Beef up to ubuntu-24.04-16-core-x64, export QT_QPA_PLATFORM, improve comment * Remove debug line * Simplify debug text * Restore ubuntu-latest * Fixed really stupid typo * Beef up with ubuntu-22.04-16-core-x64 * Revert "Beef up with ubuntu-22.04-16-core-x64" This reverts commit 3de5773ef6c6eea99b93d3ee8448b0b95dc00dde. * Add missing name * Make .sh file primary deps file * Tweaked deps instruction label --- .github/workflows/ci.yml | 38 +++++++++- ChangeLog | 1 + README.md | 12 ++-- cmake/Libraries.cmake | 51 ++++++++++---- cmake/Packaging.cmake | 6 +- cspell.json | 1 + scripts/install_deps.py | 1 - scripts/install_deps.sh | 77 +++++++++++++++++++++ src/lib/platform/XWindowsScreen.h | 70 +++++++++---------- src/lib/synergy/CMakeLists.txt | 14 ++-- src/lib/synergy/unix/AppUtilUnix.cpp | 4 +- src/test/integtests/synergy/ConfigTests.cpp | 4 ++ 12 files changed, 211 insertions(+), 68 deletions(-) create mode 100755 scripts/install_deps.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 144cc8960..e66689c7e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,8 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - uses: ./.github/actions/run-tests-setup + - name: Test setup + uses: ./.github/actions/run-tests-setup windows: name: ${{ matrix.target.name }} @@ -328,3 +329,38 @@ jobs: gdrive-secret-key: ${{ secrets.GOOGLE_DRIVE_KEY }} gdrive-parent-folder-id: ${{ secrets.GOOGLE_DRIVE_TECH_DRIVE }} package-version: ${{ env.SYNERGY_VERSION }} + + # Technically, "unix" is a misnomer, but we use it here to mean "Unix-like BSD-derived". + unix: + name: unix-${{ matrix.distro.name }} + runs-on: ubuntu-latest + timeout-minutes: 20 + + env: + SYNERGY_BUILD_CMD: | + ./scripts/install_deps.sh; + cmake -B build; + cmake --build build -j8; + export QT_QPA_PLATFORM=offscreen; + ./build/bin/unittests + ./build/bin/integtests + + strategy: + fail-fast: false + + matrix: + distro: + - name: freebsd + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: "recursive" + + - name: Build on FreeBSD + if: ${{ matrix.distro.name == 'freebsd' }} + uses: vmactions/freebsd-vm@v1 + with: + usesh: true + run: ${{ env.SYNERGY_BUILD_CMD }} diff --git a/ChangeLog b/ChangeLog index ba0faefba..39fec8705 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,7 @@ Enhancements: - #7469 Option to link against local `libportal` and other subprojects - #7471 Use `vcpkg` to manage `openssl` dep instead of `choco` - #7473 Simplify `vcpkg` caching and use system `vcpkg` +- #7474 FreeBSD GitHub runner with `vmactions/freebsd-vm@v1` # 1.15.1 diff --git a/README.md b/README.md index dafcdb282..d37c6f3cc 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ We support all major operating systems, including Windows, macOS, Linux, and Uni All Linux distributions are supported, primarily focusing on: Debian, Ubuntu, Linux Mint, Fedora, RHEL, AlmaLinux, Rocky Linux, Arch Linux, openSUSE, Gentoo. -Supported Unix-like BSD-derived operating systems: FreeBSD, OpenBSD, NetBSD, DragonFly BSD. +We officially support FreeBSD, we would also like to support: OpenBSD, NetBSD, DragonFly BSD, Solaris. ## Ways to get involved @@ -50,16 +50,16 @@ How to build Synergy 1 Community Edition. Check the [Developer Guide](https://gi **1. Dependencies:** +*Linux, macOS, or BSD-derived:* +``` +./scripts/install_deps.sh +``` + *Windows:* ``` python scripts/install_deps.py ``` -*macOS/Linux:* -``` -./scripts/install_deps.py -``` - **2. Configure:** *Windows:* diff --git a/cmake/Libraries.cmake b/cmake/Libraries.cmake index d0b34743a..c1c8206a4 100644 --- a/cmake/Libraries.cmake +++ b/cmake/Libraries.cmake @@ -38,7 +38,6 @@ macro(configure_unix_libs) include(CheckIncludeFileCXX) include(CheckSymbolExists) include(CheckCSourceCompiles) - include(FindPkgConfig) check_include_file_cxx(istream HAVE_ISTREAM) check_include_file_cxx(ostream HAVE_OSTREAM) @@ -106,8 +105,26 @@ macro(configure_unix_libs) if(APPLE) configure_mac_libs() else() + configure_xorg_libs() configure_wayland_libs() + + find_package(pugixml REQUIRED) + + find_package(PkgConfig) + if(PKG_CONFIG_FOUND) + pkg_check_modules(lib_glib REQUIRED IMPORTED_TARGET glib-2.0) + pkg_search_module(PC_GDKPIXBUF gdk-pixbuf-2.0) + + include_directories(${PC_GDKPIXBUF_INCLUDE_DIRS}) + + pkg_check_modules(lib_gdkpixbuf REQUIRED IMPORTED_TARGET gdk-pixbuf-2.0) + pkg_check_modules(lib_notify REQUIRED IMPORTED_TARGET libnotify) + + add_definitions(-DHAVE_GDK_PIXBUF=1 -DHAVE_LIBNOTIFY=1) + else() + message(WARNING "pkg-config not found, skipping libnotify and gdk-pixbuf") + endif() endif() # For config.h, set some static values; it may be a good idea to make these @@ -168,14 +185,20 @@ endmacro() macro(configure_wayland_libs) - configure_libei() - configure_libportal() + include(FindPkgConfig) - pkg_check_modules(LIBXKBCOMMON REQUIRED xkbcommon) - pkg_check_modules(GLIB2 REQUIRED glib-2.0 gio-2.0) - find_library(LIBM m) - include_directories(${LIBXKBCOMMON_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS} - ${LIBM_INCLUDE_DIRS}) + if(PKG_CONFIG_FOUND) + configure_libei() + configure_libportal() + + pkg_check_modules(LIBXKBCOMMON REQUIRED xkbcommon) + pkg_check_modules(GLIB2 REQUIRED glib-2.0 gio-2.0) + find_library(LIBM m) + include_directories(${LIBXKBCOMMON_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS} + ${LIBM_INCLUDE_DIRS}) + else() + message(WARNING "pkg-config not found, skipping wayland libraries") + endif() endmacro() @@ -310,10 +333,8 @@ endmacro() # macro(configure_xorg_libs) - find_package(pugixml REQUIRED) - - # Add include dir for BSD (posix uses /usr/include/) - set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}:/usr/local/include") + # Set include dir for BSD-derived systems + set(CMAKE_REQUIRED_INCLUDES "/usr/local/include") set(XKBlib "X11/Xlib.h;X11/XKBlib.h") set(CMAKE_EXTRA_INCLUDE_FILES "${XKBlib};X11/extensions/Xrandr.h") @@ -341,6 +362,12 @@ macro(configure_xorg_libs) message(FATAL_ERROR "Missing header: " ${XKBlib}) endif() + # Set library path and -L flag for BSD-derived systems. + # On our FreeBSD CI, `link_directories` is also needed for some reason. + set(CMAKE_LIBRARY_PATH "/usr/local/lib") + set(CMAKE_REQUIRED_FLAGS "-L${CMAKE_LIBRARY_PATH}") + link_directories(${CMAKE_LIBRARY_PATH}) + check_library_exists("SM;ICE" IceConnectionNumber "" HAVE_ICE) check_library_exists("Xext;X11" DPMSQueryExtension "" HAVE_Xext) check_library_exists("Xtst;Xext;X11" XTestQueryExtension "" HAVE_Xtst) diff --git a/cmake/Packaging.cmake b/cmake/Packaging.cmake index 378fe0e35..cb47e15c6 100644 --- a/cmake/Packaging.cmake +++ b/cmake/Packaging.cmake @@ -30,8 +30,10 @@ macro(configure_packaging) configure_windows_packaging() elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") configure_macos_packaging() - elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux|.*BSD|DragonFly") + elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") configure_linux_packaging() + elseif(${CMAKE_SYSTEM_NAME} MATCHES "|.*BSD") + message(STATUS "BSD packaging not yet supported") endif() include(CPack) @@ -78,7 +80,7 @@ macro(configure_macos_packaging) endmacro() # -# Linux packages (including BSD and DragonFly) +# Linux packages # macro(configure_linux_packaging) diff --git a/cspell.json b/cspell.json index 4aaa4dd77..64e48f05b 100644 --- a/cspell.json +++ b/cspell.json @@ -58,6 +58,7 @@ "synergyc", "synergyd", "synergys", + "unittests", "Valgrind", "vcpkg", "Volker", diff --git a/scripts/install_deps.py b/scripts/install_deps.py index 4859ea41c..4d6a71406 100755 --- a/scripts/install_deps.py +++ b/scripts/install_deps.py @@ -304,7 +304,6 @@ class Dependencies: print(f"Optional package not found, stripping: {optional_package}") command = command.replace(optional_package, "") - print("Running dependencies command") linux.run_command(command, check=True) subprojects = self.config.get_os_subprojects() diff --git a/scripts/install_deps.sh b/scripts/install_deps.sh new file mode 100755 index 000000000..4d4f4a390 --- /dev/null +++ b/scripts/install_deps.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env sh + +SUDO=$(which sudo > /dev/null 2>&1 && echo "sudo" || echo "") + +install_deps() { + uname_out="$(uname -s)" + case "${uname_out}" in + FreeBSD*) install_freebsd ;; + OpenBSD*) install_openbsd ;; + NetBSD*) install_netbsd ;; + DragonFly*) install_dragonfly ;; + SunOS*) install_solaris ;; + *) install_other $uname_out ;; + esac +} + +install_freebsd() { + run_cmd pkg install -y \ + cmake \ + ninja \ + gmake \ + gcc10 \ + openssl \ + glib \ + gdk-pixbuf2 \ + libX11 \ + libXtst \ + libnotify \ + libxkbfile \ + qt6-base \ + qt6-tools \ + gtk3 \ + googletest \ + pugixml +} + +install_openbsd() { + # Patches welcome! + # pkg_add error: + # Can't find libX11 + # Can't find libXtst + echo "Sorry, OpenBSD is not supported yet." +} + +install_netbsd() { + # Patches welcome! + # pkg_add error: + # pkg_add: no pkg found for 'libX11', sorry. + # pkg_add: no pkg found for 'libXtst', sorry. + echo "Sorry, NetBSD is not supported yet." +} + +install_dragonfly() { + # Patches welcome! + # The C++ version on DragonFly BSD seems to be too old. + echo "Sorry, DragonFly BSD is not supported yet." +} + +install_solaris() { + # Patches welcome! + echo "Sorry, Solaris is not supported yet." +} + +install_other() { + # TODO: Port the .py script to shell script to make the deps installation lighter on + # Linux and macOS. The .py script is probably only really needed to deal with Windows. + echo "Running Python script for: $1" + run_cmd ./scripts/install_deps.py +} + +run_cmd() { + cmd="${SUDO:+$SUDO }$@" + echo "Running: $cmd" + $cmd +} + +install_deps diff --git a/src/lib/platform/XWindowsScreen.h b/src/lib/platform/XWindowsScreen.h index 5053ce147..8deb64540 100644 --- a/src/lib/platform/XWindowsScreen.h +++ b/src/lib/platform/XWindowsScreen.h @@ -44,7 +44,7 @@ public: int mouseScrollDelta, IEventQueue *events, synergy::ClientScrollDirection m_clientScrollDirection = synergy::ClientScrollDirection::SERVER); - virtual ~XWindowsScreen(); + virtual ~XWindowsScreen() override; //! @name manipulators //@{ @@ -52,50 +52,50 @@ public: //@} // IScreen overrides - virtual void *getEventTarget() const; - virtual bool getClipboard(ClipboardID id, IClipboard *) const; - virtual void - getShape(SInt32 &x, SInt32 &y, SInt32 &width, SInt32 &height) const; - virtual void getCursorPos(SInt32 &x, SInt32 &y) const; + void *getEventTarget() const override; + bool getClipboard(ClipboardID id, IClipboard *) const override; + void + getShape(SInt32 &x, SInt32 &y, SInt32 &width, SInt32 &height) const override; + void getCursorPos(SInt32 &x, SInt32 &y) const override; // IPrimaryScreen overrides - virtual void reconfigure(UInt32 activeSides); - virtual void warpCursor(SInt32 x, SInt32 y); - virtual UInt32 registerHotKey(KeyID key, KeyModifierMask mask); - virtual void unregisterHotKey(UInt32 id); - virtual void fakeInputBegin(); - virtual void fakeInputEnd(); - virtual SInt32 getJumpZoneSize() const; - virtual bool isAnyMouseButtonDown(UInt32 &buttonID) const; - virtual void getCursorCenter(SInt32 &x, SInt32 &y) const; + void reconfigure(UInt32 activeSides) override; + void warpCursor(SInt32 x, SInt32 y) override; + UInt32 registerHotKey(KeyID key, KeyModifierMask mask) override; + void unregisterHotKey(UInt32 id) override; + void fakeInputBegin() override; + void fakeInputEnd() override; + SInt32 getJumpZoneSize() const override; + bool isAnyMouseButtonDown(UInt32 &buttonID) const override; + void getCursorCenter(SInt32 &x, SInt32 &y) const override; // ISecondaryScreen overrides - virtual void fakeMouseButton(ButtonID id, bool press); - virtual void fakeMouseMove(SInt32 x, SInt32 y); - virtual void fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const; - virtual void fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const; + void fakeMouseButton(ButtonID id, bool press) override; + void fakeMouseMove(SInt32 x, SInt32 y) override; + void fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const override; + void fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const override; // IPlatformScreen overrides - virtual void enable(); - virtual void disable(); - virtual void enter(); - virtual bool leave(); - virtual bool setClipboard(ClipboardID, const IClipboard *); - virtual void checkClipboards(); - virtual void openScreensaver(bool notify); - virtual void closeScreensaver(); - virtual void screensaver(bool activate); - virtual void resetOptions(); - virtual void setOptions(const OptionsList &options); - virtual void setSequenceNumber(UInt32); - virtual bool isPrimary() const; + void enable() override; + void disable() override; + void enter() override; + bool leave() override; + bool setClipboard(ClipboardID, const IClipboard *) override; + void checkClipboards() override; + void openScreensaver(bool notify) override; + void closeScreensaver() override; + void screensaver(bool activate) override; + void resetOptions() override; + void setOptions(const OptionsList &options) override; + void setSequenceNumber(UInt32) override; + bool isPrimary() const override; String getSecureInputApp() const override; protected: // IPlatformScreen overrides - virtual void handleSystemEvent(const Event &, void *); - virtual void updateButtons(); - virtual IKeyState *getKeyState() const; + void handleSystemEvent(const Event &, void *) override; + void updateButtons() override; + IKeyState *getKeyState() const override; private: // event sending diff --git a/src/lib/synergy/CMakeLists.txt b/src/lib/synergy/CMakeLists.txt index e92017bac..02e92b1b1 100644 --- a/src/lib/synergy/CMakeLists.txt +++ b/src/lib/synergy/CMakeLists.txt @@ -55,14 +55,10 @@ if(UNIX) if(NOT APPLE) target_link_libraries(synlib pugixml) - find_package(PkgConfig REQUIRED) - pkg_check_modules(lib_glib REQUIRED IMPORTED_TARGET glib-2.0) - pkg_search_module(PC_GDKPIXBUF gdk-pixbuf-2.0) - include_directories(${PC_GDKPIXBUF_INCLUDE_DIRS}) - - pkg_check_modules(lib_gdkpixbuf REQUIRED IMPORTED_TARGET gdk-pixbuf-2.0) - pkg_check_modules(lib_notify REQUIRED IMPORTED_TARGET libnotify) - target_link_libraries(synlib PkgConfig::lib_glib PkgConfig::lib_gdkpixbuf - PkgConfig::lib_notify) + find_package(PkgConfig) + if(PKG_CONFIG_FOUND) + target_link_libraries(synlib PkgConfig::lib_glib PkgConfig::lib_gdkpixbuf + PkgConfig::lib_notify) + endif() endif() endif() diff --git a/src/lib/synergy/unix/AppUtilUnix.cpp b/src/lib/synergy/unix/AppUtilUnix.cpp index 4b4ecc45c..0a4f6d88b 100644 --- a/src/lib/synergy/unix/AppUtilUnix.cpp +++ b/src/lib/synergy/unix/AppUtilUnix.cpp @@ -32,7 +32,7 @@ #include "base/Log.h" #include "base/log_outputters.h" -#if WINAPI_XWINDOWS +#if HAVE_LIBNOTIFY #include #endif @@ -173,7 +173,7 @@ String AppUtilUnix::getCurrentLanguageCode() { void AppUtilUnix::showNotification( const String &title, const String &text) const { -#if WINAPI_XWINDOWS +#if HAVE_LIBNOTIFY LOG( (CLOG_INFO "showing notification, title=\"%s\", text=\"%s\"", title.c_str(), text.c_str())); diff --git a/src/test/integtests/synergy/ConfigTests.cpp b/src/test/integtests/synergy/ConfigTests.cpp index 52fbbd59e..d97573630 100644 --- a/src/test/integtests/synergy/ConfigTests.cpp +++ b/src/test/integtests/synergy/ConfigTests.cpp @@ -15,6 +15,8 @@ * along with this program. If not, see . */ +#if HAVE_TOMLPLUSPLUS + #include "synergy/Config.h" #include @@ -46,3 +48,5 @@ TEST(ConfigTests, LoadConfigFile) { std::filesystem::remove(kTestFilename); } + +#endif // HAVE_TOMLPLUSPLUS