forked from encounter/objdiff
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.rs
More file actions
41 lines (39 loc) · 1.42 KB
/
Copy pathupdate.rs
File metadata and controls
41 lines (39 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use anyhow::Result;
use cfg_if::cfg_if;
use const_format::formatcp;
use objdiff_core::jobs::update::self_update;
use self_update::{cargo_crate_version, update::ReleaseUpdate};
pub const OS: &str = std::env::consts::OS;
cfg_if! {
if #[cfg(target_arch = "aarch64")] {
cfg_if! {
if #[cfg(any(windows, target_os = "macos"))] {
pub const ARCH: &str = "arm64";
} else {
pub const ARCH: &str = std::env::consts::ARCH;
}
}
} else if #[cfg(target_arch = "arm")] {
pub const ARCH: &str = "armv7l";
} else {
pub const ARCH: &str = std::env::consts::ARCH;
}
}
pub const GITHUB_USER: &str = "encounter";
pub const GITHUB_REPO: &str = "objdiff";
pub const BIN_NAME_NEW: &str =
formatcp!("objdiff-gui-{}-{}{}", OS, ARCH, std::env::consts::EXE_SUFFIX);
pub const BIN_NAME_OLD: &str = formatcp!("objdiff-{}-{}{}", OS, ARCH, std::env::consts::EXE_SUFFIX);
pub const RELEASE_URL: &str =
formatcp!("https://github.com/{}/{}/releases/latest", GITHUB_USER, GITHUB_REPO);
pub fn build_updater() -> Result<Box<dyn ReleaseUpdate>> {
Ok(self_update::backends::github::Update::configure()
.repo_owner(GITHUB_USER)
.repo_name(GITHUB_REPO)
// bin_name is required, but unused?
.bin_name(BIN_NAME_NEW)
.no_confirm(true)
.show_output(false)
.current_version(cargo_crate_version!())
.build()?)
}