Skip to content

Commit db26b64

Browse files
committed
use build.rs to replace xcap
1 parent 4dda23b commit db26b64

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

crates/goose-mcp/build.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
use std::process::Command;
2+
use std::env;
3+
4+
#[cfg(target_os = "android")]
5+
fn main() {
6+
println!("cargo:rerun-if-changed=src/");
7+
8+
// Get the path to Cargo.toml relative to the build.rs script
9+
let cargo_toml_path = env::current_dir()
10+
.expect("Failed to get current directory")
11+
.join("Cargo.toml");
12+
13+
// Convert path to string
14+
let cargo_toml_path_str = cargo_toml_path.to_str()
15+
.expect("Failed to convert path to string");
16+
17+
// Execute the sed command to add a comment after the [package] section
18+
let output = Command::new("sed")
19+
.arg("-i")
20+
.arg(format!("s|xcap = \"0.0.14\"|xcap = {{ package = \"xcap\", git = \"https://github.com/shawn111/xcap\", branch = \"android\" }}|"))
21+
.arg(cargo_toml_path_str)
22+
.output()
23+
.expect("Failed to execute sed command");
24+
25+
if !output.status.success() {
26+
eprintln!("sed command failed:");
27+
eprintln!("Stdout: {}", String::from_utf8_lossy(&output.stdout));
28+
eprintln!("Stderr: {}", String::from_utf8_lossy(&output.stderr));
29+
panic!("Failed to modify Cargo.toml with sed.");
30+
}
31+
32+
println!("Successfully added comment to Cargo.toml using sed.");
33+
}
34+
35+
#[cfg(not(target_os = "android"))]
36+
fn main() {
37+
// Do nothing on non-Android platforms
38+
println!("cargo:rerun-if-changed=src/");
39+
}

0 commit comments

Comments
 (0)