diff options
-rw-r--r-- | src/Build.hs | 27 | ||||
-rw-r--r-- | src/Lib.hs | 19 | ||||
-rw-r--r-- | test/Spec.hs | 6 | ||||
-rw-r--r-- | test/test1.f90 | 8 |
4 files changed, 47 insertions, 13 deletions
diff --git a/src/Build.hs b/src/Build.hs index 813c10e..2febb87 100644 --- a/src/Build.hs +++ b/src/Build.hs @@ -88,10 +88,11 @@ buildPrograms programDirectory libraryDirectories sourceExtensions buildDirector } $ do buildDirectory </> "*" <.> "o" %> \objectFile -> do - let - sourceFile = fromMaybe + let realObjectFile = + foldl (</>) "" $ splitDirectories objectFile + let sourceFile = fromMaybe undefined - (Map.lookup objectFile sourceFileLookupMap) + (Map.lookup realObjectFile sourceFileLookupMap) need [sourceFile] modulesUsed <- liftIO $ getModulesUsed sourceFile let @@ -104,11 +105,14 @@ buildPrograms programDirectory libraryDirectories sourceExtensions buildDirector includeFlags flags ["-o", objectFile, sourceFile] - (`elem` executables) ?> \exe -> do - let objectFile = map toLower exe -<.> "o" - need [objectFile] - need archives - cmd compiler objectFile archives ["-o", exe] flags + (\file -> + foldl (</>) "" (splitDirectories file) `elem` executables + ) + ?> \exe -> do + let objectFile = map toLower exe -<.> "o" + need [objectFile] + need archives + cmd compiler objectFile archives ["-o", exe] flags want executables buildLibrary @@ -140,9 +144,12 @@ buildLibrary libraryDirectory sourceExtensions buildDirectory compiler flags lib map (\ext -> buildDirectory </> "*" <.> ext) ["o", "mod"] &%> \[objectFile, moduleFile] -> do let - sourceFile = fromMaybe + realObjectFile = foldl (</>) "" + $ splitDirectories objectFile + let sourceFile = fromMaybe undefined - (Map.lookup objectFile sourceFileLookupMap + (Map.lookup realObjectFile + sourceFileLookupMap ) need [sourceFile] modulesUsed <- liftIO $ getModulesUsed sourceFile @@ -1,6 +1,21 @@ module Lib - ( someFunc + ( someFunc, + someFunc2 ) where +import Development.Shake.FilePath ((</>)) +import System.Process (callCommand) + + someFunc :: IO () -someFunc = putStrLn "someFunc" +someFunc = do + putStrLn "someFunc" + a <- callCommand "gfortran test/test1.f90 -o test1" + a <- callCommand $ "." </> "test1" + return () + +someFunc2 :: IO () +someFunc2 = do + putStrLn "example" + a <- callCommand "cd example_project && stack run -- build" + return () diff --git a/test/Spec.hs b/test/Spec.hs index cd4753f..1c9fc48 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -1,2 +1,6 @@ +import Lib (someFunc, someFunc2) + main :: IO () -main = putStrLn "Test suite not yet implemented" +main = do + someFunc + someFunc2 diff --git a/test/test1.f90 b/test/test1.f90 new file mode 100644 index 0000000..f577b58 --- /dev/null +++ b/test/test1.f90 @@ -0,0 +1,8 @@ +program test1 +implicit none +integer :: i +i = 5+5 +print *, i +print *, "Fortran test code executed" +print *, "TESTS PASSED" +end program |