-
Notifications
You must be signed in to change notification settings - Fork 178
Expand file tree
/
Copy pathdist.rs
More file actions
50 lines (42 loc) · 1.34 KB
/
dist.rs
File metadata and controls
50 lines (42 loc) · 1.34 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
42
43
44
45
46
47
48
49
50
use anyhow::Result;
use crate::{
not_bash::{fs2, rm_rf, run},
project_root,
};
pub struct ClientOpts {
pub version: String,
pub release_tag: String,
}
pub fn run_dist() -> Result<()> {
let dist = project_root().join("dist");
rm_rf(&dist)?;
fs2::create_dir_all(&dist)?;
dist_clarinet()?;
Ok(())
}
fn dist_clarinet() -> Result<()> {
if cfg!(target_os = "linux") {
std::env::set_var("CC", "clang");
run!(
"cargo build --manifest-path ./Cargo.toml --bin clarinet --release
--target x86_64-unknown-linux-musl
"
// We'd want to add, but that requires setting the right linker somehow
// --features=jemalloc
)?;
run!("strip ./target/x86_64-unknown-linux-musl/release/clarinet")?;
} else {
run!("cargo build --manifest-path ./Cargo.toml --bin clarinet --release")?;
}
let (src, dst) = if cfg!(target_os = "linux") {
("./target/x86_64-unknown-linux-musl/release/clarinet", "./dist/clarinet-linux")
} else if cfg!(target_os = "windows") {
("./target/release/clarinet.exe", "./dist/clarinet-windows.exe")
} else if cfg!(target_os = "macos") {
("./target/release/clarinet", "./dist/clarinet-mac")
} else {
panic!("Unsupported OS")
};
fs2::copy(src, dst)?;
Ok(())
}