{-# LANGUAGE NoImplicitPrelude   #-}
{-# LANGUAGE NoFieldSelectors    #-}

{-|
Module      : Stack.Types.ConfigureOpts
License     : BSD-3-Clause
-}

module Stack.Types.ConfigureOpts
  ( ConfigureOpts (..)
  , BaseConfigOpts (..)
  , PackageConfigureOpts (..)
  ) where

import           Stack.Prelude
import           Stack.Types.BuildOpts ( BuildOpts (..) )
import           Stack.Types.BuildOptsCLI ( BuildOptsCLI )

-- | Basic information used to calculate what the configure options are

data BaseConfigOpts = BaseConfigOpts
  { BaseConfigOpts -> Path Abs Dir
snapDB :: !(Path Abs Dir)
  , BaseConfigOpts -> Path Abs Dir
localDB :: !(Path Abs Dir)
  , BaseConfigOpts -> Path Abs Dir
snapInstallRoot :: !(Path Abs Dir)
  , BaseConfigOpts -> Path Abs Dir
localInstallRoot :: !(Path Abs Dir)
  , BaseConfigOpts -> BuildOpts
buildOpts :: !BuildOpts
  , BaseConfigOpts -> BuildOptsCLI
buildOptsCLI :: !BuildOptsCLI
  , BaseConfigOpts -> [Path Abs Dir]
extraDBs :: ![Path Abs Dir]
  }
  deriving Int -> BaseConfigOpts -> ShowS
[BaseConfigOpts] -> ShowS
BaseConfigOpts -> String
(Int -> BaseConfigOpts -> ShowS)
-> (BaseConfigOpts -> String)
-> ([BaseConfigOpts] -> ShowS)
-> Show BaseConfigOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BaseConfigOpts -> ShowS
showsPrec :: Int -> BaseConfigOpts -> ShowS
$cshow :: BaseConfigOpts -> String
show :: BaseConfigOpts -> String
$cshowList :: [BaseConfigOpts] -> ShowS
showList :: [BaseConfigOpts] -> ShowS
Show

-- | All these fields come from the v'Package' data type but bringing the

-- whole t'Package' is way too much, hence this datatype.

data PackageConfigureOpts = PackageConfigureOpts
  { PackageConfigureOpts -> [Text]
pkgCabalConfigOpts :: [Text]
  , PackageConfigureOpts -> [Text]
pkgGhcOptions :: [Text]
  , PackageConfigureOpts -> Map FlagName Bool
pkgFlags :: Map FlagName Bool
  , PackageConfigureOpts -> Map FlagName Bool
pkgDefaultFlags :: Map FlagName Bool
  , PackageConfigureOpts -> PackageIdentifier
pkgIdentifier :: PackageIdentifier
  }
  deriving Int -> PackageConfigureOpts -> ShowS
[PackageConfigureOpts] -> ShowS
PackageConfigureOpts -> String
(Int -> PackageConfigureOpts -> ShowS)
-> (PackageConfigureOpts -> String)
-> ([PackageConfigureOpts] -> ShowS)
-> Show PackageConfigureOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PackageConfigureOpts -> ShowS
showsPrec :: Int -> PackageConfigureOpts -> ShowS
$cshow :: PackageConfigureOpts -> String
show :: PackageConfigureOpts -> String
$cshowList :: [PackageConfigureOpts] -> ShowS
showList :: [PackageConfigureOpts] -> ShowS
Show

-- | Configure options to be sent to Setup.hs configure.

data ConfigureOpts = ConfigureOpts
  { ConfigureOpts -> [String]
pathRelated :: ![String]
    -- ^ Options related to various paths. We separate these out since they do

    -- not have an effect on the contents of the compiled binary for checking

    -- if we can use an existing precompiled cache.

  , ConfigureOpts -> [String]
nonPathRelated :: ![String]
    -- ^ Options other than path-related options.

  }
  deriving (Typeable ConfigureOpts
Typeable ConfigureOpts =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> ConfigureOpts -> c ConfigureOpts)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ConfigureOpts)
-> (ConfigureOpts -> Constr)
-> (ConfigureOpts -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ConfigureOpts))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c ConfigureOpts))
-> ((forall b. Data b => b -> b) -> ConfigureOpts -> ConfigureOpts)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ConfigureOpts -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ConfigureOpts -> r)
-> (forall u. (forall d. Data d => d -> u) -> ConfigureOpts -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> ConfigureOpts -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ConfigureOpts -> m ConfigureOpts)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ConfigureOpts -> m ConfigureOpts)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ConfigureOpts -> m ConfigureOpts)
-> Data ConfigureOpts
ConfigureOpts -> Constr
ConfigureOpts -> DataType
(forall b. Data b => b -> b) -> ConfigureOpts -> ConfigureOpts
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> ConfigureOpts -> u
forall u. (forall d. Data d => d -> u) -> ConfigureOpts -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ConfigureOpts -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ConfigureOpts -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ConfigureOpts -> m ConfigureOpts
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ConfigureOpts -> m ConfigureOpts
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ConfigureOpts
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConfigureOpts -> c ConfigureOpts
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ConfigureOpts)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ConfigureOpts)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConfigureOpts -> c ConfigureOpts
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConfigureOpts -> c ConfigureOpts
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ConfigureOpts
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ConfigureOpts
$ctoConstr :: ConfigureOpts -> Constr
toConstr :: ConfigureOpts -> Constr
$cdataTypeOf :: ConfigureOpts -> DataType
dataTypeOf :: ConfigureOpts -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ConfigureOpts)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ConfigureOpts)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ConfigureOpts)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ConfigureOpts)
$cgmapT :: (forall b. Data b => b -> b) -> ConfigureOpts -> ConfigureOpts
gmapT :: (forall b. Data b => b -> b) -> ConfigureOpts -> ConfigureOpts
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ConfigureOpts -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ConfigureOpts -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ConfigureOpts -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ConfigureOpts -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ConfigureOpts -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> ConfigureOpts -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ConfigureOpts -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ConfigureOpts -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ConfigureOpts -> m ConfigureOpts
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ConfigureOpts -> m ConfigureOpts
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ConfigureOpts -> m ConfigureOpts
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ConfigureOpts -> m ConfigureOpts
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ConfigureOpts -> m ConfigureOpts
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ConfigureOpts -> m ConfigureOpts
Data, ConfigureOpts -> ConfigureOpts -> Bool
(ConfigureOpts -> ConfigureOpts -> Bool)
-> (ConfigureOpts -> ConfigureOpts -> Bool) -> Eq ConfigureOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConfigureOpts -> ConfigureOpts -> Bool
== :: ConfigureOpts -> ConfigureOpts -> Bool
$c/= :: ConfigureOpts -> ConfigureOpts -> Bool
/= :: ConfigureOpts -> ConfigureOpts -> Bool
Eq, (forall x. ConfigureOpts -> Rep ConfigureOpts x)
-> (forall x. Rep ConfigureOpts x -> ConfigureOpts)
-> Generic ConfigureOpts
forall x. Rep ConfigureOpts x -> ConfigureOpts
forall x. ConfigureOpts -> Rep ConfigureOpts x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ConfigureOpts -> Rep ConfigureOpts x
from :: forall x. ConfigureOpts -> Rep ConfigureOpts x
$cto :: forall x. Rep ConfigureOpts x -> ConfigureOpts
to :: forall x. Rep ConfigureOpts x -> ConfigureOpts
Generic, Int -> ConfigureOpts -> ShowS
[ConfigureOpts] -> ShowS
ConfigureOpts -> String
(Int -> ConfigureOpts -> ShowS)
-> (ConfigureOpts -> String)
-> ([ConfigureOpts] -> ShowS)
-> Show ConfigureOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConfigureOpts -> ShowS
showsPrec :: Int -> ConfigureOpts -> ShowS
$cshow :: ConfigureOpts -> String
show :: ConfigureOpts -> String
$cshowList :: [ConfigureOpts] -> ShowS
showList :: [ConfigureOpts] -> ShowS
Show)

instance NFData ConfigureOpts