Github messages for voidlinux
 help / color / mirror / Atom feed
From: tranzystorek-io <tranzystorek-io@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] New package: Clipboard-0.2.1r2
Date: Wed, 18 Jan 2023 12:48:53 +0100	[thread overview]
Message-ID: <20230118114853.gke36cTO_eplLlmlag0jc66eXaAX1mbeOGITf5NJMCE@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-41621@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 1251 bytes --]

There is an updated pull request by tranzystorek-io against master on the void-packages repository

https://github.com/tranzystorek-io/void-packages Clipboard
https://github.com/void-linux/void-packages/pull/41621

New package: Clipboard-0.2.1r2
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/41621.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-Clipboard-41621.patch --]
[-- Type: text/x-diff, Size: 11727 bytes --]

From 1ae902eeb4d5ad7247bf69dffd5f685ce371db80 Mon Sep 17 00:00:00 2001
From: Marcin Puc <tranzystorek.io@protonmail.com>
Date: Fri, 13 Jan 2023 23:34:27 +0100
Subject: [PATCH] New package: Clipboard-0.2.1r2

---
 srcpkgs/Clipboard/patches/support-32bit.patch | 231 ++++++++++++++++++
 srcpkgs/Clipboard/template                    |  25 ++
 2 files changed, 256 insertions(+)
 create mode 100644 srcpkgs/Clipboard/patches/support-32bit.patch
 create mode 100644 srcpkgs/Clipboard/template

