Merge pull request #1634 from rtfeldman/fix_macos

Fix MacOS
This commit is contained in:
Richard Feldman 2021-08-29 16:13:56 -04:00 committed by GitHub
commit 7c2963d31d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 45 deletions

View File

@ -1,5 +0,0 @@
#!/bin/bash
set -euxo pipefail
zig build-obj src/main.zig -O ReleaseFast -femit-llvm-ir=builtins.ll -femit-bin=builtins.o --strip

View File

@ -24,9 +24,6 @@ fn main() {
return;
}
let big_sur_path = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib";
let use_build_script = Path::new(big_sur_path).exists();
// "." is relative to where "build.rs" is
let build_script_dir_path = fs::canonicalize(Path::new(".")).unwrap();
let bitcode_path = build_script_dir_path.join("bitcode");
@ -40,26 +37,18 @@ fn main() {
let dest_ir_path = bitcode_path.join("builtins-64bit.ll");
let dest_ir_64bit = dest_ir_path.to_str().expect("Invalid dest ir path");
if use_build_script {
println!(
"Compiling zig object & ir to: {} and {}",
src_obj, dest_ir_64bit
);
run_command_with_no_args(&bitcode_path, "./build.sh");
} else {
println!("Compiling zig object to: {}", src_obj);
run_command(&bitcode_path, "zig", &["build", "object", "-Drelease=true"]);
println!("Compiling zig object to: {}", src_obj);
run_command(&bitcode_path, "zig", &["build", "object", "-Drelease=true"]);
println!("Compiling 64-bit ir to: {}", dest_ir_64bit);
run_command(&bitcode_path, "zig", &["build", "ir", "-Drelease=true"]);
println!("Compiling 64-bit ir to: {}", dest_ir_64bit);
run_command(&bitcode_path, "zig", &["build", "ir", "-Drelease=true"]);
println!("Compiling 32-bit ir to: {}", dest_ir_32bit);
run_command(
&bitcode_path,
"zig",
&["build", "ir-32bit", "-Drelease=true"],
);
}
println!("Compiling 32-bit ir to: {}", dest_ir_32bit);
run_command(
&bitcode_path,
"zig",
&["build", "ir-32bit", "-Drelease=true"],
);
println!("Moving zig object to: {}", dest_obj);
@ -119,25 +108,6 @@ where
}
}
fn run_command_with_no_args<P: AsRef<Path>>(path: P, command_str: &str) {
let output_result = Command::new(OsStr::new(&command_str))
.current_dir(path)
.output();
match output_result {
Ok(output) => match output.status.success() {
true => (),
false => {
let error_str = match str::from_utf8(&output.stderr) {
Ok(stderr) => stderr.to_string(),
Err(_) => format!("Failed to run \"{}\"", command_str),
};
panic!("{} failed: {}", command_str, error_str);
}
},
Err(reason) => panic!("{} failed: {}", command_str, reason),
}
}
fn get_zig_files(dir: &Path, cb: &dyn Fn(&Path)) -> io::Result<()> {
if dir.is_dir() {
for entry in fs::read_dir(dir)? {