aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrad Richardson <brichardson@structint.com>2020-03-06 19:45:44 -0800
committerBrad Richardson <brichardson@structint.com>2020-03-06 19:45:44 -0800
commit3c5c649902c2d9e5e1c07e0335d6caf28bf3694c (patch)
treedc69ed509bfc6b09de786effe965529b435af54f /src
parent45cc57a901594eaa94535659e2aafe9971a24c00 (diff)
downloadfpm-3c5c649902c2d9e5e1c07e0335d6caf28bf3694c.tar.gz
fpm-3c5c649902c2d9e5e1c07e0335d6caf28bf3694c.zip
Add place to specify other libraries when building library
Diffstat (limited to 'src')
-rw-r--r--src/Build.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Build.hs b/src/Build.hs
index 813c10e..b9f2011 100644
--- a/src/Build.hs
+++ b/src/Build.hs
@@ -118,8 +118,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
@@ -129,6 +130,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
@@ -148,11 +153,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