-
Notifications
You must be signed in to change notification settings - Fork 843
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re #2407 Move ExtraDirs out of Stack.Types.Config
- Loading branch information
Showing
11 changed files
with
106 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
|
||
module Stack.Types.ExtraDirs | ||
( ExtraDirs (..) | ||
) where | ||
|
||
import Generics.Deriving.Monoid ( mappenddefault, memptydefault ) | ||
import Stack.Prelude | ||
|
||
data ExtraDirs = ExtraDirs | ||
{ edBins :: ![Path Abs Dir] | ||
, edInclude :: ![Path Abs Dir] | ||
, edLib :: ![Path Abs Dir] | ||
} | ||
deriving (Show, Generic) | ||
|
||
instance Semigroup ExtraDirs where | ||
(<>) = mappenddefault | ||
|
||
instance Monoid ExtraDirs where | ||
mempty = memptydefault | ||
mappend = (<>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Stack.Types.ProjectAndConfigMonoid | ||
( ProjectAndConfigMonoid (..) | ||
, parseProjectAndConfigMonoid | ||
) where | ||
|
||
import qualified Data.Set as Set | ||
import qualified Data.Yaml as Yaml | ||
import Pantry.Internal.AesonExtended | ||
( WithJSONWarnings, Value, (...:), (..:?), (..!=) | ||
, jsonSubWarnings, jsonSubWarningsT, jsonSubWarningsTT | ||
, withObjectWarnings ) | ||
import Stack.Prelude | ||
import Stack.Types.ConfigMonoid | ||
( ConfigMonoid, parseConfigMonoidObject ) | ||
import Stack.Types.Project ( Project (..) ) | ||
|
||
data ProjectAndConfigMonoid | ||
= ProjectAndConfigMonoid !Project !ConfigMonoid | ||
|
||
parseProjectAndConfigMonoid :: | ||
Path Abs Dir | ||
-> Value | ||
-> Yaml.Parser (WithJSONWarnings (IO ProjectAndConfigMonoid)) | ||
parseProjectAndConfigMonoid rootDir = | ||
withObjectWarnings "ProjectAndConfigMonoid" $ \o -> do | ||
packages <- o ..:? "packages" ..!= [RelFilePath "."] | ||
deps <- jsonSubWarningsTT (o ..:? "extra-deps") ..!= [] | ||
flags' <- o ..:? "flags" ..!= mempty | ||
let flags = unCabalStringMap <$> unCabalStringMap | ||
(flags' :: Map (CabalString PackageName) (Map (CabalString FlagName) Bool)) | ||
|
||
resolver <- jsonSubWarnings $ o ...: ["snapshot", "resolver"] | ||
mcompiler <- o ..:? "compiler" | ||
msg <- o ..:? "user-message" | ||
config <- parseConfigMonoidObject rootDir o | ||
extraPackageDBs <- o ..:? "extra-package-dbs" ..!= [] | ||
mcurator <- jsonSubWarningsT (o ..:? "curator") | ||
drops <- o ..:? "drop-packages" ..!= mempty | ||
pure $ do | ||
deps' <- mapM (resolvePaths (Just rootDir)) deps | ||
resolver' <- resolvePaths (Just rootDir) resolver | ||
let project = Project | ||
{ projectUserMsg = msg | ||
, projectResolver = resolver' | ||
, projectCompiler = mcompiler -- FIXME make sure resolver' isn't SLCompiler | ||
, projectExtraPackageDBs = extraPackageDBs | ||
, projectPackages = packages | ||
, projectDependencies = | ||
concatMap toList (deps' :: [NonEmpty RawPackageLocation]) | ||
, projectFlags = flags | ||
, projectCurator = mcurator | ||
, projectDropPackages = Set.map unCabalString drops | ||
} | ||
pure $ ProjectAndConfigMonoid project config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters