Skip to content

Commit

Permalink
Re #2407 Move EnvConfig out of Stack.Types.Config
Browse files Browse the repository at this point in the history
  • Loading branch information
mpilgrem committed Apr 18, 2023
1 parent 21e1a39 commit 714ad54
Show file tree
Hide file tree
Showing 41 changed files with 589 additions and 473 deletions.
4 changes: 4 additions & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ library:
- Stack.Types.CabalConfigKey
- Stack.Types.ColorWhen
- Stack.Types.CompilerBuild
- Stack.Types.CompilerPaths
- Stack.Types.Compiler
- Stack.Types.Config
- Stack.Types.Config.Build
Expand All @@ -275,6 +276,8 @@ library:
- Stack.Types.DockerEntrypoint
- Stack.Types.DownloadInfo
- Stack.Types.DumpLogs
- Stack.Types.DumpPackage
- Stack.Types.EnvConfig
- Stack.Types.GHCDownloadInfo
- Stack.Types.GHCVariant
- Stack.Types.GhcOptionKey
Expand All @@ -287,6 +290,7 @@ library:
- Stack.Types.Nix
- Stack.Types.Package
- Stack.Types.PackageName
- Stack.Types.PlatformVariant
- Stack.Types.PvpBounds
- Stack.Types.Resolver
- Stack.Types.Runner
Expand Down
21 changes: 12 additions & 9 deletions src/Stack/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,23 @@ import Stack.Types.Build
, TaskType (..), taskLocation
)
import Stack.Types.Compiler ( getGhcVersion )
import Stack.Types.CompilerPaths ( cabalVersionL )
import Stack.Types.Config
( BuildOpts (..), BuildOptsCLI (..), Config (..)
, EnvConfig (..), HasBuildConfig, HasConfig (..)
, HasEnvConfig (..), HasPlatform (..), HasSourceMap
, actualCompilerVersionL, buildOptsL
, buildOptsMonoidBenchmarksL, buildOptsMonoidHaddockL
, buildOptsMonoidInstallExesL, buildOptsMonoidTestsL
, cabalVersionL, globalOptsBuildOptsMonoidL
, installationRootDeps, installationRootLocal
, packageDatabaseDeps, packageDatabaseExtra
, packageDatabaseLocal, stackYamlL
, HasBuildConfig, HasConfig (..), HasPlatform (..)
, buildOptsL, buildOptsMonoidBenchmarksL
, buildOptsMonoidHaddockL, buildOptsMonoidInstallExesL
, buildOptsMonoidTestsL, globalOptsBuildOptsMonoidL
, stackYamlL
)
import Stack.Types.Config.Build
( BuildCommand (..), FileWatchOpts (..) )
import Stack.Types.EnvConfig
( EnvConfig (..), HasEnvConfig (..), HasSourceMap
, actualCompilerVersionL, installationRootDeps
, installationRootLocal, packageDatabaseDeps
, packageDatabaseExtra, packageDatabaseLocal
)
import Stack.Types.NamedComponent ( exeComponents )
import Stack.Types.Package
( InstallLocation (..), LocalPackage (..), Package (..)
Expand Down
10 changes: 6 additions & 4 deletions src/Stack/Build/Cache.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ import Stack.Types.Build
, Installed (..), PrecompiledCache (..)
)
import Stack.Types.Cache ( ConfigCacheType (..) )
import Stack.Types.Config
( HasEnvConfig (..), actualCompilerVersionL, cabalVersionL
, envConfigSourceMapHash, installationRootDeps
, installationRootLocal, platformGhcRelDir, stackRootL
import Stack.Types.CompilerPaths ( cabalVersionL )
import Stack.Types.Config ( stackRootL )
import Stack.Types.EnvConfig
( EnvConfig (..), HasEnvConfig (..), actualCompilerVersionL
, installationRootDeps, installationRootLocal
, platformGhcRelDir
)
import Stack.Types.GhcPkgId ( GhcPkgId, ghcPkgIdString )
import Stack.Types.NamedComponent ( NamedComponent (..) )
Expand Down
18 changes: 12 additions & 6 deletions src/Stack/Build/ConstructPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,20 @@ import Stack.Types.Build
, toCachePkgSrc
)
import Stack.Types.Compiler ( WhichCompiler (..) )
import Stack.Types.CompilerPaths
( CompilerPaths (..), HasCompiler (..) )
import Stack.Types.Config
( BuildConfig (..), BuildOpts (..), BuildOptsCLI (..)
, BuildSubset (..), CompilerPaths (..), Config (..)
, Curator (..), DumpPackage (..), EnvConfig, EnvSettings (..)
, HasBuildConfig (..), HasCompiler (..), HasConfig (..)
, HasEnvConfig (..), HasGHCVariant, HasPlatform
, HasSourceMap (..), minimalEnvSettings, stackRootL
, BuildSubset (..), Config (..), Curator (..)
, EnvSettings (..), HasBuildConfig (..), HasConfig (..)
, HasGHCVariant, HasPlatform, minimalEnvSettings, stackRootL
, stackYamlL
)
import Stack.Types.Dependency
( DepValue (DepValue), DepType (AsLibrary) )
import Stack.Types.DumpPackage ( DumpPackage (..) )
import Stack.Types.EnvConfig
( EnvConfig (..), HasEnvConfig (..), HasSourceMap (..) )
import Stack.Types.GhcPkgId ( GhcPkgId )
import Stack.Types.NamedComponent ( exeComponents, renderComponent )
import Stack.Types.Package
Expand Down Expand Up @@ -174,7 +177,10 @@ instance HasPantryConfig Ctx where
instance HasProcessContext Ctx where
processContextL = configL.processContextL

