Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 97 additions & 82 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ metadata.makepad-auto-version = "zqpv-Yj-K7WNVK2I8h5Okhho46Q="
# makepad-widgets = { git = "https://github.com/makepad/makepad", branch = "dev", features = ["serde"] }
# makepad-code-editor = { git = "https://github.com/makepad/makepad", branch = "dev" }

makepad-widgets = { git = "https://github.com/kevinaboos/makepad", branch = "runtime_dpi_override", features = ["serde"] }
makepad-code-editor = { git = "https://github.com/kevinaboos/makepad", branch = "runtime_dpi_override" }
makepad-widgets = { git = "https://github.com/kevinaboos/makepad", branch = "dedup_ios_ime_conversion", features = ["serde"] }
makepad-code-editor = { git = "https://github.com/kevinaboos/makepad", branch = "dedup_ios_ime_conversion" }


## Including this crate automatically configures all `robius-*` crates to work with Makepad.
Expand Down Expand Up @@ -75,7 +75,7 @@ serde = "1.0"
serde_json = "1.0"
thiserror = "2.0.16"
tokio = { version = "1.43.1", features = ["macros", "rt-multi-thread"] }
tracing-subscriber = "0.3.17"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
unicode-segmentation = "1.11.0"
url = "2.5.0"

Expand Down Expand Up @@ -166,6 +166,9 @@ askar-storage = { git = "https://github.com/openwallet-foundation/askar.git" }
[patch."https://github.com/ruma/ruma"]
ruma = { git = "https://github.com/project-robius/ruma.git", branch = "tsp" }

[build-dependencies]
toml = "1"

## On Windows, use the `winresource` crate to embed the app's icon and metadata into the executable.
[target.'cfg(windows)'.build-dependencies]
winresource = "0.1"
Expand Down
95 changes: 95 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,99 @@ fn main() {
res.compile().expect("Failed to compile Windows resources");
}
}

// Get version info about Robrix, the matrix SDK, and testflight.
println!("cargo:rerun-if-changed=Cargo.lock");
let (sdk_version, sdk_git_rev, sdk_url) = read_matrix_sdk_info();
println!("cargo:rustc-env=MATRIX_SDK_VERSION={sdk_version}");
println!("cargo:rustc-env=MATRIX_SDK_GIT_REV={sdk_git_rev}");
println!("cargo:rustc-env=MATRIX_SDK_URL={sdk_url}");

let (robrix_git_rev, robrix_url) = read_robrix_git_info();
println!("cargo:rustc-env=ROBRIX_GIT_COMMIT_HASH={robrix_git_rev}");
println!("cargo:rustc-env=ROBRIX_GIT_COMMIT_URL={robrix_url}");

println!("cargo:rerun-if-env-changed=TESTFLIGHT_BUILD_NUMBER");
let testflight_build = std::env::var("TESTFLIGHT_BUILD_NUMBER").unwrap_or_default();
println!("cargo:rustc-env=TESTFLIGHT_BUILD_NUMBER={testflight_build}");
}

/// Returns Robrix's own current git commit info as a commit hash and a permalink.
fn read_robrix_git_info() -> (String, String) {
// Tell cargo to re-run when the git-tracked HEAD changes.
println!("cargo:rerun-if-changed=.git/HEAD");
if let Ok(head) = std::fs::read_to_string(".git/HEAD") {
if let Some(branch_ref) = head.trim().strip_prefix("ref: ") {
println!("cargo:rerun-if-changed=.git/{branch_ref}");
}
}

let Ok(output) = std::process::Command::new("git")
.args(["rev-parse", "HEAD"])
.output()
else {
return (String::new(), String::new());
};
if !output.status.success() {
return (String::new(), String::new());
}
let full_sha = String::from_utf8_lossy(&output.stdout).trim().to_string();
if full_sha.len() < 8 {
return (String::new(), String::new());
}
let short_rev: String = full_sha.chars().take(8).collect();
let url = format!("https://github.com/project-robius/robrix/tree/{full_sha}");
(short_rev, url)
}

/// Parses Cargo.lock to find the resolved version of `matrix-sdk`.
///
/// Returns `(version, short_git_rev, url)`.
fn read_matrix_sdk_info() -> (String, String, String) {
let Ok(lockfile_text) = std::fs::read_to_string("Cargo.lock") else {
return (String::new(), String::new(), String::new());
};
let Ok(lockfile) = toml::from_str::<toml::Value>(&lockfile_text) else {
return (String::new(), String::new(), String::new());
};

let Some(pkg) = lockfile
.get("package")
.and_then(|p| p.as_array())
.and_then(|pkgs| {
pkgs.iter().find(|p| {
p.get("name").and_then(|n| n.as_str()) == Some("matrix-sdk")
})
})
else {
return (String::new(), String::new(), String::new());
};

let version = pkg
.get("version")
.and_then(|v| v.as_str())
.unwrap_or("")
.to_string();
let source = pkg.get("source").and_then(|s| s.as_str()).unwrap_or("");

// Git sources look like `git+<repo-url>?<query>#<full-commit>`.
// The repo URL is the prefix before `?` or `#`; the commit is after `#`.
let (git_rev, url) = if let Some(rest) = source.strip_prefix("git+") {
let (left, full_commit) = rest.rsplit_once('#').unwrap_or((rest, ""));
let base = left.split_once('?').map_or(left, |(b, _)| b);
let short_rev: String = full_commit.chars().take(8).collect();
let url = if full_commit.is_empty() {
base.to_string()
} else {
format!("{base}/tree/{full_commit}")
};
(short_rev, url)
} else if !version.is_empty() {
// Registry/path/other sources: fall back to the crates.io URL.
(String::new(), format!("https://crates.io/crates/matrix-sdk/{version}"))
} else {
(String::new(), String::new())
};

(version, git_rev, url)
}
13 changes: 11 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,17 @@ impl ScriptHook for App {

impl MatchEvent for App {
fn handle_startup(&mut self, cx: &mut Cx) {
// only init logging/tracing once
let _ = tracing_subscriber::fmt::try_init();
// only init logging/tracing once.
// `matrix_sdk::latest_events` emits a noisy per-room "Timer ... finished"
// INFO line on every load; silence it by default. RUST_LOG still wins
// when set, so you can re-enable it with `RUST_LOG=matrix_sdk::latest_events=info`.
let filter = tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new(
"info,matrix_sdk::latest_events=warn",
));
let _ = tracing_subscriber::fmt()
.with_env_filter(filter)
.try_init();

// On iOS (and potentially other devices), there is a very low limit
// (albeit a soft limit) on max file descriptors, as little as 256.
Expand Down
1 change: 0 additions & 1 deletion src/home/add_room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ script_mod! {
width: Fill
height: 20
}

}
}

Expand Down
2 changes: 1 addition & 1 deletion src/persistence/matrix_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ pub async fn cleanup_orphan_db_dirs() {
}
if active.contains(&path) {
kept += 1;
log!("cleanup_orphan_db_dirs: preserving referenced db dir: {}", path.display());
// log!("cleanup_orphan_db_dirs: preserving referenced db dir: {}", path.display());
continue;
}
let size = dir_size_bytes(&path).await.unwrap_or(0);
Expand Down
Loading
Loading