mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
Allow zig hosts
This commit is contained in:
parent
017b53ce23
commit
f79614e769
1 changed files with 27 additions and 13 deletions
|
@ -42,26 +42,40 @@ pub fn link(
|
||||||
pub fn rebuild_host(host_input_path: &Path) {
|
pub fn rebuild_host(host_input_path: &Path) {
|
||||||
let c_host_src = host_input_path.with_file_name("host.c");
|
let c_host_src = host_input_path.with_file_name("host.c");
|
||||||
let c_host_dest = host_input_path.with_file_name("c_host.o");
|
let c_host_dest = host_input_path.with_file_name("c_host.o");
|
||||||
|
let zig_host_src = host_input_path.with_file_name("host.zig");
|
||||||
let rust_host_src = host_input_path.with_file_name("host.rs");
|
let rust_host_src = host_input_path.with_file_name("host.rs");
|
||||||
let rust_host_dest = host_input_path.with_file_name("rust_host.o");
|
let rust_host_dest = host_input_path.with_file_name("rust_host.o");
|
||||||
let cargo_host_src = host_input_path.with_file_name("Cargo.toml");
|
let cargo_host_src = host_input_path.with_file_name("Cargo.toml");
|
||||||
let host_dest = host_input_path.with_file_name("host.o");
|
let host_dest = host_input_path.with_file_name("host.o");
|
||||||
|
|
||||||
let env_path = env::var("PATH").unwrap_or_else(|_| "".to_string());
|
let env_path = env::var("PATH").unwrap_or_else(|_| "".to_string());
|
||||||
// Compile host.c
|
|
||||||
let output = Command::new("clang")
|
|
||||||
.env_clear()
|
|
||||||
.env("PATH", &env_path)
|
|
||||||
.args(&[
|
|
||||||
"-c",
|
|
||||||
c_host_src.to_str().unwrap(),
|
|
||||||
"-o",
|
|
||||||
c_host_dest.to_str().unwrap(),
|
|
||||||
])
|
|
||||||
.output()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
validate_output("host.c", "clang", output);
|
if zig_host_src.exists() {
|
||||||
|
// Compile host.zig
|
||||||
|
let output = Command::new("zig")
|
||||||
|
.env_clear()
|
||||||
|
.env("PATH", &env_path)
|
||||||
|
.args(&["build-obj", zig_host_src.to_str().unwrap()])
|
||||||
|
.output()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
validate_output("host.zig", "zig", output);
|
||||||
|
} else {
|
||||||
|
// Compile host.c
|
||||||
|
let output = Command::new("clang")
|
||||||
|
.env_clear()
|
||||||
|
.env("PATH", &env_path)
|
||||||
|
.args(&[
|
||||||
|
"-c",
|
||||||
|
c_host_src.to_str().unwrap(),
|
||||||
|
"-o",
|
||||||
|
c_host_dest.to_str().unwrap(),
|
||||||
|
])
|
||||||
|
.output()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
validate_output("host.c", "clang", output);
|
||||||
|
}
|
||||||
|
|
||||||
if cargo_host_src.exists() {
|
if cargo_host_src.exists() {
|
||||||
// Compile and link Cargo.toml, if it exists
|
// Compile and link Cargo.toml, if it exists
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue