Skip to content

Commit

Permalink
codesnap: bump to 0.10.5 (#1506)
Browse files Browse the repository at this point in the history
  • Loading branch information
licy183 authored Feb 9, 2025
1 parent ae737dd commit a05449c
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 0 deletions.
103 changes: 103 additions & 0 deletions tur/codesnap/arboard-dummy-platform.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
https://github.com/1Password/arboard/pull/50
--- a/src/common.rs
+++ b/src/common.rs
@@ -28,6 +28,7 @@
/// This can be caused by a few conditions:
/// - Using the Primary clipboard with an older Wayland compositor (that doesn't support version 2)
/// - Using the Secondary clipboard on Wayland
+ /// - Using the clipboard on an unsupported platform
ClipboardNotSupported,

/// The native clipboard is not accessible due to being held by an other party.
--- /dev/null
+++ b/src/platform/dummy.rs
@@ -0,0 +1,78 @@
+/*
+SPDX-License-Identifier: Apache-2.0 OR MIT
+
+Copyright 2022 The Arboard contributors
+
+The project to which this file belongs is licensed under either of
+the Apache 2.0 or the MIT license at the licensee's choice. The terms
+and conditions of the chosen license apply to this file.
+*/
+
+use crate::common::Error;
+#[cfg(feature = "image-data")]
+use crate::common::ImageData;
+use std::borrow::Cow;
+
+pub(crate) struct Clipboard { }
+
+impl Clipboard {
+ pub(crate) fn new() -> Result<Clipboard, Error> {
+ Ok(Self {})
+ }
+}
+
+pub(crate) struct Get<'clipboard> {
+ clipboard: &'clipboard mut Clipboard,
+}
+
+impl<'clipboard> Get<'clipboard> {
+ pub(crate) fn new(clipboard: &'clipboard mut Clipboard) -> Self {
+ Self { clipboard }
+ }
+
+ pub(crate) fn text(self) -> Result<String, Error> {
+ Err(Error::ContentNotAvailable)
+ }
+
+ #[cfg(feature = "image-data")]
+ pub(crate) fn image(self) -> Result<ImageData<'static>, Error> {
+ Err(Error::ContentNotAvailable)
+ }
+}
+
+pub(crate) struct Set<'clipboard> {
+ clipboard: &'clipboard mut Clipboard,
+}
+
+impl<'clipboard> Set<'clipboard> {
+ pub(crate) fn new(clipboard: &'clipboard mut Clipboard) -> Self {
+ Self { clipboard }
+ }
+
+ pub(crate) fn text(self, data: Cow<'_, str>) -> Result<(), Error> {
+ Err(Error::ClipboardNotSupported)
+ }
+
+ pub(crate) fn html(self, html: Cow<'_, str>, alt: Option<Cow<'_, str>>) -> Result<(), Error> {
+ Err(Error::ClipboardNotSupported)
+ }
+
+ #[cfg(feature = "image-data")]
+ pub(crate) fn image(self, data: ImageData) -> Result<(), Error> {
+ Err(Error::ClipboardNotSupported)
+ }
+}
+
+pub(crate) struct Clear<'clipboard> {
+ clipboard: &'clipboard mut Clipboard,
+}
+
+impl<'clipboard> Clear<'clipboard> {
+ pub(crate) fn new(clipboard: &'clipboard mut Clipboard) -> Self {
+ Self { clipboard }
+ }
+
+ pub(crate) fn clear(self) -> Result<(), Error> {
+ Err(Error::ClipboardNotSupported)
+ }
+}
--- a/src/platform/mod.rs
+++ b/src/platform/mod.rs
@@ -15,3 +15,8 @@
mod osx;
#[cfg(target_os = "macos")]
pub use osx::*;
+
+#[cfg(target_os = "android")]
+mod dummy;
+#[cfg(target_os = "android")]
+pub use dummy::*;
41 changes: 41 additions & 0 deletions tur/codesnap/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
TERMUX_PKG_HOMEPAGE="https://github.com/mistricky/CodeSnap"
TERMUX_PKG_DESCRIPTION="Pure Rust tool to generate beautiful code snapshots, provide CLI and Library"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_LICENSE_FILE="LICENSE"
TERMUX_PKG_MAINTAINER="@termux-user-repository"
TERMUX_PKG_VERSION="0.10.5"
TERMUX_PKG_SRCURL="https://github.com/mistricky/CodeSnap/archive/refs/tags/v$TERMUX_PKG_VERSION.tar.gz"
TERMUX_PKG_SHA256=f9ba0e36aab5c671f8068ca0d7bbd3cab4432f72096dbc6c425f4aaf9bc1b780
TERMUX_PKG_AUTO_UPDATE=true
TERMUX_PKG_BUILD_IN_SRC=true

termux_step_pre_configure() {
termux_setup_rust

: "${CARGO_HOME:=$HOME/.cargo}"
export CARGO_HOME

cargo vendor
patch --silent -p1 \
-d ./vendor/arboard/ \
< "$TERMUX_PKG_BUILDER_DIR"/arboard-dummy-platform.diff

echo "" >> Cargo.toml
echo '[patch.crates-io]' >> Cargo.toml
echo 'arboard = { path = "./vendor/arboard" }' >> Cargo.toml
}

termux_step_make() {
cargo build --jobs $TERMUX_PKG_MAKE_PROCESSES --target $CARGO_TARGET_NAME --release
}

termux_step_make_install() {
install -Dm700 -t $TERMUX_PREFIX/bin target/${CARGO_TARGET_NAME}/release/codesnap

install -Dm600 -t $TERMUX_PREFIX/share/doc/$TERMUX_PKG_NAME README.*
}

termux_step_post_make_install() {
# Remove the vendor sources to save space
rm -rf "$TERMUX_PKG_SRCDIR"/vendor
}

0 comments on commit a05449c

Please sign in to comment.