From 93d4aea1b1813c5a01778196f8bde7c1d47545ba Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sat, 30 Mar 2024 23:01:38 -0400 Subject: [PATCH] Compiler tests properly add extension to obj files --- compiler/common_test.go | 7 +++++-- compiler/compile-unit.go | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/common_test.go b/compiler/common_test.go index 98cbbf0..52fbe67 100644 --- a/compiler/common_test.go +++ b/compiler/common_test.go @@ -11,6 +11,7 @@ import "path/filepath" import "git.tebibyte.media/fspl/fspl/entity" import "git.tebibyte.media/fspl/fspl/errors" import "git.tebibyte.media/fspl/fspl/testcommon" +import "git.tebibyte.media/fspl/fspl/generator/native" //go:embed all:test-data/* var testData embed.FS @@ -27,6 +28,8 @@ func defaultCompiler () *Compiler { comp.Resolver.FS = testData comp.Filetype = FiletypeObject comp.Debug = true + nativeTarget := native.NativeTarget() + comp.Target = &nativeTarget return comp } @@ -50,7 +53,7 @@ func compileDependency ( if !ok { test.Fatal("could not generate nickname for", address) } - comp.Output = filepath.Join(temp, nickname) + comp.Output = filepath.Join(temp, FiletypeObject.Extend(*comp.Target, nickname)) // compile to object file err := comp.CompileUnit(address) @@ -79,7 +82,7 @@ func testUnit ( test.Log("COMPILER LOG (main unit):\n" + compOutputBuilder.String()) } comp.Writer = compOutputBuilder - comp.Output = filepath.Join(temp, "output.o") + comp.Output = filepath.Join(temp, FiletypeObject.Extend(*comp.Target, "output")) // compile to object file err := comp.CompileUnit(address) diff --git a/compiler/compile-unit.go b/compiler/compile-unit.go index 14304d5..9088199 100644 --- a/compiler/compile-unit.go +++ b/compiler/compile-unit.go @@ -34,6 +34,7 @@ func (this *Compiler) CompileUnit (address entity.Address) error { // if the format isn't specified, try to get it from the filename // extension of the input. if that isn't specified, default to .o if this.Filetype == FiletypeUnknown { + this.Debugln("filetype was not specified") if this.Output == "" { this.Filetype = FiletypeObject } else {