Also add language options when resolving components
This commit is contained in:
parent
6f59f07f00
commit
ca79f99c3e
@ -76,13 +76,18 @@ cabalHelperCache = Cached {
|
||||
cacheFile = cabalHelperCacheFile,
|
||||
cachedAction = \ _ (progs, root, _) ->
|
||||
runQuery' progs root $ do
|
||||
q <- liftM4 join4 ghcOptions ghcSrcOptions entrypoints sourceDirs
|
||||
let cs = flip map q $ \(cn, (opts, (srcOpts, (ep, srcDirs)))) ->
|
||||
GmComponent cn opts srcOpts ep ep srcDirs mempty
|
||||
q <- liftM5 join5
|
||||
ghcOptions
|
||||
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)
|
||||
}
|
||||
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' lb lc = [ (a, (b, c))
|
||||
| (a, b) <- lb
|
||||
|
@ -180,6 +180,9 @@ setupConfigFile crdl = cradleRootDir crdl </> setupConfigPath
|
||||
setupConfigPath :: FilePath
|
||||
setupConfigPath = "dist/setup-config" -- localBuildInfoFile defaultDistPref
|
||||
|
||||
macrosHeaderPath :: FilePath
|
||||
macrosHeaderPath = "dist/build/autogen/cabal_macros.h"
|
||||
|
||||
ghcSandboxPkgDbDir :: String
|
||||
ghcSandboxPkgDbDir =
|
||||
cabalBuildPlatform ++ "-ghc-" ++ cProjectVersion ++ "-packages.conf.d"
|
||||
|
@ -260,18 +260,26 @@ resolveGmComponent :: (IOish m, GmLog m, GmEnv m)
|
||||
-> GmComponent GMCRaw (Set ModulePath)
|
||||
-> m (GmComponent GMCResolved (Set ModulePath))
|
||||
resolveGmComponent mums c@GmComponent {..} = do
|
||||
withLightHscEnv gmcGhcSrcOpts $ \env -> do
|
||||
withLightHscEnv ghcOpts $ \env -> do
|
||||
let srcDirs = if null gmcSourceDirs then [""] else gmcSourceDirs
|
||||
let mg = gmcHomeModuleGraph
|
||||
let simp = gmcEntrypoints
|
||||
sump <- case mums of
|
||||
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
|
||||
|
||||
return $ c { gmcEntrypoints = simp, gmcHomeModuleGraph = mg' }
|
||||
|
||||
where ghcOpts = concat [
|
||||
gmcGhcSrcOpts,
|
||||
gmcGhcLangOpts,
|
||||
[ "-optP-include", "-optP" ++ macrosHeaderPath ]
|
||||
]
|
||||
|
||||
resolveEntrypoint :: IOish m
|
||||
=> Cradle
|
||||
-> GmComponent GMCRaw ChEntrypoint
|
||||
|
@ -164,7 +164,6 @@ type ModuleString = String
|
||||
-- | A Module
|
||||
type Module = [String]
|
||||
|
||||
|
||||
data GmLogLevel = GmPanic
|
||||
| GmException
|
||||
| GmError
|
||||
@ -215,6 +214,7 @@ data GmComponent (t :: GmComponentType) eps = GmComponent {
|
||||
gmcName :: ChComponentName,
|
||||
gmcGhcOpts :: [GHCOption],
|
||||
gmcGhcSrcOpts :: [GHCOption],
|
||||
gmcGhcLangOpts :: [GHCOption],
|
||||
gmcRawEntrypoints :: ChEntrypoint,
|
||||
gmcEntrypoints :: eps,
|
||||
gmcSourceDirs :: [FilePath],
|
||||
|
@ -121,7 +121,7 @@ Library
|
||||
, bytestring
|
||||
, cereal >= 0.4
|
||||
, containers
|
||||
, cabal-helper >= 0.3.1.0
|
||||
, cabal-helper >= 0.3.2.0
|
||||
, deepseq
|
||||
, directory
|
||||
, filepath
|
||||
|
Loading…
Reference in New Issue
Block a user