diff options
author | Alan Zimmerman <alan.zimm@gmail.com> | 2018-02-08 12:12:24 +0200 |
---|---|---|
committer | Daniel Gröber <dxld@darkboxed.org> | 2018-02-08 11:12:24 +0100 |
commit | 32c9bf6c48aedaff55c247bc56829bb372457e69 (patch) | |
tree | d1b47bfa3c25d5f4354e0713866311cb4abaf4d5 /src/CabalHelper/Runtime | |
parent | 09e2236679739547984e2e29db23e160a3a80890 (diff) |
Fix combineEP, to preserve top level exe targets (#45)
Diffstat (limited to 'src/CabalHelper/Runtime')
-rw-r--r-- | src/CabalHelper/Runtime/Main.hs | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/CabalHelper/Runtime/Main.hs b/src/CabalHelper/Runtime/Main.hs index 336650a..48d134a 100644 --- a/src/CabalHelper/Runtime/Main.hs +++ b/src/CabalHelper/Runtime/Main.hs @@ -634,7 +634,7 @@ recursiveIncludeDirs includeDirs unit = go ([],[],Nothing) [unit] go (afp,aci,Just amep) [] = (afp,aci,amep) go acc@(afp,aci,amep) (u:us) = case Map.lookup u includeDirs of Nothing -> go acc us - Just (SubDeps us' sfp sci sep) -> go (afp++sfp,aci++sci,combineEp amep sep) (us++us') + Just (SubDeps us' sfp sci sep) -> go (afp++sfp,aci++sci,Just (combineEp amep sep)) (us++us') needsBuildOutput :: Map.Map UnitId SubDeps -> UnitId -> NeedsBuildOutput needsBuildOutput includeDirs unit = go [unit] @@ -649,12 +649,20 @@ needsBuildOutput includeDirs unit = go [unit] then ProduceBuildOutput else go (us++us') -combineEp Nothing e = Just e -combineEp (Just ChSetupEntrypoint) e = Just e -combineEp (Just (ChLibEntrypoint es1 os1 ss1)) (ChLibEntrypoint es2 os2 ss2) = Just (ChLibEntrypoint (nub $ es2++es1) (nub $ os2++os1) (nub $ ss2++ss1)) -combineEp (Just (ChLibEntrypoint es1 os1 ss1)) (ChExeEntrypoint mi os2) = Just (ChExeEntrypoint mi (nub $ os2++es1++os1++ss1)) -combineEp (Just (ChExeEntrypoint _ os1)) (ChLibEntrypoint es2 os2 ss2) = Just (ChLibEntrypoint es2 (nub $ os2++os1) ss2) -combineEp (Just (ChExeEntrypoint _ os1)) (ChExeEntrypoint mi os2) = Just (ChExeEntrypoint mi (nub $ os2++os1)) +-- | combineEP is used to combine the entrypoints when recursively chasing +-- through the dependencies of a given entry point. The first parameter is the +-- current accumulated value, and the second one is the current sub-dependency +-- being considered. So the bias should be to preserve the type of entrypoint +-- from the first parameter. +combineEp Nothing e = e +combineEp (Just ChSetupEntrypoint) e = e +combineEp (Just (ChLibEntrypoint es1 os1 ss1)) (ChLibEntrypoint es2 os2 ss2) = (ChLibEntrypoint (nub $ es2++es1) (nub $ os2++os1) (nub $ ss2++ss1)) +combineEp _ e@(ChExeEntrypoint mi os2) = error $ "combineEP: cannot have a sub exe:" ++ show e +combineEp (Just (ChExeEntrypoint mi os1)) (ChLibEntrypoint es2 os2 ss2) = (ChExeEntrypoint mi (nub $ os1++es2++os2++ss2)) + +-- no, you unconditionally always wrap the result in Just, so instead of `f x = Just y; f x = Just z` do `f x = y; f x = z` and use f as `Just . f` + + instantiatedGhcPackage :: (ModuleName,OpenModule) -> [(OpenUnitId, ModuleRenaming)] instantiatedGhcPackage (_,OpenModule oui@(DefiniteUnitId _) _) = [(oui,DefaultRenaming)] |