diff --git a/srcpkgs/Clipboard/patches/support-32bit.patch b/srcpkgs/Clipboard/patches/support-32bit.patch
new file mode 100644
index 000000000000..20b0bd854d75
--- /dev/null
+++ b/srcpkgs/Clipboard/patches/support-32bit.patch
@@ -0,0 +1,231 @@
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index eb4d9f2..cb1e1eb 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -67,12 +67,5 @@ add_subdirectory(clipboard)
+ 
+ add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
+ 
+-include(CheckCXXCompilerFlag)
+-CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
+-if(COMPILER_SUPPORTS_MARCH_NATIVE AND (NOT DEFINED ENV{CI})) #do not use a native uarch if we are in a CI environment
+-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
+-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
+-endif()
+-
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ADD_FLAGS}")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ADD_FLAGS}")
+diff --git a/src/clipboardx11/src/x11.cpp b/src/clipboardx11/src/x11.cpp
+index ce725d0..2f63e50 100644
+--- a/src/clipboardx11/src/x11.cpp
++++ b/src/clipboardx11/src/x11.cpp
+@@ -228,6 +228,10 @@ private:
+     std::size_t m_size;
+ 
+ public:
++    using format8_t = std::uint8_t;
++    using format16_t = std::uint16_t;
++    using format32_t = std::conditional<sizeof(void*) == sizeof(std::uint64_t), std::uint64_t, std::uint32_t>::type;
++
+     enum Value : std::size_t {
+         Format8 = 8,
+         Format16 = 16,
+@@ -236,9 +240,9 @@ public:
+ 
+     constexpr X11PropertyFormat(Value value) : X11PropertyFormat(
+         static_cast<std::size_t>(value),
+-        value == Format8 ? sizeof(std::uint8_t) :
+-        value == Format8 ? sizeof(std::uint16_t) :
+-        sizeof(std::uint64_t) // No, this is not a mistake. libx11 uses a 64-bit int for the 32 format
++        value == Format8 ? sizeof(format8_t) :
++        value == Format16 ? sizeof(format16_t) :
++        sizeof(format32_t)
+     ) { }
+ 
+     [[nodiscard]] inline std::size_t size() const { return m_size; }
+@@ -250,19 +254,8 @@ public:
+         return { static_cast<Value>(value) };
+     }
+ 
+-    static X11PropertyFormat fromSize(std::size_t size) {
+-        if (size == sizeof(std::uint8_t)) {
+-            return Format8;
+-        }
+-        if (size == sizeof(std::uint16_t)) {
+-            return Format16;
+-        }
+-        if (size == sizeof(std::uint64_t)) {
+-            return Format32;
+-        }
+-
+-        throw X11Exception("Invalid format size");
+-    }
++    template<std::size_t char_t>
++    constexpr static inline X11PropertyFormat fromSize();
+ };
+ 
+ enum class X11PropertyMode : int {
+@@ -277,7 +270,7 @@ private:
+     X11Atom const& m_type;
+     X11PropertyFormat m_format;
+ 
+-    std::variant<std::uint8_t const*, std::unique_ptr<std::uint8_t[]>> m_data8;
++    std::variant<X11PropertyFormat::format8_t const*, std::unique_ptr<X11PropertyFormat::format8_t[]>> m_data8;
+     std::size_t m_size8;
+ 
+ public:
+@@ -294,21 +287,21 @@ public:
+     [[nodiscard]] std::size_t size() const { return m_size8 / m_format.size(); }
+ 
+     [[nodiscard]] std::size_t size8() const { return m_size8; }
+-    [[nodiscard]] std::size_t size16() const { return size8() / X11PropertyFormat{X11PropertyFormat::Format16}.size(); }
+-    [[nodiscard]] std::size_t size32() const { return size8() / X11PropertyFormat{X11PropertyFormat::Format32}.size(); }
++    [[nodiscard]] std::size_t size16() const { return size8() / sizeof(X11PropertyFormat::format16_t); }
++    [[nodiscard]] std::size_t size32() const { return size8() / sizeof(X11PropertyFormat::format32_t); }
+ 
+-    [[nodiscard]] std::uint8_t const* data8() const {
+-        return std::visit([](auto&& arg) -> std::uint8_t const* {
++    [[nodiscard]] X11PropertyFormat::format8_t const* data8() const {
++        return std::visit([](auto&& arg) -> X11PropertyFormat::format8_t const* {
+             using T = std::decay_t<decltype(arg)>;
+-            if constexpr (std::is_same_v<T, uint8_t const*>)
++            if constexpr (std::is_same_v<T, X11PropertyFormat::format8_t const*>)
+                 return arg;
+             else
+                 return arg.get();
+         }, m_data8);
+     }
+ 
+-    [[nodiscard]] std::uint16_t const* data16() const { return reinterpret_cast<std::uint16_t const*>(data8()); }
+-    [[nodiscard]] std::uint64_t const* data32() const { return reinterpret_cast<std::uint64_t const*>(data8()); }
++    [[nodiscard]] X11PropertyFormat::format16_t const* data16() const { return reinterpret_cast<X11PropertyFormat::format16_t const*>(data8()); }
++    [[nodiscard]] X11PropertyFormat::format32_t const* data32() const { return reinterpret_cast<X11PropertyFormat::format32_t const*>(data8()); }
+ 
+     [[nodiscard]] X11PropertyIterator begin() const;
+     [[nodiscard]] X11PropertyIterator end() const;
+@@ -324,7 +317,7 @@ private:
+ public:
+     X11PropertyIterator(X11Property const& property, std::size_t offset) : m_property(property), m_offset(offset) { }
+ 
+-    std::uint64_t operator*() const;
++    X11PropertyFormat::format32_t operator*() const;
+     X11PropertyIterator& operator++();
+     std::partial_ordering operator<=>(X11PropertyIterator const&) const;
+ 
+@@ -830,6 +823,26 @@ std::shared_ptr<X11Window> X11Connection::externalWindow(Window window) {
+     return result;
+ }
+ 
++template<>
++constexpr X11PropertyFormat X11PropertyFormat::fromSize<sizeof(X11PropertyFormat::format8_t)>() { return X11PropertyFormat::Format8; }
++
++template<>
++constexpr X11PropertyFormat X11PropertyFormat::fromSize<sizeof(X11PropertyFormat::format16_t)>() { return X11PropertyFormat::Format16; }
++
++template<>
++constexpr X11PropertyFormat X11PropertyFormat::fromSize<sizeof(X11PropertyFormat::format32_t)>() { return X11PropertyFormat::Format32; }
++
++template<std::size_t T>
++struct AssertFalse : std::false_type
++{ };
++
++template<std::size_t bad_t>
++constexpr X11PropertyFormat X11PropertyFormat::fromSize() {
++    static_assert(AssertFalse<bad_t>::value);
++    return X11PropertyFormat::Format8; // Just here to make the compiler happy
++}
++
++
+ template<ranges::contiguous_range range_t, typename char_t>
+ X11Property::X11Property(
+     X11Atom const& name,
+@@ -839,7 +852,7 @@ X11Property::X11Property(
+ ) : X11Property(
+     name,
+     type,
+-    X11PropertyFormat::fromSize(sizeof(char_t)),
++    X11PropertyFormat::fromSize<sizeof(char_t)>(),
+     data,
+     owned
+ ) { }
+@@ -856,11 +869,11 @@ X11Property::X11Property(
+   , m_format(format)
+   , m_size8(data.size() * sizeof(char_t)) {
+     if (owned) {
+-        auto data8 = std::make_unique<std::uint8_t[]>(m_size8);
++        auto data8 = std::make_unique<X11PropertyFormat::format8_t[]>(m_size8);
+         std::memcpy(data8.get(), &data[0], m_size8);
+-        m_data8.emplace<std::unique_ptr<std::uint8_t[]>>(std::move(data8));
++        m_data8.emplace<std::unique_ptr<X11PropertyFormat::format8_t[]>>(std::move(data8));
+     } else {
+-        m_data8.emplace<std::uint8_t const*>(reinterpret_cast<std::uint8_t const*>(&data[0]));
++        m_data8.emplace<X11PropertyFormat::format8_t const*>(reinterpret_cast<X11PropertyFormat::format8_t const*>(&data[0]));
+     }
+ }
+ 
+@@ -894,7 +907,7 @@ std::partial_ordering X11PropertyIterator::operator<=>(X11PropertyIterator const
+     return m_offset <=> other.m_offset;
+ }
+ 
+-std::uint64_t X11PropertyIterator::operator*() const {
++X11PropertyFormat::format32_t X11PropertyIterator::operator*() const {
+     auto pointer8 = m_property.data8() + (m_property.format().size() * m_offset);
+ 
+     if (m_property.format() == X11PropertyFormat::Format8) {
+@@ -902,11 +915,11 @@ std::uint64_t X11PropertyIterator::operator*() const {
+     }
+ 
+     if (m_property.format() == X11PropertyFormat::Format16) {
+-        return *reinterpret_cast<std::uint16_t const*>(pointer8);
++        return *reinterpret_cast<X11PropertyFormat::format16_t const*>(pointer8);
+     }
+ 
+     if (m_property.format() == X11PropertyFormat::Format32) {
+-        return *reinterpret_cast<std::uint64_t const*>(pointer8);
++        return *reinterpret_cast<X11PropertyFormat::format32_t const*>(pointer8);
+     }
+ 
+     throw X11Exception("Unknown property format");
+@@ -1056,9 +1069,9 @@ X11Property X11Window::getProperty(X11Atom const& name, bool delet) {
+ 
+     Atom actualTypeReturn = None;
+     int actualFormatReturn = 0;
+-    std::size_t nitemsReturn = 0;
+-    std::size_t bytesAfterReturn = 0;
+-    std::uint8_t* propReturn = nullptr;
++    unsigned long nitemsReturn = 0;
++    unsigned long bytesAfterReturn = 0;
++    unsigned char* propReturn = nullptr;
+ 
+     X_CALL(XGetWindowProperty,
+        /*display*/ display(),
+@@ -1487,8 +1500,8 @@ bool X11SelectionDaemon::handleMultipleSelectionRequest(X11SelectionRequest cons
+         return refuseSelectionRequest(request);
+     }
+ 
+-    std::vector<std::uint64_t> result;
+-    std::optional<std::uint64_t> target;
++    std::vector<X11PropertyFormat::format32_t> result;
++    std::optional<X11PropertyFormat::format32_t> target;
+     for (auto&& value : *pairs) {
+         if (!target) {
+             target = value;
+@@ -1508,7 +1521,7 @@ bool X11SelectionDaemon::handleMultipleSelectionRequest(X11SelectionRequest cons
+ }
+ 
+ bool X11SelectionDaemon::handleTargetsSelectionRequest(X11SelectionRequest const& request) {
+-    std::vector<std::uint64_t> data {
++    std::vector<X11PropertyFormat::format32_t> data {
+         atom(atomTargets).value(),
+         atom(atomMultiple).value(),
+         atom(atomTimestamp).value(),
+@@ -1530,8 +1543,7 @@ bool X11SelectionDaemon::handleTimestampSelectionRequest(X11SelectionRequest con
+     debugStream << "Got a TIMESTAMP request" << std::endl;
+     debugStream << "Replying with: " << m_selectionAcquiredTime << std::endl;
+ 
+-    std::vector<std::uint64_t> data { m_selectionAcquiredTime };
+-    return replySelectionRequest(event, atom(atomInteger), data);
++    return replySelectionRequest(event, atom(atomInteger), ranges::single_view(m_selectionAcquiredTime));
+ }
+ 
+ bool X11SelectionDaemon::handleRegularSelectionRequest(X11SelectionRequest const& request) {
diff --git a/srcpkgs/Clipboard/template b/srcpkgs/Clipboard/template
new file mode 100644
index 000000000000..2653f228e4a7
--- /dev/null
+++ b/srcpkgs/Clipboard/template
@@ -0,0 +1,25 @@
+# Template file for 'Clipboard'
+pkgname=Clipboard
+version=0.2.1r2
+revision=1
+build_style=cmake
+hostmakedepends="pkg-config"
+makedepends="libX11-devel"
+short_desc="Cut, copy, and paste anything, anywhere, all from the terminal"
+maintainer="Marcin Puc <tranzystorek.io@protonmail.com>"
+license="GPL-3.0-or-later"
+homepage="https://github.com/Slackadays/Clipboard"
+distfiles="https://github.com/Slackadays/Clipboard/archive/refs/tags/${version}.tar.gz"
+checksum=3d88f14aa38530f0af74c492e0e708b206b56e67bc6d04275dfe12e6983c865a
+
+if [ "${XBPS_TARGET_NO_ATOMIC8}" ]; then
+	makedepends+=" libatomic-devel"
+	CXXFLAGS+=" -latomic"
+fi
+
+post_install() {
+	vman documentation/manpages/man.1 clipboard.1
+
+	# symlink fails to be installed automatically
+	ln -s clipboard "${DESTDIR}/usr/bin/cb"
+}

  parent reply	other threads:[~2023-01-18 11:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-13 22:38 [PR PATCH] " tranzystorek-io
2023-01-13 23:06 ` [PR PATCH] [Updated] " tranzystorek-io
2023-01-13 23:52 ` tranzystorek-io
2023-01-13 23:53 ` Slackadays
2023-01-14  0:04 ` [PR REVIEW] " paper42
2023-01-14  0:16 ` [PR PATCH] [Updated] " tranzystorek-io
2023-01-14  0:17 ` [PR REVIEW] " tranzystorek-io
2023-01-14  4:29 ` Slackadays
2023-01-14  9:51 ` paper42
2023-01-14 22:33 ` [PR PATCH] [Updated] " tranzystorek-io
2023-01-18 11:48 ` tranzystorek-io [this message]
2023-02-02 20:41 ` tranzystorek-io
2023-02-02 21:15 ` [PR PATCH] [Updated] New package: Clipboard-0.3.0 tranzystorek-io
2023-02-07  7:11 ` tranzystorek-io
2023-02-13 18:51 ` [PR PATCH] [Updated] New package: Clipboard-0.3.1 tranzystorek-io
2023-02-13 22:38 ` New package: Clipboard-0.3.2 Slackadays
2023-02-18 17:25 ` [PR PATCH] [Merged]: " leahneukirchen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230118114853.gke36cTO_eplLlmlag0jc66eXaAX1mbeOGITf5NJMCE@z \
    --to=tranzystorek-io@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).