make ROC_DEV_WRITE_OBJ work in more cases

This commit is contained in:
Folkert 2024-01-27 17:46:19 +01:00
parent 076fafe02f
commit 919a51137a
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
2 changed files with 22 additions and 6 deletions

View file

@ -29,6 +29,28 @@ pub fn build_module<'a, 'r>(
layout_interner: &'r mut STLayoutInterner<'a>,
target: &Triple,
procedures: MutMap<(symbol::Symbol, ProcLayout<'a>), Proc<'a>>,
) -> Object<'a> {
let module_object = build_module_help(env, interns, layout_interner, target, procedures);
if std::env::var("ROC_DEV_WRITE_OBJ").is_ok() {
let module_out = module_object
.write()
.expect("failed to build output object");
let file_path = std::env::temp_dir().join("app.o");
println!("gen-test object file written to {}", file_path.display());
std::fs::write(&file_path, module_out).expect("failed to write object to file");
}
module_object
}
fn build_module_help<'a, 'r>(
env: &'r Env<'a>,
interns: &'r mut Interns,
layout_interner: &'r mut STLayoutInterner<'a>,
target: &Triple,
procedures: MutMap<(symbol::Symbol, ProcLayout<'a>), Proc<'a>>,
) -> Object<'a> {
match target {
Triple {