aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrad Richardson <brichardson@structint.com>2020-05-23 12:39:30 -0700
committerBrad Richardson <brichardson@structint.com>2020-05-23 12:39:30 -0700
commit382ce71efae399897c8a008c0042bb0511516fe6 (patch)
tree57aa4fbb0c5c17f8595b2c9c2d9e28b98a3d6e03 /src
parent524866688adf2a3a4756eab85cf5956127d21e6d (diff)
downloadfpm-382ce71efae399897c8a008c0042bb0511516fe6.tar.gz
fpm-382ce71efae399897c8a008c0042bb0511516fe6.zip
Avoid problems with circular dependencies
Diffstat (limited to 'src')
-rw-r--r--src/Fpm.hs42
1 files changed, 25 insertions, 17 deletions
diff --git a/src/Fpm.hs b/src/Fpm.hs
index a648382..2fdb707 100644
--- a/src/Fpm.hs
+++ b/src/Fpm.hs
@@ -44,7 +44,9 @@ import System.Directory ( doesDirectoryExist
, makeAbsolute
, withCurrentDirectory
)
-import System.Process ( runCommand, system )
+import System.Process ( runCommand
+ , system
+ )
import Toml ( TomlCodec
, (.=)
)
@@ -147,7 +149,7 @@ build settings = do
let executables = appSettingsExecutables settings
let tests = appSettingsTests settings
builtDependencies <-
- fetchDependencies (appSettingsDependencies settings)
+ fetchDependencies [projectName] (appSettingsDependencies settings)
>>= buildDependencies buildPrefix compiler flags
executableDepends <- case appSettingsLibrary settings of
Just librarySettings -> do
@@ -389,26 +391,32 @@ makeBuildPrefix compiler release =
return $ "build" </> compiler ++ "_" ++ if release then "release" else "debug"
-- This really needs to be a tree instead
-fetchDependencies :: Map.Map String Version -> IO [DependencyTree]
-fetchDependencies dependencies = do
- theseDependencies <- mapM (uncurry fetchDependency) (Map.toList dependencies)
+fetchDependencies :: [String] -> Map.Map String Version -> IO [DependencyTree]
+fetchDependencies knownPackages dependencies = do
+ theseDependencies <- mapM
+ (uncurry fetchDependency)
+ (filter (\(name, _) -> not (name `elem` knownPackages)) (Map.toList dependencies))
mapM fetchTransitiveDependencies theseDependencies
where
fetchTransitiveDependencies :: (String, FilePath) -> IO DependencyTree
fetchTransitiveDependencies (name, path) = do
- tomlSettings <- Toml.decodeFile settingsCodec (path </> "fpm.toml")
- librarySettingsM <- withCurrentDirectory path $ getLibrarySettings (tomlSettingsLibrary tomlSettings)
+ tomlSettings <- Toml.decodeFile settingsCodec (path </> "fpm.toml")
+ librarySettingsM <- withCurrentDirectory path
+ $ getLibrarySettings (tomlSettingsLibrary tomlSettings)
case librarySettingsM of
- Just librarySettings -> do
- newDependencies <- fetchDependencies (tomlSettingsDependencies tomlSettings)
- return $ Dependency { dependencyName = name
- , dependencyPath = path
- , dependencySourcePath = path </> (librarySourceDir librarySettings)
- , dependencyDependencies = newDependencies
- }
- Nothing -> do
- putStrLn $ "No library found in " ++ name
- undefined
+ Just librarySettings -> do
+ newDependencies <- fetchDependencies
+ (name : knownPackages)
+ (tomlSettingsDependencies tomlSettings)
+ return $ Dependency
+ { dependencyName = name
+ , dependencyPath = path
+ , dependencySourcePath = path </> (librarySourceDir librarySettings)
+ , dependencyDependencies = newDependencies
+ }
+ Nothing -> do
+ putStrLn $ "No library found in " ++ name
+ undefined
fetchDependency :: String -> Version -> IO (String, FilePath)
fetchDependency name version = do