mirror of
https://code.gri.mw/GUI/grim.git
synced 2026-07-18 12:48:55 +00:00
8c48d2f5ce
The Linux release no longer ships a loose nym-socks5-client beside AppRun. It's baked into the goblin binary the same way the Windows build bakes it into goblin.exe, and extracted to ~/.local/share/Goblin at first launch (chmod +x on Unix). The AppImage is now one self-contained file with nothing loose to misplace. - build.rs: generalised the Windows-only GOBLIN_NYM_WIN_BIN embed to a cross-platform path. GOBLIN_NYM_UNIX_BIN embeds the Linux/macOS sidecar; Android never embeds (its sidecar rides in the APK's jniLibs). - src/nym/sidecar.rs: the embedded const, extract_embedded_sidecar, and the binary_path extract branch now cover all non-Android targets, with a Unix chmod +x on the freshly written file. - linux/build_release.sh: rewritten to set GOBLIN_NYM_UNIX_BIN, apply the glibc-2.17 zigbuild + CRoaring-AVX512/vendored-OpenSSL fixes, and assemble an AppDir with no loose sidecar.
90 lines
3.3 KiB
Rust
90 lines
3.3 KiB
Rust
use std::env;
|
|
use std::path::PathBuf;
|
|
use std::process::Command;
|
|
|
|
/// The GRIM commit Goblin forked from; builds count commits on top of it.
|
|
const GOBLIN_FORK_BASE: &str = "b51a46b";
|
|
|
|
fn main() {
|
|
built::write_built_file().expect("Failed to acquire build-time information");
|
|
|
|
// Goblin versioning is build-based: Build N = commits since the fork.
|
|
// An explicit GOBLIN_BUILD env wins (CI builds from the public single-commit
|
|
// squash where the fork base isn't an ancestor, so the git count can't run);
|
|
// otherwise count commits since the fork; "dev" only as a last resort.
|
|
let build = env::var("GOBLIN_BUILD")
|
|
.ok()
|
|
.map(|s| s.trim().to_string())
|
|
.filter(|s| !s.is_empty())
|
|
.or_else(|| {
|
|
Command::new("git")
|
|
.args([
|
|
"rev-list",
|
|
"--count",
|
|
&format!("{}..HEAD", GOBLIN_FORK_BASE),
|
|
])
|
|
.output()
|
|
.ok()
|
|
.filter(|o| o.status.success())
|
|
.and_then(|o| String::from_utf8(o.stdout).ok())
|
|
.map(|s| s.trim().to_string())
|
|
.filter(|s| !s.is_empty())
|
|
})
|
|
.unwrap_or_else(|| "dev".to_string());
|
|
println!("cargo:rustc-env=GOBLIN_BUILD={}", build);
|
|
// .git/HEAD only changes on branch switches; the reflog is appended on
|
|
// every commit, so the build number stays current.
|
|
println!("cargo:rerun-if-changed=.git/HEAD");
|
|
println!("cargo:rerun-if-changed=.git/logs/HEAD");
|
|
println!("cargo:rerun-if-env-changed=GOBLIN_BUILD");
|
|
|
|
// Setting up git hooks in the project: rustfmt and so on.
|
|
let git_hooks = format!(
|
|
"git config core.hooksPath {}",
|
|
PathBuf::from("./.hooks").to_str().unwrap()
|
|
);
|
|
|
|
if cfg!(target_os = "windows") {
|
|
Command::new("cmd")
|
|
.args(&["/C", &git_hooks])
|
|
.output()
|
|
.expect("failed to execute git config for hooks");
|
|
} else {
|
|
Command::new("sh")
|
|
.args(&["-c", &git_hooks])
|
|
.output()
|
|
.expect("failed to execute git config for hooks");
|
|
}
|
|
|
|
// Goblin routes all traffic over the Nym mixnet via a bundled
|
|
// `nym-socks5-client` sidecar (see src/nym/); there is no embedded Tor and
|
|
// thus no webtunnel pluggable-transport binary to build here anymore.
|
|
|
|
// Single-file desktop builds: embed the matching nym-socks5-client into the
|
|
// goblin binary so the release ships as ONE self-contained file with no loose
|
|
// sidecar beside it. At startup the app extracts it to a per-user data dir and
|
|
// runs it (src/nym/sidecar.rs). Windows reads GOBLIN_NYM_WIN_BIN (a .exe);
|
|
// Linux/macOS read GOBLIN_NYM_UNIX_BIN. Android does NOT embed — its sidecar
|
|
// rides in the APK's jniLibs (the only exec-allowed location).
|
|
println!("cargo:rerun-if-env-changed=GOBLIN_NYM_WIN_BIN");
|
|
println!("cargo:rerun-if-env-changed=GOBLIN_NYM_UNIX_BIN");
|
|
println!("cargo:rustc-check-cfg=cfg(goblin_embed_nym)");
|
|
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
|
|
let embed = match target_os.as_str() {
|
|
"windows" => Some(("GOBLIN_NYM_WIN_BIN", "nym-socks5-client.exe")),
|
|
"android" => None,
|
|
_ => Some(("GOBLIN_NYM_UNIX_BIN", "nym-socks5-client")),
|
|
};
|
|
if let Some((var, out_name)) = embed {
|
|
if let Ok(src) = env::var(var) {
|
|
if !src.is_empty() {
|
|
let out = PathBuf::from(env::var("OUT_DIR").unwrap()).join(out_name);
|
|
std::fs::copy(&src, &out)
|
|
.unwrap_or_else(|e| panic!("copy {var} into OUT_DIR for embedding: {e}"));
|
|
println!("cargo:rustc-cfg=goblin_embed_nym");
|
|
println!("cargo:rerun-if-changed={}", src);
|
|
}
|
|
}
|
|
}
|
|
}
|