-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathbuild.rs
More file actions
39 lines (38 loc) · 1.21 KB
/
build.rs
File metadata and controls
39 lines (38 loc) · 1.21 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
use std::env;
use std::fs::copy;
use std::path::PathBuf;
use std::process::Command;
fn main() {
// Build the otterc_runtime static library and pull it into the target directory
// so it's available with the otter binary. The otter compiler will use this static
// lib when compiling Otter programs.
let release = if let Ok(profile) = env::var("PROFILE") {
profile == "release"
} else {
false
};
let runtime_dir = PathBuf::from("crates/otterc_runtime");
let mut cmd = Command::new("cargo");
cmd.arg("rustc");
if release {
cmd.arg("--release");
}
cmd.args(["--lib", "--crate-type=staticlib", "--target-dir", "target"])
.current_dir(&runtime_dir)
.status()
.expect("Failed to build otterc_runtime");
let target_dir = PathBuf::from(if release {
"target/release"
} else {
"target/debug"
});
#[cfg(target_os = "windows")]
let runtime_lib = "otterc_runtime.lib";
#[cfg(not(target_os = "windows"))]
let runtime_lib = "libotterc_runtime.a";
copy(
runtime_dir.join(&target_dir).join(runtime_lib),
target_dir.join(runtime_lib),
)
.expect("Failed to copy otterc_runtime library");
}