diff options
author | Brad Richardson <everythingfunctional@protonmail.com> | 2020-03-08 20:32:27 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-08 20:32:27 -0700 |
commit | 6fe22cfa6d7813ec5c6fca390a992b56ac646778 (patch) | |
tree | e2f8c5a626e49d45fe7f3a71452a995a7eaa49ab | |
parent | 8e6fd427508e10999349c7e08c53a3d34bcea143 (diff) | |
parent | 3c5c649902c2d9e5e1c07e0335d6caf28bf3694c (diff) | |
download | fpm-6fe22cfa6d7813ec5c6fca390a992b56ac646778.tar.gz fpm-6fe22cfa6d7813ec5c6fca390a992b56ac646778.zip |
Merge pull request #43 from everythingfunctional/bpr_AdditionalLibraries
Add place to specify other libraries when building library
-rw-r--r-- | app/Main.hs | 1 | ||||
-rw-r--r-- | src/Build.hs | 12 |
2 files changed, 11 insertions, 2 deletions
diff --git a/app/Main.hs b/app/Main.hs index 02d54d6..88bb302 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -44,6 +44,7 @@ build = do "gfortran" ["-g", "-Wall", "-Wextra", "-Werror", "-pedantic"] "library" + [] buildPrograms "app" ["build" </> "library"] [".f90", ".f", ".F", ".F90", ".f95", ".f03"] diff --git a/src/Build.hs b/src/Build.hs index 2febb87..0353ca5 100644 --- a/src/Build.hs +++ b/src/Build.hs @@ -122,8 +122,9 @@ buildLibrary -> FilePath -> [String] -> String + -> [FilePath] -> IO () -buildLibrary libraryDirectory sourceExtensions buildDirectory compiler flags libraryName +buildLibrary libraryDirectory sourceExtensions buildDirectory compiler flags libraryName otherLibraryDirectories = do sourceFiles <- getDirectoriesFiles [libraryDirectory] sourceExtensions let sourceFileLookupMap = createSourceFileLookupMap @@ -133,6 +134,10 @@ buildLibrary libraryDirectory sourceExtensions buildDirectory compiler flags lib let moduleLookupMap = createModuleLookupMap buildDirectory libraryDirectory sourceFiles + otherModuleMaps <- mapM getLibraryModuleMap otherLibraryDirectories + let allModuleMaps = + moduleLookupMap + `Map.union` foldl Map.union Map.empty otherModuleMaps let archiveFile = buildDirectory </> libraryName <.> "a" shake shakeOptions { shakeFiles = buildDirectory , shakeChange = ChangeModtimeAndDigest @@ -155,11 +160,14 @@ buildLibrary libraryDirectory sourceExtensions buildDirectory compiler flags lib modulesUsed <- liftIO $ getModulesUsed sourceFile let moduleFilesNeeded = mapMaybe - (`Map.lookup` moduleLookupMap) + (`Map.lookup` allModuleMaps) modulesUsed + let includeFlags = + map ("-I" ++) otherLibraryDirectories need moduleFilesNeeded cmd compiler ["-c", "-J" ++ buildDirectory] + includeFlags flags ["-o", objectFile, sourceFile] archiveFile %> \a -> do |