mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 03:42:17 +00:00
Give tempfiles the file extensions Zig expects
This commit is contained in:
parent
16fd39c4f7
commit
9c1291d57d
5 changed files with 54 additions and 13 deletions
|
@ -342,7 +342,12 @@ pub fn build_file<'a>(
|
||||||
app_o_file.to_str().unwrap(),
|
app_o_file.to_str().unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
let builtins_host_file = tempfile::NamedTempFile::new().unwrap();
|
let builtins_host_file = tempfile::Builder::new()
|
||||||
|
.prefix("host_bitcode")
|
||||||
|
.suffix(".o")
|
||||||
|
.rand_bytes(5)
|
||||||
|
.tempfile()
|
||||||
|
.unwrap();
|
||||||
std::fs::write(builtins_host_file.path(), bitcode::HOST_UNIX)
|
std::fs::write(builtins_host_file.path(), bitcode::HOST_UNIX)
|
||||||
.expect("failed to write host builtins object to tempfile");
|
.expect("failed to write host builtins object to tempfile");
|
||||||
|
|
||||||
|
|
|
@ -118,10 +118,10 @@ pub fn build_zig_host_native(
|
||||||
// with LLVM, the builtins are already part of the roc app,
|
// with LLVM, the builtins are already part of the roc app,
|
||||||
// but with the dev backend, they are missing. To minimize work,
|
// but with the dev backend, they are missing. To minimize work,
|
||||||
// we link them as part of the host executable
|
// we link them as part of the host executable
|
||||||
let builtins_bytes = if target.contains("windows") {
|
let (builtins_bytes, builtins_ext) = if target.contains("windows") {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
bitcode::HOST_WINDOWS
|
(bitcode::HOST_WINDOWS, ".obj")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
|
@ -133,7 +133,7 @@ pub fn build_zig_host_native(
|
||||||
} else {
|
} else {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
{
|
{
|
||||||
bitcode::HOST_UNIX
|
(bitcode::HOST_UNIX, ".o")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(unix))]
|
#[cfg(not(unix))]
|
||||||
|
@ -146,7 +146,12 @@ pub fn build_zig_host_native(
|
||||||
|
|
||||||
// TODO in the future when we have numbered releases, this
|
// TODO in the future when we have numbered releases, this
|
||||||
// can go in ~/.cache/roc instead of writing it to a tempdir every time.
|
// can go in ~/.cache/roc instead of writing it to a tempdir every time.
|
||||||
let builtins_host_file = tempfile::NamedTempFile::new().unwrap();
|
let builtins_host_file = tempfile::Builder::new()
|
||||||
|
.prefix("host_bitcode")
|
||||||
|
.suffix(builtins_ext)
|
||||||
|
.rand_bytes(5)
|
||||||
|
.tempfile()
|
||||||
|
.unwrap();
|
||||||
std::fs::write(builtins_host_file.path(), builtins_bytes)
|
std::fs::write(builtins_host_file.path(), builtins_bytes)
|
||||||
.expect("failed to write host builtins object to tempfile");
|
.expect("failed to write host builtins object to tempfile");
|
||||||
|
|
||||||
|
@ -318,14 +323,20 @@ pub fn build_zig_host_native(
|
||||||
.env("PATH", &env_path)
|
.env("PATH", &env_path)
|
||||||
.env("HOME", &env_home);
|
.env("HOME", &env_home);
|
||||||
if let Some(shared_lib_path) = shared_lib_path {
|
if let Some(shared_lib_path) = shared_lib_path {
|
||||||
let builtins_host_file = tempfile::NamedTempFile::new().unwrap();
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
let native_bitcode = bitcode::HOST_WINDOWS;
|
let native_bitcode = bitcode::HOST_WINDOWS;
|
||||||
|
let builtins_ext = ".obj";
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(unix)]
|
||||||
let native_bitcode = bitcode::HOST_UNIX;
|
let native_bitcode = bitcode::HOST_UNIX;
|
||||||
|
let builtins_ext = ".o";
|
||||||
|
|
||||||
|
let builtins_host_file = tempfile::Builder::new()
|
||||||
|
.prefix("host_bitcode")
|
||||||
|
.suffix(builtins_ext)
|
||||||
|
.rand_bytes(5)
|
||||||
|
.tempfile()
|
||||||
|
.unwrap();
|
||||||
std::fs::write(builtins_host_file.path(), native_bitcode)
|
std::fs::write(builtins_host_file.path(), native_bitcode)
|
||||||
.expect("failed to write host builtins object to tempfile");
|
.expect("failed to write host builtins object to tempfile");
|
||||||
|
|
||||||
|
@ -466,7 +477,12 @@ pub fn build_c_host_native(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let builtins_host_file = tempfile::NamedTempFile::new().unwrap();
|
let builtins_host_file = tempfile::Builder::new()
|
||||||
|
.prefix("host_bitcode")
|
||||||
|
.suffix(".o")
|
||||||
|
.rand_bytes(5)
|
||||||
|
.tempfile()
|
||||||
|
.unwrap();
|
||||||
std::fs::write(builtins_host_file.path(), bitcode::HOST_UNIX)
|
std::fs::write(builtins_host_file.path(), bitcode::HOST_UNIX)
|
||||||
.expect("failed to write host builtins object to tempfile");
|
.expect("failed to write host builtins object to tempfile");
|
||||||
|
|
||||||
|
@ -1394,7 +1410,12 @@ pub fn preprocess_host_wasm32(host_input_path: &Path, preprocessed_host_path: &P
|
||||||
(but seems to be an unofficial API)
|
(but seems to be an unofficial API)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let builtins_host_file = tempfile::NamedTempFile::new().unwrap();
|
let builtins_host_file = tempfile::Builder::new()
|
||||||
|
.prefix("host_bitcode")
|
||||||
|
.suffix(".wasm")
|
||||||
|
.rand_bytes(5)
|
||||||
|
.tempfile()
|
||||||
|
.unwrap();
|
||||||
std::fs::write(builtins_host_file.path(), bitcode::HOST_WASM)
|
std::fs::write(builtins_host_file.path(), bitcode::HOST_WASM)
|
||||||
.expect("failed to write host builtins object to tempfile");
|
.expect("failed to write host builtins object to tempfile");
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,12 @@ fn build_wasm_test_host() {
|
||||||
let mut outfile = PathBuf::from(&out_dir).join(PLATFORM_FILENAME);
|
let mut outfile = PathBuf::from(&out_dir).join(PLATFORM_FILENAME);
|
||||||
outfile.set_extension("wasm");
|
outfile.set_extension("wasm");
|
||||||
|
|
||||||
let builtins_host_file = tempfile::NamedTempFile::new().unwrap();
|
let builtins_host_file = tempfile::Builder::new()
|
||||||
|
.prefix("host_bitcode")
|
||||||
|
.suffix(".wasm")
|
||||||
|
.rand_bytes(5)
|
||||||
|
.tempfile()
|
||||||
|
.unwrap();
|
||||||
std::fs::write(builtins_host_file.path(), bitcode::HOST_WASM)
|
std::fs::write(builtins_host_file.path(), bitcode::HOST_WASM)
|
||||||
.expect("failed to write host builtins object to tempfile");
|
.expect("failed to write host builtins object to tempfile");
|
||||||
|
|
||||||
|
|
|
@ -193,7 +193,12 @@ pub fn helper(
|
||||||
.expect("failed to build output object");
|
.expect("failed to build output object");
|
||||||
std::fs::write(&app_o_file, module_out).expect("failed to write object to file");
|
std::fs::write(&app_o_file, module_out).expect("failed to write object to file");
|
||||||
|
|
||||||
let builtins_host_file = tempfile::NamedTempFile::new().unwrap();
|
let builtins_host_file = tempfile::Builder::new()
|
||||||
|
.prefix("host_bitcode")
|
||||||
|
.suffix(".o")
|
||||||
|
.rand_bytes(5)
|
||||||
|
.tempfile()
|
||||||
|
.unwrap();
|
||||||
std::fs::write(builtins_host_file.path(), bitcode::HOST_UNIX)
|
std::fs::write(builtins_host_file.path(), bitcode::HOST_UNIX)
|
||||||
.expect("failed to write host builtins object to tempfile");
|
.expect("failed to write host builtins object to tempfile");
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,12 @@ fn main() {
|
||||||
pre_linked_binary_path.extend(["pre_linked_binary"]);
|
pre_linked_binary_path.extend(["pre_linked_binary"]);
|
||||||
pre_linked_binary_path.set_extension("o");
|
pre_linked_binary_path.set_extension("o");
|
||||||
|
|
||||||
let builtins_host_file = tempfile::NamedTempFile::new().unwrap();
|
let builtins_host_file = tempfile::Builder::new()
|
||||||
|
.prefix("host_bitcode")
|
||||||
|
.suffix(".wasm")
|
||||||
|
.rand_bytes(5)
|
||||||
|
.tempfile()
|
||||||
|
.unwrap();
|
||||||
std::fs::write(builtins_host_file.path(), bitcode::HOST_WASM)
|
std::fs::write(builtins_host_file.path(), bitcode::HOST_WASM)
|
||||||
.expect("failed to write host builtins object to tempfile");
|
.expect("failed to write host builtins object to tempfile");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue