replace stray strings with impl on Target

This commit is contained in:
Luke Boswell 2024-07-09 14:39:36 +10:00
parent 753cfb4285
commit 85447ec2cc
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
7 changed files with 58 additions and 54 deletions

View file

@ -1706,8 +1706,6 @@ fn surgery_elf_help(
#[cfg(test)]
mod tests {
use super::*;
use crate::preprocessed_host_filename;
use indoc::indoc;
use roc_target::Target;
@ -1848,7 +1846,7 @@ mod tests {
panic!("zig build-exe failed");
}
let preprocessed_host_filename = dir.join(preprocessed_host_filename(target));
let preprocessed_host_filename = dir.join(target.prebuilt_surgical_host());
preprocess_elf_le(
&dir.join("host"),

View file

@ -45,16 +45,6 @@ pub fn supported(link_type: LinkType, target: Target) -> bool {
}
}
pub const PRECOMPILED_HOST_EXT: &str = "rh"; // Short for "roc host"
pub fn preprocessed_host_filename(target: Target) -> String {
format!("{target}.{PRECOMPILED_HOST_EXT}")
}
pub fn metadata_file_name(target: Target) -> String {
format!("metadata_{}.rm", target)
}
pub fn link_preprocessed_host(
target: Target,
roc_app_bytes: &[u8],
@ -118,14 +108,9 @@ pub fn generate_stub_lib(
};
if let EntryPoint::Executable { platform_path, .. } = &loaded.entry_point {
let stub_lib = if target.operating_system() == OperatingSystem::Windows {
platform_path.with_file_name("libapp.obj")
} else {
platform_path.with_file_name("libapp.so")
};
let stub_lib = platform_path.with_file_name(target.stub_app_lib_file_name());
let stub_dll_symbols = exposed_symbols.stub_dll_symbols();
generate_dynamic_lib(target, &stub_dll_symbols, &stub_lib);
generate_dynamic_lib(target, &stub_dll_symbols, stub_lib.as_path());
(platform_path.into(), stub_lib, stub_dll_symbols)
} else {
unreachable!();
@ -137,15 +122,10 @@ pub fn generate_stub_lib_from_loaded(
platform_main_roc: &Path,
stub_dll_symbols: &[String],
) -> PathBuf {
let stub_lib_path = if target.operating_system() == OperatingSystem::Windows {
platform_main_roc.with_file_name("libapp.dll")
} else {
platform_main_roc.with_file_name("libapp.so")
};
let stub_lib = platform_main_roc.with_file_name(target.stub_app_lib_file_name());
generate_dynamic_lib(target, stub_dll_symbols, stub_lib.as_path());
generate_dynamic_lib(target, stub_dll_symbols, &stub_lib_path);
stub_lib_path
stub_lib
}
pub struct ExposedSymbols {

View file

@ -1435,11 +1435,9 @@ const ___CHKSTK_MS: [u8; 48] = [
mod test {
const PE_DYNHOST: &[u8] = include_bytes!("../dynhost_benchmarks_windows.exe") as &[_];
use indoc::indoc;
use object::read::pe::PeFile64;
use object::{pe, LittleEndian as LE, Object};
use crate::preprocessed_host_filename;
use indoc::indoc;
use serial_test::serial;
use target_lexicon::Triple;
@ -1792,8 +1790,8 @@ mod test {
panic!("zig build-exe failed: {command_str}");
}
let preprocessed_host_filename =
dir.join(preprocessed_host_filename(Triple::host().into()));
let target: roc_target::Target = Triple::host().into();
let preprocessed_host_filename = dir.join(target.prebuilt_surgical_host());
preprocess_windows(
&dir.join("host.exe"),