1use std::path::Path;
2
3use rootcause::prelude::ResultExt;
4
5use crate::installers::Installer;
6
7pub struct Rio<'a> {
8 pub dev_tools_dir: &'a Path,
9 pub bin_dir: &'a Path,
10}
11
12impl Installer for Rio<'_> {
13 fn bin_name(&self) -> &'static str {
14 "rio"
15 }
16
17 fn install(&self) -> rootcause::Result<()> {
20 let source_dir = self.dev_tools_dir.join(self.bin_name()).join("source");
21
22 ytil_cmd::silent_cmd("sh")
23 .args([
24 "-c",
25 &format!(
26 r#"
27 ([ ! -d "{0}" ] && \
28 git clone --depth=1 https://github.com/raphamorim/rio.git {0} || true) && \
29 cd {0} && \
30 git fetch origin main --depth=1 && \
31 git checkout origin/main && \
32 rustup target add aarch64-apple-darwin && \
33 make release-macos
34 "#,
35 source_dir.display(),
36 ),
37 ])
38 .status()
39 .context("failed to spawn build command")?
40 .exit_ok()
41 .context("build failed")
42 .attach_with(|| format!("tool={}", self.bin_name()))
43 .attach_with(|| format!("source_dir={}", source_dir.display()))?;
44
45 let app = source_dir.join("release").join("Rio.app");
46
47 crate::installers::install_macos_app(&app, self.bin_dir, self.bin_name())?;
48
49 Ok(())
50 }
51
52 fn health_check_args(&self) -> Option<&[&str]> {
53 Some(&["--version"])
54 }
55
56 fn should_verify_checksum(&self) -> bool {
57 false
58 }
59}