From 29356ac6da1a94dbcc0c50c157e8dcb353213793 Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Wed, 14 Oct 2020 12:51:29 -0500 Subject: Add test for program object file name --- bootstrap/src/BuildModel.hs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'bootstrap/src/BuildModel.hs') diff --git a/bootstrap/src/BuildModel.hs b/bootstrap/src/BuildModel.hs index 711f977..b8bc122 100644 --- a/bootstrap/src/BuildModel.hs +++ b/bootstrap/src/BuildModel.hs @@ -1,11 +1,34 @@ module BuildModel where +import Data.List ( intercalate ) +import System.FilePath ( () + , (<.>) + , splitDirectories + ) + data RawSource = RawSource { rawSourceFilename :: FilePath , rawSourceContents :: String } -data Source = Program { programSourceFileName :: String} +data Source = Program { + programSourceFileName :: FilePath + , programObjectFileName :: FilePath -> FilePath +} processRawSource :: RawSource -> Source -processRawSource rawSource = Program $ rawSourceFilename rawSource +processRawSource rawSource = + let sourceFileName = rawSourceFilename rawSource + in Program + { programSourceFileName = sourceFileName + , programObjectFileName = \buildDirectory -> + buildDirectory + (pathSeparatorsToUnderscores + sourceFileName + ) + <.> "o" + } + +pathSeparatorsToUnderscores :: FilePath -> FilePath +pathSeparatorsToUnderscores fileName = + intercalate "_" (splitDirectories fileName) -- cgit v1.2.3