From e8f6f69bff6bf8bd672e4a1ed56bb42098d39a29 Mon Sep 17 00:00:00 2001 From: Folkert Date: Tue, 30 Aug 2022 14:16:20 +0200 Subject: [PATCH] make filenames cross-platform --- crates/compiler/build/src/link.rs | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/crates/compiler/build/src/link.rs b/crates/compiler/build/src/link.rs index fce8ece2f0..536b655a69 100644 --- a/crates/compiler/build/src/link.rs +++ b/crates/compiler/build/src/link.rs @@ -482,15 +482,29 @@ pub fn rebuild_host( host_input_path.with_file_name("host.bc") } } else { - host_input_path.with_file_name(if shared_lib_path.is_some() { - "dynhost" + let os = roc_target::OperatingSystem::from(target.operating_system); + + if shared_lib_path.is_some() { + let extension = match os { + roc_target::OperatingSystem::Windows => "exe", + roc_target::OperatingSystem::Unix => "", + roc_target::OperatingSystem::Wasi => "", + }; + + host_input_path + .with_file_name("dynhost") + .with_extension(extension) } else { - match roc_target::OperatingSystem::from(target.operating_system) { - roc_target::OperatingSystem::Windows => "host.obj", - roc_target::OperatingSystem::Unix => "host.o", - roc_target::OperatingSystem::Wasi => "host.o", - } - }) + let extension = match os { + roc_target::OperatingSystem::Windows => "obj", + roc_target::OperatingSystem::Unix => "o", + roc_target::OperatingSystem::Wasi => "o", + }; + + host_input_path + .with_file_name("host") + .with_extension(extension) + } }; let env_path = env::var("PATH").unwrap_or_else(|_| "".to_string());