instance HasBuildConfig Ctx
instance HasBuildConfig Ctx where
buildConfigL = envConfigL.lens
envConfigBuildConfig
(\x y -> x { envConfigBuildConfig = y })

instance HasSourceMap Ctx where
sourceMapL = envConfigL.sourceMapL
Expand Down
28 changes: 17 additions & 11 deletions src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,27 @@ import Stack.Types.Compiler
( ActualCompiler (..), WhichCompiler (..)
, compilerVersionString, getGhcVersion
)
import Stack.Types.CompilerPaths
( CompilerPaths (..), GhcPkgExe (..), HasCompiler (..)
, cabalVersionL, cpWhich, getCompilerPath, getGhcPkgExe
)
import Stack.Types.Config
( BenchmarkOpts (..), BuildConfig (..), BuildOpts (..)
, BuildOptsCLI (..), CabalVerbosity (..), CompilerPaths (..)
, Config (..), Curator (..), DumpPackage (..)
, EnvSettings (..), GhcPkgExe (..), HaddockOpts (..)
, HasBuildConfig (..), HasCompiler (..), HasConfig (..)
, HasEnvConfig, HasPlatform (..), TestOpts (..)
, actualCompilerVersionL, appropriateGhcColorFlag
, bindirCompilerTools, buildOptsL, cabalVersionL, cpWhich
, getCompilerPath, getGhcPkgExe, installationRootDeps
, installationRootLocal, packageDatabaseLocal
, platformGhcRelDir, projectRootL, shouldForceGhcColorFlag
, stackRootL, whichCompilerL
, BuildOptsCLI (..), CabalVerbosity (..), Config (..)
, Curator (..), EnvSettings (..), HaddockOpts (..)
, HasBuildConfig (..), HasConfig (..), HasPlatform (..)
, TestOpts (..), buildOptsL, projectRootL, stackRootL
, whichCompilerL
)
import Stack.Types.DumpLogs ( DumpLogs (..) )
import Stack.Types.DumpPackage ( DumpPackage (..) )
import Stack.Types.EnvConfig
( HasEnvConfig (..), actualCompilerVersionL
, appropriateGhcColorFlag, bindirCompilerTools
, installationRootDeps, installationRootLocal
, packageDatabaseLocal, platformGhcRelDir
, shouldForceGhcColorFlag
)
import Stack.Types.GhcPkgId ( GhcPkgId, ghcPkgIdString, unGhcPkgId )
import Stack.Types.GlobalOpts ( GlobalOpts (..) )
import Stack.Types.NamedComponent
Expand Down
8 changes: 4 additions & 4 deletions src/Stack/Build/Haddock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import RIO.Process ( HasProcessContext, withWorkingDir )
import Stack.Constants ( docDirSuffix, relDirAll, relFileIndexHtml )
import Stack.Prelude
import Stack.Types.Build ( BaseConfigOpts (..), BuildException (..) )
import Stack.Types.CompilerPaths
( CompilerPaths (..), HasCompiler (..) )
import Stack.Types.Config
( BuildOpts (..), BuildOptsCLI (..), CompilerPaths (..)
, DumpPackage (..), HaddockOpts (..), HasCompiler
, compilerPathsL
)
( BuildOpts (..), BuildOptsCLI (..), HaddockOpts (..) )
import Stack.Types.DumpPackage ( DumpPackage (..) )
import Stack.Types.GhcPkgId ( GhcPkgId )
import Stack.Types.Package
( InstallLocation (..), LocalPackage (..), Package (..) )
Expand Down
11 changes: 6 additions & 5 deletions src/Stack/Build/Installed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import Stack.PackageDump
( conduitDumpPackage, ghcPkgDump, pruneDeps )
import Stack.Prelude
import Stack.SourceMap ( getPLIVersion, loadVersion )
import Stack.Types.Config
( DumpPackage (..), HasEnvConfig, getGhcPkgExe
, packageDatabaseDeps, packageDatabaseExtra
, packageDatabaseLocal
)
import Stack.Types.CompilerPaths ( getGhcPkgExe )
import Stack.Types.DumpPackage ( DumpPackage (..) )
import Stack.Types.EnvConfig
( HasEnvConfig, packageDatabaseDeps, packageDatabaseExtra
, packageDatabaseLocal
)
import Stack.Types.GhcPkgId ( GhcPkgId )
import Stack.Types.Package
( InstallLocation (..), InstallMap, Installed (..)
Expand Down
11 changes: 7 additions & 4 deletions src/Stack/Build/Source.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,18 @@ import Stack.SourceMap
import Stack.Types.ApplyGhcOptions ( ApplyGhcOptions (..) )
import Stack.Types.Build ( FlagSource (..) )
import Stack.Types.CabalConfigKey ( CabalConfigKey (..) )
import Stack.Types.CompilerPaths ( HasCompiler, getCompilerPath )
import Stack.Types.Config
( ApplyCLIFlag (..), BuildConfig (..), BuildOpts (..)
, BuildOptsCLI (..), Config (..), Curator (..)
, HasBuildConfig (..), HasCompiler, HasConfig (..)
, HasEnvConfig (..), HasPlatform (..), HasSourceMap (..)
, ProjectPackage (..), TestOpts (..), actualCompilerVersionL
, buildOptsL, envConfigSourceMap, getCompilerPath, ppGPD
, HasBuildConfig (..), HasConfig (..), HasPlatform (..)
, ProjectPackage (..), TestOpts (..), buildOptsL, ppGPD
, ppRoot
)
import Stack.Types.EnvConfig
( EnvConfig (..), HasEnvConfig (..), HasSourceMap (..)
, actualCompilerVersionL
)
import Stack.Types.NamedComponent
( NamedComponent (..), isCInternalLib )
import Stack.Types.Package
Expand Down
6 changes: 3 additions & 3 deletions src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ import Stack.Types.Config
( BuildConfig (..), BuildOpts (..), Config (..)
, ConfigException (..), ConfigPrettyException (..)
, HasConfig (..), ParseAbsolutePathException (..)
, PlatformVariant (..), Project (..)
, ProjectAndConfigMonoid (..), ProjectConfig (..)
, askLatestSnapshotUrl, configProjectRoot
, Project (..), ProjectAndConfigMonoid (..)
, ProjectConfig (..), askLatestSnapshotUrl, configProjectRoot
, packageIndicesWarning, parseProjectAndConfigMonoid
, platformOnlyRelDir, stackRootL, workDirL
)
Expand All @@ -118,6 +117,7 @@ import Stack.Types.Docker ( DockerOptsMonoid (..), dockerEnable )
import Stack.Types.DumpLogs ( DumpLogs (..) )
import Stack.Types.GlobalOpts ( GlobalOpts (..) )
import Stack.Types.Nix ( nixEnable )
import Stack.Types.PlatformVariant ( PlatformVariant (..) )
import Stack.Types.PvpBounds ( PvpBounds (..), PvpBoundsType (..) )
import Stack.Types.Resolver ( AbstractResolver (..), Snapshots (..) )
import Stack.Types.Runner
Expand Down
3 changes: 2 additions & 1 deletion src/Stack/ConfigCmd.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ import Stack.Config
import Stack.Constants ( stackDotYaml )
import Stack.Prelude
import Stack.Types.Config
( Config (..), EnvConfig, EnvSettings (..), HasConfig (..)
( Config (..), EnvSettings (..), HasConfig (..)
, HasGHCVariant, ProjectConfig (..)
)
import Stack.Types.ConfigMonoid
( configMonoidInstallGHCName, configMonoidSystemGHCName )
import Stack.Types.EnvConfig ( EnvConfig )
import Stack.Types.GlobalOpts ( GlobalOpts (..) )
import Stack.Types.Resolver ( AbstractResolver, readAbstractResolver )
import Stack.Types.Runner ( globalOptsL )
Expand Down
7 changes: 4 additions & 3 deletions src/Stack/Constants/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ module Stack.Constants.Config
import Path ( (</>), mkRelDir, mkRelFile, parseRelDir )
import Stack.Constants ( cabalPackageName )
import Stack.Prelude
import Stack.Types.CompilerPaths ( cabalVersionL )
import Stack.Types.Config
( Config, HasBuildConfig, HasConfig, HasEnvConfig
, cabalVersionL, platformGhcRelDir, projectRootL
, stackRootL, useShaPathOnWindows, workDirL
( Config, HasBuildConfig, HasConfig, projectRootL, stackRootL
, useShaPathOnWindows, workDirL
)
import Stack.Types.EnvConfig ( HasEnvConfig, platformGhcRelDir )

-- | Output .o/.hi directory.
objectInterfaceDirL :: HasBuildConfig env => Getting r env (Path Abs Dir)
Expand Down
11 changes: 7 additions & 4 deletions src/Stack/Coverage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@ import Stack.Constants.Config ( distDirFromDir, hpcRelativeDir )
import Stack.Prelude
import Stack.Runners ( ShouldReexec (..), withConfig, withEnvConfig )
import Stack.Types.Compiler ( getGhcVersion )
import Stack.Types.CompilerPaths ( cabalVersionL )
import Stack.Types.Config
( BuildConfig (..), BuildOptsCLI (..), EnvConfig (..)
, HasBuildConfig (..), HasEnvConfig (..)
, actualCompilerVersionL, cabalVersionL, defaultBuildOptsCLI
, hpcReportDir, ppRoot
( BuildConfig (..), BuildOptsCLI (..), HasBuildConfig (..)
, defaultBuildOptsCLI, ppRoot
)
import Stack.Types.EnvConfig
( EnvConfig (..), HasEnvConfig (..), actualCompilerVersionL
, hpcReportDir
)
import Stack.Types.NamedComponent ( NamedComponent (..) )
import Stack.Types.Package
Expand Down
2 changes: 2 additions & 0 deletions src/Stack/Dot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import Stack.SourceMap
import Stack.Types.Build
import Stack.Types.Compiler ( wantedToActual )
import Stack.Types.Config
import Stack.Types.DumpPackage ( DumpPackage (..) )
import Stack.Types.EnvConfig ( EnvConfig (..), HasSourceMap (..) )
import Stack.Types.GhcPkgId
import Stack.Types.Runner ( HasRunner (..), Runner )
import Stack.Types.SourceMap
Expand Down
10 changes: 6 additions & 4 deletions src/Stack/Exec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ import Stack.Setup ( withNewLocalBuildTargets )
import Stack.Types.NamedComponent ( NamedComponent (..), isCExe )
import Stack.Prelude
import Stack.Runners ( ShouldReexec (..), withConfig, withEnvConfig )
import Stack.Types.CompilerPaths
( CompilerPaths (..), HasCompiler (..), getGhcPkgExe )
import Stack.Types.Config
( BuildConfig (..), BuildOptsCLI (..), CompilerPaths (..)
, EnvConfig, EnvSettings (..), buildConfigL, compilerPathsL
, configL, configProcessContextSettings, defaultBuildOptsCLI
, getGhcPkgExe, ppComponents
( BuildConfig (..), BuildOptsCLI (..), EnvSettings (..)
, buildConfigL, configL, configProcessContextSettings
, defaultBuildOptsCLI, ppComponents
)
import Stack.Types.EnvConfig ( EnvConfig )
import Stack.Types.Runner ( Runner )
import Stack.Types.SourceMap ( SMWanted (..) )
import System.Directory ( withCurrentDirectory )
Expand Down
4 changes: 2 additions & 2 deletions src/Stack/GhcPkg.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import Path.IO
import RIO.Process ( HasProcessContext, proc, readProcess_ )
import Stack.Constants ( relFilePackageCache )
import Stack.Prelude
import Stack.Types.Config ( GhcPkgExe (..) )
import Stack.Types.GhcPkgId ( GhcPkgId, ghcPkgIdString )
import Stack.Types.Compiler ( WhichCompiler (..) )
import Stack.Types.CompilerPaths ( GhcPkgExe (..) )
import Stack.Types.GhcPkgId ( GhcPkgId, ghcPkgIdString )
import System.FilePath ( searchPathSeparator )

-- | Get the global package database
Expand Down
4 changes: 4 additions & 0 deletions src/Stack/Ghci.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ import Stack.Package
import Stack.Prelude
import Stack.Runners ( ShouldReexec (..), withConfig, withEnvConfig )
import Stack.Types.Build
import Stack.Types.CompilerPaths
( CompilerPaths (..), HasCompiler (..) )
import Stack.Types.Config
import Stack.Types.EnvConfig
( EnvConfig (..), HasEnvConfig (..), actualCompilerVersionL )
import Stack.Types.NamedComponent
import Stack.Types.Package
import Stack.Types.PackageFile
Expand Down
11 changes: 7 additions & 4 deletions src/Stack/Hoogle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ import Stack.Runners
, withEnvConfig
)
import Stack.Types.Config
( BuildOptsCLI (..), Config (..), EnvConfig, EnvSettings (..)
, HasConfig (..), HasSourceMap (..), buildOptsMonoidHaddockL
, defaultBuildOptsCLI, hoogleDatabasePath, hoogleRoot
, globalOptsBuildOptsMonoidL
( BuildOptsCLI (..), Config (..), EnvSettings (..)
, HasConfig (..), buildOptsMonoidHaddockL
, defaultBuildOptsCLI, globalOptsBuildOptsMonoidL
)
import Stack.Types.EnvConfig
( EnvConfig, HasSourceMap (..), hoogleDatabasePath
, hoogleRoot
)
import Stack.Types.GlobalOpts ( GlobalOpts (..) )
import Stack.Types.Runner ( Runner, globalOptsL )
Expand Down
4 changes: 2 additions & 2 deletions src/Stack/Ls.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import Stack.Runners
( ShouldReexec (..), withConfig, withDefaultEnvConfig )
import Stack.Setup.Installed
( Tool (..), filterTools, listInstalled, toolString )
import Stack.Types.Config
( Config (..), HasConfig (..), installationRootDeps )
import Stack.Types.Config ( Config (..), HasConfig (..) )
import Stack.Types.EnvConfig ( installationRootDeps )
import Stack.Types.Runner ( HasRunner, Runner, terminalL )
import System.Console.ANSI.Codes
( SGR (Reset), setSGRCode, sgrToCode )
Expand Down
1 change: 1 addition & 0 deletions src/Stack/Options/Completion.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Stack.Options.GlobalParser ( globalOptsFromMonoid )
import Stack.Runners
import Stack.Prelude
import Stack.Types.Config
import Stack.Types.EnvConfig ( EnvConfig )
import Stack.Types.GlobalOpts ( GlobalOpts (..) )
import Stack.Types.NamedComponent
import Stack.Types.SourceMap
Expand Down
Loading

0 comments on commit 714ad54

Please sign in to comment.