diff options
-rw-r--r-- | bootstrap/src/BuildModel.hs | 8 | ||||
-rw-r--r-- | bootstrap/unit_test/ProgramToCompileInfoTest.hs | 15 |
2 files changed, 17 insertions, 6 deletions
diff --git a/bootstrap/src/BuildModel.hs b/bootstrap/src/BuildModel.hs index 86df719..f4c809f 100644 --- a/bootstrap/src/BuildModel.hs +++ b/bootstrap/src/BuildModel.hs @@ -62,6 +62,7 @@ data CompileTimeInfo = CompileTimeInfo { compileTimeInfoSourceFileName :: FilePath , compileTimeInfoObjectFileProduced :: FilePath , compileTimeInfoOtherFilesProduced :: [FilePath] + , compileTimeInfoDirectDependencies :: [FilePath] } processRawSource :: RawSource -> Source @@ -92,13 +93,16 @@ processRawSource rawSource = } else undefined -constructCompileTimeInfo :: Source -> [Source] -> FilePath -> CompileTimeInfo -constructCompileTimeInfo program@(Program{}) otherSources buildDirectory = +constructCompileTimeInfo :: Source -> [String] -> FilePath -> CompileTimeInfo +constructCompileTimeInfo program@(Program{}) availableModules buildDirectory = CompileTimeInfo { compileTimeInfoSourceFileName = programSourceFileName program , compileTimeInfoObjectFileProduced = (programObjectFileName program) buildDirectory , compileTimeInfoOtherFilesProduced = [] + , compileTimeInfoDirectDependencies = map + (\mName -> buildDirectory </> mName <.> "mod") + (filter (`elem` availableModules) (programModulesUsed program)) } constructCompileTimeInfo _ otherSources buildDirectory = undefined diff --git a/bootstrap/unit_test/ProgramToCompileInfoTest.hs b/bootstrap/unit_test/ProgramToCompileInfoTest.hs index e16ab22..20d7131 100644 --- a/bootstrap/unit_test/ProgramToCompileInfoTest.hs +++ b/bootstrap/unit_test/ProgramToCompileInfoTest.hs @@ -20,13 +20,15 @@ import System.FilePath ( (</>) ) test :: IO (Test ()) test = return $ givenInput "a program and other sources" - (exampleProgram, exampleSources) + (exampleProgram, availableModules) [ whenTransformed "its compileTimeInfo is determined" doCompileTimeTransformation [ then' "it still knows the original source file" checkSourceFileName , then' "it knows what object file will be produced" checkObjectFileName , then' "there are no other files produced" checkOtherFilesProduced + , then' "the direct dependencies are only the available modules used" + checkDirectDependencies ] ] @@ -40,10 +42,10 @@ exampleProgram = Program programSourceFileName' :: String programSourceFileName' = "some" </> "file" </> "somewhere.f90" -exampleSources :: [Source] -exampleSources = [] +availableModules :: [String] +availableModules = ["module1", "module3"] -doCompileTimeTransformation :: (Source, [Source]) -> CompileTimeInfo +doCompileTimeTransformation :: (Source, [String]) -> CompileTimeInfo doCompileTimeTransformation (programSource, otherSources) = constructCompileTimeInfo programSource otherSources "build_dir" @@ -59,3 +61,8 @@ checkObjectFileName cti = assertEquals checkOtherFilesProduced :: CompileTimeInfo -> Result checkOtherFilesProduced cti = assertEmpty (compileTimeInfoOtherFilesProduced cti) + +checkDirectDependencies :: CompileTimeInfo -> Result +checkDirectDependencies cti = assertEquals + ["build_dir" </> "module1.mod", "build_dir" </> "module3.mod"] + (compileTimeInfoDirectDependencies cti) |