-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: EDllT <[email protected]> Co-authored-by: TomIO <[email protected]>
- Loading branch information
1 parent
7021972
commit 52646d5
Showing
7 changed files
with
1,211 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
TERMUX_PKG_HOMEPAGE="https://github.com/flxzt/rnote" | ||
TERMUX_PKG_DESCRIPTION="An infinite canvas vector-based drawing application for handwritten notes" | ||
TERMUX_PKG_LICENSE="GPL-3.0" | ||
TERMUX_PKG_MAINTAINER="@EDLLT" | ||
TERMUX_PKG_VERSION="0.11.0" | ||
TERMUX_PKG_SRCURL="https://github.com/flxzt/rnote/archive/v${TERMUX_PKG_VERSION}/v${TERMUX_PKG_VERSION}.tar.gz" | ||
TERMUX_PKG_SHA256=b133d4331963d3c09d3a7477f60fc4c5072471dcbf459379a593ca1724164af4 | ||
TERMUX_PKG_AUTO_UPDATE=true | ||
TERMUX_PKG_DEPENDS="gdk-pixbuf, gettext, glib, graphene, gtk4, hicolor-icon-theme, libadwaita, libcairo, pipewire, pango, poppler" | ||
TERMUX_PKG_BUILD_DEPENDS="libiconv" | ||
TERMUX_PKG_PYTHON_BUILD_DEPS="toml2json" | ||
|
||
__fetch_gettext_rs() { | ||
# Latest version of gettext-sys, provided by the gettext-rs crate | ||
local crate_version | ||
crate_version="$(curl -s https://crates.io/api/v1/crates/gettext-sys | jq --raw-output '.crate.max_stable_version')" | ||
grep -qP '\d+\.\d+\.\d+' <<< "$crate_version" || { | ||
termux_error_exit "Unable to fetch latest version for \`gettext-sys\` crate" | ||
} | ||
local -a crate=( | ||
"https://github.com/gettext-rs/gettext-rs/archive/refs/tags/gettext-sys-$crate_version.tar.gz" # Upstream URL | ||
"$TERMUX_PKG_CACHEDIR/gettext-v$crate_version.tar.gz" # Local save path | ||
'211773408ab61880b94a0ea680785fc21fad307cd42594d547cf5a056627fcda' # SHA256 checksum | ||
) | ||
|
||
# Fetch latest gettext from upstream | ||
local -a upstream=( | ||
"$(. "$TERMUX_SCRIPTDIR/packages/gettext/build.sh"; echo ${TERMUX_PKG_SRCURL})" # Upstream URL (from gettext's build script) | ||
"$TERMUX_PKG_SRCDIR/gettext-source/gettext-sys/gettext-latest.tar.xz" # Local save path | ||
"$(. "$TERMUX_SCRIPTDIR/packages/gettext/build.sh"; echo ${TERMUX_PKG_SHA256})" # SHA256 checksum (from gettext's build script) | ||
) | ||
|
||
termux_download "${crate[@]}" | ||
|
||
tar xf "${crate[1]}" -C "$TERMUX_PKG_SRCDIR" | ||
mv "gettext-rs-gettext-sys-$crate_version" "gettext-source" | ||
|
||
termux_download "${upstream[@]}" | ||
} | ||
|
||
__patch_gettext_rs() { | ||
# Patch gettext-rs crate to use a newer gettext version because the old one doesn't compile properly with clang | ||
patch -p1 -d "$TERMUX_PKG_SRCDIR/gettext-source" -i "$TERMUX_PKG_BUILDER_DIR"/gettext-rs-crate.diff | ||
} | ||
|
||
termux_step_pre_configure() { | ||
termux_setup_cmake | ||
|
||
local _WRAPPER_BIN="${TERMUX_PKG_BUILDDIR}/_wrapper/bin" | ||
mkdir -p "${_WRAPPER_BIN}" | ||
if [[ "${TERMUX_ON_DEVICE_BUILD}" == "false" ]]; then | ||
sed "s|^export PKG_CONFIG_LIBDIR=|export PKG_CONFIG_LIBDIR=${TERMUX_PREFIX}/opt/glib/cross/lib/x86_64-linux-gnu/pkgconfig:|" \ | ||
"${TERMUX_STANDALONE_TOOLCHAIN}/bin/pkg-config" \ | ||
> "${_WRAPPER_BIN}/pkg-config" | ||
chmod +x "${_WRAPPER_BIN}/pkg-config" | ||
export PKG_CONFIG="${_WRAPPER_BIN}/pkg-config" | ||
fi | ||
export PATH="${_WRAPPER_BIN}:${PATH}" | ||
|
||
# Fetch and patch the crate to use a newer upstream gettext version | ||
__fetch_gettext_rs | ||
__patch_gettext_rs | ||
} | ||
|
||
termux_step_make() { | ||
termux_setup_rust | ||
|
||
cd "${TERMUX_PKG_SRCDIR}" || termux_error_exit "Failed to enter source directory, aborting build." | ||
local target | ||
for target in 'rnote-cli' 'rnote'; do | ||
RUSTFLAGS="-C link-arg=-Wl,-rpath=${TERMUX_PREFIX}/lib -C link-arg=-L${TERMUX_PREFIX}/lib -C link-arg=-liconv" \ | ||
cargo build \ | ||
--jobs "${TERMUX_PKG_MAKE_PROCESSES}" \ | ||
--target "${CARGO_TARGET_NAME}" \ | ||
--package "${target}" \ | ||
--release | ||
done | ||
} | ||
|
||
termux_step_post_make_install() { | ||
install -Dm755 "${TERMUX_PKG_SRCDIR}/target/$CARGO_TARGET_NAME/release/rnote-cli" -t "$TERMUX_PREFIX/bin" | ||
install -Dm755 "${TERMUX_PKG_SRCDIR}/target/$CARGO_TARGET_NAME/release/rnote" -t "$TERMUX_PREFIX/bin" | ||
} |
13 changes: 13 additions & 0 deletions
13
x11-packages/rnote/custom-gettext-rs-crate-Cargo.toml.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/Cargo.toml b/Cargo.toml | ||
index 6a6aa16..58b576a 100644 | ||
--- a/Cargo.toml | ||
+++ b/Cargo.toml | ||
@@ -34,7 +34,7 @@ flate2 = "1.0" | ||
fs_extra = "1.3" | ||
futures = "0.3.30" | ||
geo = "0.28.0" | ||
-gettext-rs = { version = "0.7.0", features = ["gettext-system"] } | ||
+gettext-rs = { path = "./gettext-source/gettext-rs" } | ||
gio = "0.19.5" | ||
glib = "0.19.7" | ||
glib-build-tools = "0.19.0" |
62 changes: 62 additions & 0 deletions
62
x11-packages/rnote/disable-cargo-command-meson.build.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
Disable cargo commands | ||
|
||
--- a/meson.build | ||
+++ b/meson.build | ||
@@ -1,6 +1,6 @@ | ||
project( | ||
'rnote', | ||
- ['rust', 'cpp'], | ||
+ ['cpp'], | ||
version: '0.11.0', | ||
meson_version: '>= 1.0', | ||
) | ||
@@ -70,7 +70,6 @@ | ||
dependency('gio-2.0', version: '>= 2.76') | ||
dependency('cairo', version: '>= 1.18') | ||
|
||
-cargo = find_program('cargo', required: true) | ||
# cmake is needed by the "ink-stroke-modeler-rs" bindings crate to build the C++ library | ||
find_program('cmake', required: true) | ||
find_program('glib-compile-resources', required: true) | ||
@@ -108,7 +107,7 @@ | ||
subdir('crates/rnote-compose') | ||
subdir('crates/rnote-engine') | ||
|
||
- | ||
+if false | ||
# cargo fmt check | ||
run_target( | ||
'cargo-fmt-check', | ||
@@ -157,6 +156,7 @@ | ||
], | ||
env: cargo_env, | ||
) | ||
+endif | ||
|
||
# build/install the ui | ||
if build_ui == true | ||
@@ -198,6 +198,7 @@ | ||
ui_output = app_name | ||
endif | ||
|
||
+if false | ||
# ui cargo check | ||
run_target( | ||
'ui-cargo-check', | ||
@@ -251,6 +252,7 @@ | ||
meson.project_build_root() / '@OUTPUT@', | ||
], | ||
) | ||
+endif | ||
|
||
meson.add_install_script( | ||
'build-aux/meson_post_install.py', | ||
@@ -263,7 +265,7 @@ | ||
glib_compile_schemas: true, | ||
gtk_update_icon_cache: true, | ||
update_desktop_database: true, | ||
- update_mime_database: true, | ||
+ update_mime_database: false, | ||
) | ||
|
||
# Windows installer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
diff --git a/crates/rnote-ui/build.rs b/crates/rnote-ui/build.rs | ||
index 9e5c07e..cd7baa5 100644 | ||
--- a/crates/rnote-ui/build.rs | ||
+++ b/crates/rnote-ui/build.rs | ||
@@ -1,5 +1,11 @@ | ||
fn main() -> anyhow::Result<()> { | ||
- compile_gresources()?; | ||
+ let is_cross_compiling = detect_cross_compilation(); | ||
+ | ||
+ if !is_cross_compiling { | ||
+ println!("cargo:rustc-cfg=feature=\"use_glib_build_tools\""); | ||
+ } | ||
+ | ||
+ compile_gresources(is_cross_compiling)?; | ||
|
||
#[cfg(windows)] | ||
compile_icon_winres()?; | ||
@@ -18,11 +24,64 @@ fn compile_icon_winres() -> anyhow::Result<()> { | ||
.context("Failed to compile winresource resource") | ||
} | ||
|
||
-fn compile_gresources() -> anyhow::Result<()> { | ||
- glib_build_tools::compile_resources( | ||
- &["data"], | ||
- "data/resources.gresource.xml", | ||
- "compiled.gresource", | ||
- ); | ||
- Ok(()) | ||
+fn detect_cross_compilation() -> bool { | ||
+ let host = std::env::var("HOST").unwrap_or_default(); | ||
+ let target = std::env::var("TARGET").unwrap_or_default(); | ||
+ host != target | ||
+} | ||
+ | ||
+fn compile_gresources(is_cross_compiling: bool) -> anyhow::Result<()> { | ||
+ use std::env; | ||
+ use std::path::PathBuf; | ||
+ use std::process::Command; | ||
+ | ||
+ let out_dir = env::var("OUT_DIR").expect("OUT_DIR not set"); | ||
+ let output_path = PathBuf::from(&out_dir).join("compiled.gresource"); | ||
+ | ||
+ // First, try using the system's glib-compile-resources | ||
+ let system_result = Command::new("glib-compile-resources") | ||
+ .args(&[ | ||
+ "--sourcedir=data", | ||
+ "data/resources.gresource.xml", | ||
+ &format!("--target={}", output_path.display()), | ||
+ ]) | ||
+ .status(); | ||
+ | ||
+ match system_result { | ||
+ Ok(status) if status.success() => return Ok(()), | ||
+ Ok(_) => println!("glib-compile-resources command failed, trying fallback method..."), | ||
+ Err(e) if e.kind() == std::io::ErrorKind::NotFound => { | ||
+ println!("glib-compile-resources not found, trying fallback method...") | ||
+ } | ||
+ Err(e) => println!( | ||
+ "Error executing glib-compile-resources: {}, trying fallback method...", | ||
+ e | ||
+ ), | ||
+ } | ||
+ | ||
+ // If cross-compiling, don't use glib_build_tools | ||
+ if is_cross_compiling { | ||
+ return Err(anyhow::anyhow!( | ||
+ "Failed to compile gresources: system glib-compile-resources failed and we're cross-compiling. \ | ||
+ Please ensure you have glib development tools installed on your target system." | ||
+ )); | ||
+ } | ||
+ | ||
+ // If not cross-compiling and system command fails, fall back to glib_build_tools if available | ||
+ #[cfg(feature = "use_glib_build_tools")] | ||
+ { | ||
+ println!("Attempting to use glib_build_tools::compile_resources..."); | ||
+ glib_build_tools::compile_resources( | ||
+ &["data"], | ||
+ "data/resources.gresource.xml", | ||
+ output_path.to_str().unwrap(), | ||
+ ); | ||
+ Ok(()) | ||
+ } | ||
+ | ||
+ #[cfg(not(feature = "use_glib_build_tools"))] | ||
+ Err(anyhow::anyhow!( | ||
+ "Failed to compile gresources: system glib-compile-resources failed and glib_build_tools is not available. \ | ||
+ Please ensure you have glib development tools installed on your system." | ||
+ )) | ||
} | ||
|
||
diff --git a/crates/rnote-ui/Cargo.toml b/crates/rnote-ui/Cargo.toml | ||
index 426d8e9..55447fc 100644 | ||
--- a/crates/rnote-ui/Cargo.toml | ||
+++ b/crates/rnote-ui/Cargo.toml | ||
@@ -58,7 +58,10 @@ url = { workspace = true } | ||
|
||
[build-dependencies] | ||
anyhow = { workspace = true } | ||
-glib-build-tools = { workspace = true } | ||
+glib-build-tools = { workspace = true, optional = true } | ||
+ | ||
+[features] | ||
+use_glib_build_tools = ["glib-build-tools"] | ||
|
||
[target.'cfg(windows)'.build-dependencies] | ||
winresource = { workspace = true } |
Oops, something went wrong.