Also add language options when resolving components

This commit is contained in:
Daniel Gröber 2015-04-12 02:36:17 +02:00
parent 6f59f07f00
commit ca79f99c3e
5 changed files with 24 additions and 8 deletions

View File

@ -76,13 +76,18 @@ cabalHelperCache = Cached {
cacheFile = cabalHelperCacheFile, cacheFile = cabalHelperCacheFile,
cachedAction = \ _ (progs, root, _) -> cachedAction = \ _ (progs, root, _) ->
runQuery' progs root $ do runQuery' progs root $ do
q <- liftM4 join4 ghcOptions ghcSrcOptions entrypoints sourceDirs q <- liftM5 join5
let cs = flip map q $ \(cn, (opts, (srcOpts, (ep, srcDirs)))) -> ghcOptions
GmComponent cn opts srcOpts ep ep srcDirs mempty ghcSrcOptions
ghcLangOptions
entrypoints
sourceDirs
let cs = flip map q $ \(cn, (opts, (srcOpts, (langOpts, (ep, srcDirs))))) ->
GmComponent cn opts srcOpts langOpts ep ep srcDirs mempty
return ([setupConfigPath], cs) return ([setupConfigPath], cs)
} }
where where
join4 a b c = join' a . join' b . join' c join5 a b c d = join' a . join' b . join' c . join' d
join' :: Eq a => [(a,b)] -> [(a,c)] -> [(a,(b,c))] join' :: Eq a => [(a,b)] -> [(a,c)] -> [(a,(b,c))]
join' lb lc = [ (a, (b, c)) join' lb lc = [ (a, (b, c))
| (a, b) <- lb | (a, b) <- lb

View File

@ -180,6 +180,9 @@ setupConfigFile crdl = cradleRootDir crdl </> setupConfigPath
setupConfigPath :: FilePath setupConfigPath :: FilePath
setupConfigPath = "dist/setup-config" -- localBuildInfoFile defaultDistPref setupConfigPath = "dist/setup-config" -- localBuildInfoFile defaultDistPref
macrosHeaderPath :: FilePath
macrosHeaderPath = "dist/build/autogen/cabal_macros.h"
ghcSandboxPkgDbDir :: String ghcSandboxPkgDbDir :: String
ghcSandboxPkgDbDir = ghcSandboxPkgDbDir =
cabalBuildPlatform ++ "-ghc-" ++ cProjectVersion ++ "-packages.conf.d" cabalBuildPlatform ++ "-ghc-" ++ cProjectVersion ++ "-packages.conf.d"

View File

@ -260,18 +260,26 @@ resolveGmComponent :: (IOish m, GmLog m, GmEnv m)
-> GmComponent GMCRaw (Set ModulePath) -> GmComponent GMCRaw (Set ModulePath)
-> m (GmComponent GMCResolved (Set ModulePath)) -> m (GmComponent GMCResolved (Set ModulePath))
resolveGmComponent mums c@GmComponent {..} = do resolveGmComponent mums c@GmComponent {..} = do
withLightHscEnv gmcGhcSrcOpts $ \env -> do withLightHscEnv ghcOpts $ \env -> do
let srcDirs = if null gmcSourceDirs then [""] else gmcSourceDirs let srcDirs = if null gmcSourceDirs then [""] else gmcSourceDirs
let mg = gmcHomeModuleGraph let mg = gmcHomeModuleGraph
let simp = gmcEntrypoints let simp = gmcEntrypoints
sump <- case mums of sump <- case mums of
Nothing -> return simp Nothing -> return simp
Just ums -> Set.fromList . catMaybes <$> mapM (resolveModule env srcDirs) ums Just ums ->
Set.fromList . catMaybes <$>
mapM (resolveModule env srcDirs) ums
mg' <- canonicalizeModuleGraph =<< updateHomeModuleGraph env mg simp sump mg' <- canonicalizeModuleGraph =<< updateHomeModuleGraph env mg simp sump
return $ c { gmcEntrypoints = simp, gmcHomeModuleGraph = mg' } return $ c { gmcEntrypoints = simp, gmcHomeModuleGraph = mg' }
where ghcOpts = concat [
gmcGhcSrcOpts,
gmcGhcLangOpts,
[ "-optP-include", "-optP" ++ macrosHeaderPath ]
]
resolveEntrypoint :: IOish m resolveEntrypoint :: IOish m
=> Cradle => Cradle
-> GmComponent GMCRaw ChEntrypoint -> GmComponent GMCRaw ChEntrypoint

View File

@ -164,7 +164,6 @@ type ModuleString = String
-- | A Module -- | A Module
type Module = [String] type Module = [String]
data GmLogLevel = GmPanic data GmLogLevel = GmPanic
| GmException | GmException
| GmError | GmError
@ -215,6 +214,7 @@ data GmComponent (t :: GmComponentType) eps = GmComponent {
gmcName :: ChComponentName, gmcName :: ChComponentName,
gmcGhcOpts :: [GHCOption], gmcGhcOpts :: [GHCOption],
gmcGhcSrcOpts :: [GHCOption], gmcGhcSrcOpts :: [GHCOption],
gmcGhcLangOpts :: [GHCOption],
gmcRawEntrypoints :: ChEntrypoint, gmcRawEntrypoints :: ChEntrypoint,
gmcEntrypoints :: eps, gmcEntrypoints :: eps,
gmcSourceDirs :: [FilePath], gmcSourceDirs :: [FilePath],

View File

@ -121,7 +121,7 @@ Library
, bytestring , bytestring
, cereal >= 0.4 , cereal >= 0.4
, containers , containers
, cabal-helper >= 0.3.1.0 , cabal-helper >= 0.3.2.0
, deepseq , deepseq
, directory , directory
, filepath , filepath