-
-
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.
- Loading branch information
Showing
7 changed files
with
1,107 additions
and
14 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
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" |
File renamed without changes.
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 } |
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,180 @@ | ||
Patch gettext-rs crate to use the a custom gettext fetched from upstream instead | ||
Patch systest crate to skip testing gettext binary when cross compiling | ||
|
||
diff --git a/gettext-rs/Cargo.toml b/gettext-rs/Cargo.toml | ||
index f98bba8..b374080 100644 | ||
--- a/gettext-rs/Cargo.toml | ||
+++ b/gettext-rs/Cargo.toml | ||
@@ -18,7 +18,7 @@ name = "gettextrs" | ||
gettext-system = ["gettext-sys/gettext-system"] | ||
|
||
[dependencies.gettext-sys] | ||
-version = "0.21.0" | ||
+version = "0.22.0" | ||
path = "../gettext-sys" | ||
|
||
[dependencies] | ||
diff --git a/gettext-rs/tests/integration.rs b/gettext-rs/tests/integration.rs | ||
index bae3cc1..8d52953 100644 | ||
--- a/gettext-rs/tests/integration.rs | ||
+++ b/gettext-rs/tests/integration.rs | ||
@@ -86,7 +86,7 @@ fn dcgettext_fn() { | ||
); | ||
|
||
assert_eq!( | ||
- dcgettext("bound_domain", "Hello, World!", LocaleCategory::LcAll), | ||
+ dcgettext("bound_domain", "Hello, World!", LocaleCategory::LcMessages), | ||
"Hello, World!" | ||
); | ||
} | ||
@@ -156,7 +156,7 @@ fn dcngettext_fn() { | ||
"Hello, World!", | ||
"Hello, Worlds!", | ||
1, | ||
- LocaleCategory::LcAll | ||
+ LocaleCategory::LcMessages | ||
), | ||
"Hello, World!" | ||
); | ||
@@ -166,7 +166,7 @@ fn dcngettext_fn() { | ||
"Hello, World!", | ||
"Hello, Worlds!", | ||
2, | ||
- LocaleCategory::LcAll | ||
+ LocaleCategory::LcMessages | ||
), | ||
"Hello, Worlds!" | ||
); | ||
diff --git a/gettext-sys/Cargo.toml b/gettext-sys/Cargo.toml | ||
index b5f849c..3baf2fd 100644 | ||
--- a/gettext-sys/Cargo.toml | ||
+++ b/gettext-sys/Cargo.toml | ||
@@ -2,7 +2,7 @@ | ||
name = "gettext-sys" | ||
description = "Raw FFI bindings for gettext" | ||
license = "MIT" | ||
-version = "0.21.4" | ||
+version = "0.22.5" | ||
authors = ["Brian Olsen <[email protected]>", "Alexander Batischev <[email protected]>"] | ||
build = "build.rs" | ||
links = "gettext" | ||
diff --git a/gettext-sys/build.rs b/gettext-sys/build.rs | ||
index 7772f74..42bc167 100644 | ||
--- a/gettext-sys/build.rs | ||
+++ b/gettext-sys/build.rs | ||
@@ -191,7 +191,7 @@ fn main() { | ||
let mut cmd = Command::new("tar"); | ||
cmd.current_dir(&build_dir.join("gettext")) | ||
.arg("xJf") | ||
- .arg(&src.join("gettext-0.21.tar.xz")) | ||
+ .arg(&src.join("gettext-0.22.5.tar.xz")) | ||
.arg("--strip-components") | ||
.arg("1"); | ||
if host.contains("windows") { | ||
diff --git a/systest/Cargo.toml b/systest/Cargo.toml | ||
index 61895bb..43462d8 100644 | ||
--- a/systest/Cargo.toml | ||
+++ b/systest/Cargo.toml | ||
@@ -10,3 +10,6 @@ gettext-sys = { path = "../gettext-sys" } | ||
|
||
[build-dependencies] | ||
ctest2 = "0.4" | ||
+ | ||
+[features] | ||
+cross_compiling = [] | ||
diff --git a/systest/build.rs b/systest/build.rs | ||
index 42650d9..c8bbca1 100644 | ||
--- a/systest/build.rs | ||
+++ b/systest/build.rs | ||
@@ -5,9 +5,18 @@ use std::path::{Path, PathBuf}; | ||
use std::process::{self, Command}; | ||
|
||
fn main() { | ||
+ let target = env::var("TARGET").unwrap(); | ||
+ let host = env::var("HOST").unwrap(); | ||
+ let is_cross = target != host; | ||
+ | ||
+ // Set the cross_compiling flag before the tests | ||
+ if is_cross { | ||
+ println!("cargo:rustc-cfg=cross_compiling"); | ||
+ println!("cargo::rustc-check-cfg=cfg(cross_compiling)"); | ||
+ } | ||
+ | ||
let mut cfg = ctest2::TestGenerator::new(); | ||
|
||
- let target = env::var("TARGET").unwrap(); | ||
if target.contains("freebsd") { | ||
cfg.include("/usr/local/include"); | ||
} | ||
@@ -22,24 +31,38 @@ fn main() { | ||
// Skip ptr check because the symbol name is different between glibc | ||
// implementation and static lib. | ||
// eg. gettext is libintl_gettext in static lib | ||
- if env::var_os("GETTEXT_SYSTEM").is_none() || env::var("TARGET").unwrap().contains("windows") { | ||
+ if env::var_os("GETTEXT_SYSTEM").is_none() || target.contains("windows") { | ||
println!("Skipping ptr check"); | ||
cfg.skip_fn_ptrcheck(|_| true); | ||
} | ||
|
||
cfg.generate("../gettext-sys/lib.rs", "all.rs"); | ||
|
||
- // Check that we can find and run gettext binary | ||
+ // Check for the existence of the gettext binary | ||
let cmd = if let Some(bin) = env::var_os("DEP_GETTEXT_BIN") { | ||
Path::new(&bin).join("gettext") | ||
} else { | ||
PathBuf::from("gettext") | ||
}; | ||
- let c = Command::new(&cmd).arg("--version").spawn(); | ||
- if let Ok(mut child) = c { | ||
- assert!(child.wait().unwrap().success()); | ||
- } else { | ||
- println!("Could not run {}", cmd.display()); | ||
+ | ||
+ if !cmd.exists() { | ||
+ println!( | ||
+ "cargo:warning=Gettext binary not found at {}", | ||
+ cmd.display() | ||
+ ); | ||
process::exit(1); | ||
} | ||
+ | ||
+ // Only run the binary if not cross-compiling | ||
+ if !is_cross { | ||
+ let c = Command::new(&cmd).arg("--version").spawn(); | ||
+ if let Ok(mut child) = c { | ||
+ assert!(child.wait().unwrap().success()); | ||
+ } else { | ||
+ println!("Could not run {}", cmd.display()); | ||
+ process::exit(1); | ||
+ } | ||
+ } else { | ||
+ println!("cargo:warning=Cross-compiling detected. Gettext binary found but not executed."); | ||
+ } | ||
} | ||
diff --git a/systest/src/main.rs b/systest/src/main.rs | ||
index befa675..522275d 100644 | ||
--- a/systest/src/main.rs | ||
+++ b/systest/src/main.rs | ||
@@ -1,7 +1,20 @@ | ||
#![allow(bad_style)] | ||
- | ||
+#![allow(unused_imports)] | ||
extern crate gettext_sys; | ||
|
||
+#[cfg(not(feature = "cross_compiling"))] | ||
use gettext_sys::*; | ||
|
||
+#[cfg(not(cross_compiling))] | ||
include!(concat!(env!("OUT_DIR"), "/all.rs")); | ||
+ | ||
+#[cfg(feature = "cross_compiling")] | ||
+fn main() { | ||
+ println!("Cross-compilation detected. Skipping system tests."); | ||
+} | ||
+ | ||
+#[cfg(feature = "cross_compiling")] | ||
+#[test] | ||
+fn dummy_cross_compile_test() { | ||
+ println!("Cross-compilation detected. Skipping system tests."); | ||
+} |
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,18 @@ | ||
diff --git a/Cargo.toml b/Cargo.toml | ||
index 6a6aa16..7043460 100644 | ||
--- a/Cargo.toml | ||
+++ b/Cargo.toml | ||
@@ -94,11 +94,11 @@ piet-cairo = { git = "https://github.com/linebender/piet", rev = "02eb5f0152e893 | ||
|
||
[profile.dev] | ||
debug = true | ||
-opt-level = 2 | ||
+opt-level = 0 # We want proper gdb debugging for dev builds | ||
|
||
[profile.release] | ||
codegen-units = 1 | ||
lto = "fat" | ||
opt-level = 3 | ||
# We want to be able to debug in the release build as well | ||
-debug = true | ||
+#debug = true # Performance and size matters for termux's packaging |
Oops, something went wrong.