From e4ea3646e012161be5da855236ff5d8cec5e0961 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Sat, 7 Dec 2024 20:42:21 +0800 Subject: [PATCH 1/2] barrier: fix build with gcc --- aqua/barrier/Portfile | 18 +++ .../0001-Add-missing-cstdint-header.patch | 37 ++++++ ...-libplatform-use-ObjC-flags-on-Apple.patch | 26 ++++ ...do-not-use-reserved-id-for-variables.patch | 124 ++++++++++++++++++ ..._types.h-pull-in-cstdint-only-with-C.patch | 26 ++++ 5 files changed, 231 insertions(+) create mode 100644 aqua/barrier/files/0001-Add-missing-cstdint-header.patch create mode 100644 aqua/barrier/files/0002-libplatform-use-ObjC-flags-on-Apple.patch create mode 100644 aqua/barrier/files/0003-OSXScreen.mm-do-not-use-reserved-id-for-variables.patch create mode 100644 aqua/barrier/files/0004-basic_types.h-pull-in-cstdint-only-with-C.patch diff --git a/aqua/barrier/Portfile b/aqua/barrier/Portfile index e630378abff0c..247f5ccf46e6a 100644 --- a/aqua/barrier/Portfile +++ b/aqua/barrier/Portfile @@ -57,6 +57,24 @@ if { ${os.major} < 16 } { app.retina yes } +if {[string match *gcc* ${configure.compiler}]} { + # OSXScreen.mm is left as is on purpose: unlike the rest, it was orinally a .cpp file. + post-extract { + move ${worksrcpath}/src/lib/platform/OSXDragSimulator.mm ${worksrcpath}/src/lib/platform/OSXDragSimulator.m + move ${worksrcpath}/src/lib/platform/OSXDragView.mm ${worksrcpath}/src/lib/platform/OSXDragView.m + move ${worksrcpath}/src/lib/platform/OSXMediaKeySimulator.mm ${worksrcpath}/src/lib/platform/OSXMediaKeySimulator.m + move ${worksrcpath}/src/lib/platform/OSXMediaKeySupport.mm ${worksrcpath}/src/lib/platform/OSXMediaKeySupport.m + move ${worksrcpath}/src/lib/platform/OSXPasteboardPeeker.mm ${worksrcpath}/src/lib/platform/OSXPasteboardPeeker.m + move ${worksrcpath}/src/lib/platform/OSXScreenSaverUtil.mm ${worksrcpath}/src/lib/platform/OSXScreenSaverUtil.m + } + + patchfiles-append \ + 0001-Add-missing-cstdint-header.patch \ + 0002-libplatform-use-ObjC-flags-on-Apple.patch \ + 0003-OSXScreen.mm-do-not-use-reserved-id-for-variables.patch \ + 0004-basic_types.h-pull-in-cstdint-only-with-C.patch +} + post-destroot { xinstall -m 0644 ${worksrcpath}/doc/barrierc.1 ${destroot}${prefix}/share/man/man1/barrierc.1 xinstall -m 0644 ${worksrcpath}/doc/barriers.1 ${destroot}${prefix}/share/man/man1/barriers.1 diff --git a/aqua/barrier/files/0001-Add-missing-cstdint-header.patch b/aqua/barrier/files/0001-Add-missing-cstdint-header.patch new file mode 100644 index 0000000000000..4b0e4789de91a --- /dev/null +++ b/aqua/barrier/files/0001-Add-missing-cstdint-header.patch @@ -0,0 +1,37 @@ +From c8e79bfd5408cdc031af0b0edd62110af8f5be49 Mon Sep 17 00:00:00 2001 +From: Sergey Fedorov +Date: Sat, 7 Dec 2024 16:57:20 +0800 +Subject: [PATCH 1/4] Add missing cstdint header + +--- + src/lib/base/String.h | 1 + + src/lib/net/FingerprintData.h | 1 + + 2 files changed, 2 insertions(+) + +diff --git src/lib/base/String.h src/lib/base/String.h +index 9c5a53ba..faf35969 100644 +--- src/lib/base/String.h ++++ src/lib/base/String.h +@@ -23,6 +23,7 @@ + + #include + #include ++#include + + // use standard C++ string class for our string class + typedef std::string String; +diff --git src/lib/net/FingerprintData.h src/lib/net/FingerprintData.h +index 938a6953..8ab16314 100644 +--- src/lib/net/FingerprintData.h ++++ src/lib/net/FingerprintData.h +@@ -20,6 +20,7 @@ + + #include + #include ++#include + + namespace barrier { + +-- +2.47.1 + diff --git a/aqua/barrier/files/0002-libplatform-use-ObjC-flags-on-Apple.patch b/aqua/barrier/files/0002-libplatform-use-ObjC-flags-on-Apple.patch new file mode 100644 index 0000000000000..081405e375703 --- /dev/null +++ b/aqua/barrier/files/0002-libplatform-use-ObjC-flags-on-Apple.patch @@ -0,0 +1,26 @@ +From 280fa0101a57ae2e082beaee5811334b669400a2 Mon Sep 17 00:00:00 2001 +From: Sergey Fedorov +Date: Sat, 7 Dec 2024 19:02:23 +0800 +Subject: [PATCH 2/4] libplatform: use ObjC flags on Apple + +--- + src/lib/platform/CMakeLists.txt | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git src/lib/platform/CMakeLists.txt src/lib/platform/CMakeLists.txt +index 75551b71..d5aba571 100644 +--- src/lib/platform/CMakeLists.txt ++++ src/lib/platform/CMakeLists.txt +@@ -46,4 +46,9 @@ endif() + if (APPLE) + find_library(COCOA_LIBRARY Cocoa) + target_link_libraries(platform ${COCOA_LIBRARY}) ++ target_compile_options(platform PRIVATE ++ $<$:-fobjc-exceptions> ++ $<$:-xobjective-c> ++ $<$:-fobjc-exceptions> ++ ) + endif() +-- +2.47.1 + diff --git a/aqua/barrier/files/0003-OSXScreen.mm-do-not-use-reserved-id-for-variables.patch b/aqua/barrier/files/0003-OSXScreen.mm-do-not-use-reserved-id-for-variables.patch new file mode 100644 index 0000000000000..3dc59a2d90949 --- /dev/null +++ b/aqua/barrier/files/0003-OSXScreen.mm-do-not-use-reserved-id-for-variables.patch @@ -0,0 +1,124 @@ +From a87a99a1f178a9cae879c5801a48fd0bec6450a6 Mon Sep 17 00:00:00 2001 +From: Sergey Fedorov +Date: Sat, 7 Dec 2024 20:21:49 +0800 +Subject: [PATCH 3/4] OSXScreen.mm: do not use reserved id for variables + +--- + src/lib/platform/OSXScreen.mm | 40 +++++++++++++++++------------------ + 1 file changed, 20 insertions(+), 20 deletions(-) + +diff --git src/lib/platform/OSXScreen.mm src/lib/platform/OSXScreen.mm +index d41e321b..5560ba02 100644 +--- src/lib/platform/OSXScreen.mm ++++ src/lib/platform/OSXScreen.mm +@@ -324,14 +324,14 @@ OSXScreen::registerHotKey(KeyID key, KeyModifierMask mask) + return 0; + } + +- // choose hotkey id +- UInt32 id; ++ // choose hotkey kid ++ UInt32 kid; + if (!m_oldHotKeyIDs.empty()) { +- id = m_oldHotKeyIDs.back(); ++ kid = m_oldHotKeyIDs.back(); + m_oldHotKeyIDs.pop_back(); + } + else { +- id = m_hotKeys.size() + 1; ++ kid = m_hotKeys.size() + 1; + } + + // if this hot key has modifiers only then we'll handle it specially +@@ -343,37 +343,37 @@ OSXScreen::registerHotKey(KeyID key, KeyModifierMask mask) + okay = false; + } + else { +- m_modifierHotKeys[mask] = id; ++ m_modifierHotKeys[mask] = kid; + okay = true; + } + } + else { +- EventHotKeyID hkid = { 'SNRG', (UInt32)id }; ++ EventHotKeyID hkid = { 'SNRG', (UInt32)kid }; + OSStatus status = RegisterEventHotKey(macKey, macMask, hkid, + GetApplicationEventTarget(), 0, + &ref); + okay = (status == noErr); +- m_hotKeyToIDMap[HotKeyItem(macKey, macMask)] = id; ++ m_hotKeyToIDMap[HotKeyItem(macKey, macMask)] = kid; + } + + if (!okay) { +- m_oldHotKeyIDs.push_back(id); ++ m_oldHotKeyIDs.push_back(kid); + m_hotKeyToIDMap.erase(HotKeyItem(macKey, macMask)); + LOG((CLOG_WARN "failed to register hotkey %s (id=%04x mask=%04x)", barrier::KeyMap::formatKey(key, mask).c_str(), key, mask)); + return 0; + } + +- m_hotKeys.insert(std::make_pair(id, HotKeyItem(ref, macKey, macMask))); ++ m_hotKeys.insert(std::make_pair(kid, HotKeyItem(ref, macKey, macMask))); + +- LOG((CLOG_DEBUG "registered hotkey %s (id=%04x mask=%04x) as id=%d", barrier::KeyMap::formatKey(key, mask).c_str(), key, mask, id)); +- return id; ++ LOG((CLOG_DEBUG "registered hotkey %s (id=%04x mask=%04x) as id=%d", barrier::KeyMap::formatKey(key, mask).c_str(), key, mask, kid)); ++ return kid; + } + + void +-OSXScreen::unregisterHotKey(UInt32 id) ++OSXScreen::unregisterHotKey(UInt32 kid) + { + // look up hotkey +- HotKeyMap::iterator i = m_hotKeys.find(id); ++ HotKeyMap::iterator i = m_hotKeys.find(kid); + if (i == m_hotKeys.end()) { + return; + } +@@ -388,7 +388,7 @@ OSXScreen::unregisterHotKey(UInt32 id) + // XXX -- this is inefficient + for (ModifierHotKeyMap::iterator j = m_modifierHotKeys.begin(); + j != m_modifierHotKeys.end(); ++j) { +- if (j->second == id) { ++ if (j->second == kid) { + m_modifierHotKeys.erase(j); + okay = true; + break; +@@ -396,17 +396,17 @@ OSXScreen::unregisterHotKey(UInt32 id) + } + } + if (!okay) { +- LOG((CLOG_WARN "failed to unregister hotkey id=%d", id)); ++ LOG((CLOG_WARN "failed to unregister hotkey id=%d", kid)); + } + else { +- LOG((CLOG_DEBUG "unregistered hotkey id=%d", id)); ++ LOG((CLOG_DEBUG "unregistered hotkey id=%d", kid)); + } + + // discard hot key from map and record old id for reuse + m_hotKeyToIDMap.erase(i->second); + m_hotKeys.erase(i); +- m_oldHotKeyIDs.push_back(id); +- if (m_activeModifierHotKey == id) { ++ m_oldHotKeyIDs.push_back(kid); ++ if (m_activeModifierHotKey == kid) { + m_activeModifierHotKey = 0; + m_activeModifierHotKeyMask = 0; + } +@@ -1445,8 +1445,8 @@ OSXScreen::getScrollSpeed() const + kCFPreferencesCurrentUser, + kCFPreferencesAnyHost); + if (pref != NULL) { +- CFTypeID id = CFGetTypeID(pref); +- if (id == CFNumberGetTypeID()) { ++ CFTypeID tid = CFGetTypeID(pref); ++ if (tid == CFNumberGetTypeID()) { + CFNumberRef value = static_cast(pref); + if (CFNumberGetValue(value, kCFNumberDoubleType, &scaling)) { + if (scaling < 0.0) { +-- +2.47.1 + diff --git a/aqua/barrier/files/0004-basic_types.h-pull-in-cstdint-only-with-C.patch b/aqua/barrier/files/0004-basic_types.h-pull-in-cstdint-only-with-C.patch new file mode 100644 index 0000000000000..df2e649402a8c --- /dev/null +++ b/aqua/barrier/files/0004-basic_types.h-pull-in-cstdint-only-with-C.patch @@ -0,0 +1,26 @@ +From a503785ef27a5cf28a954d564d39d0707e7bb225 Mon Sep 17 00:00:00 2001 +From: Sergey Fedorov +Date: Sat, 7 Dec 2024 20:33:05 +0800 +Subject: [PATCH 4/4] basic_types.h: pull in cstdint only with C++ + +--- + src/lib/common/basic_types.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git src/lib/common/basic_types.h src/lib/common/basic_types.h +index 1882e57e..33623c94 100644 +--- src/lib/common/basic_types.h ++++ src/lib/common/basic_types.h +@@ -18,7 +18,9 @@ + + #pragma once + ++#ifdef __cpluplus + #include ++#endif + + // + // make typedefs +-- +2.47.1 + From a0a34bf27dfe83e2d9692da0a98620dadab1e91c Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Sat, 7 Dec 2024 20:41:01 +0800 Subject: [PATCH 2/2] barrier: non-functional: minor improvement to portfile --- aqua/barrier/Portfile | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/aqua/barrier/Portfile b/aqua/barrier/Portfile index 247f5ccf46e6a..aef3194df72ca 100644 --- a/aqua/barrier/Portfile +++ b/aqua/barrier/Portfile @@ -8,14 +8,12 @@ PortGroup legacysupport 1.1 github.setup debauchee barrier 2.4.0 v revision 0 categories aqua net sysutils -platforms darwin license GPL-2 maintainers {@ryanakca debian.org:rak} description share a keyboard and mouse over the network long_description ${name} shares a keyboard, mouse, and clipboard over the network.\ It supports multiple operating systems, including macOS,\ - Linux, FreeBSD, OpenBSD, and Windows. It is a fork of\ - synergy. + Linux, FreeBSD, OpenBSD, and Windows. It is a fork of synergy. github.tarball_from archive @@ -26,9 +24,9 @@ checksums rmd160 25982044cb4088ad8ccb76e336b40e493f7c8e55 \ compiler.cxx_standard 2014 depends_build-append \ - port:pkgconfig \ + port:ghc-filesystem \ port:gtest \ - port:ghc-filesystem + path:bin/pkg-config:pkgconfig depends_lib-append \ path:lib/libssl.dylib:openssl @@ -42,19 +40,16 @@ configure.args-append \ -DBARRIER_USE_EXTERNAL_GTEST=ON # the gui requires metal -if { ${os.major} < 16 } { +if { ${os.platform} eq "darwin" && ${os.major} < 16 } { configure.args-append \ -DBARRIER_BUILD_GUI=OFF } else { - PortGroup qt5 1.0 - PortGroup app 1.0 + PortGroup qt5 1.0 + PortGroup app 1.0 - qt5.depends_component \ - qtbase - - app.create yes - app.icon dist/macos/bundle/Barrier.app/Contents/Resources/Barrier.icns - app.retina yes + app.create yes + app.icon dist/macos/bundle/Barrier.app/Contents/Resources/Barrier.icns + app.retina yes } if {[string match *gcc* ${configure.compiler}]} {