Skip to content

Commit

Permalink
Merge pull request #6108 from commercialhaskell/refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mpilgrem authored Apr 22, 2023
2 parents fc4a2c2 + 07eec96 commit 4ed76c3
Show file tree
Hide file tree
Showing 21 changed files with 1,186 additions and 1,118 deletions.
5 changes: 5 additions & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ library:
- Stack.Types.ApplyGhcOptions
- Stack.Types.ApplyProgOptions
- Stack.Types.Build
- Stack.Types.Build.Exception
- Stack.Types.BuildConfig
- Stack.Types.BuildOpts
- Stack.Types.CabalConfigKey
Expand All @@ -275,6 +276,7 @@ library:
- Stack.Types.Config
- Stack.Types.Config.Exception
- Stack.Types.ConfigMonoid
- Stack.Types.ConfigureOpts
- Stack.Types.Curator
- Stack.Types.Docker
- Stack.Types.DockerEntrypoint
Expand All @@ -291,11 +293,13 @@ library:
- Stack.Types.GhcPkgId
- Stack.Types.GlobalOpts
- Stack.Types.GlobalOptsMonoid
- Stack.Types.IsMutable
- Stack.Types.LockFileBehavior
- Stack.Types.NamedComponent
- Stack.Types.Nix
- Stack.Types.Package
- Stack.Types.PackageName
- Stack.Types.ParentMap
- Stack.Types.Platform
- Stack.Types.Project
- Stack.Types.ProjectAndConfigMonoid
Expand All @@ -308,6 +312,7 @@ library:
- Stack.Types.SourceMap
- Stack.Types.StackYamlLoc
- Stack.Types.TemplateName
- Stack.Types.UnusedFlags
- Stack.Types.Version
- Stack.Types.VersionedDownloadInfo
- Stack.Uninstall
Expand Down
8 changes: 4 additions & 4 deletions src/Stack/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ import Stack.Prelude hiding ( loadPackage )
import Stack.Runners ( ShouldReexec (..), withConfig, withEnvConfig )
import Stack.Setup ( withNewLocalBuildTargets )
import Stack.Types.Build
( BaseConfigOpts (..), BuildException (..)
, BuildPrettyException (..), Plan (..), Task (..)
, TaskType (..), taskLocation
)
( Plan (..), Task (..), TaskType (..), taskLocation )
import Stack.Types.Build.Exception
( BuildException (..), BuildPrettyException (..) )
import Stack.Types.BuildConfig ( HasBuildConfig, stackYamlL )
import Stack.Types.BuildOpts
( BuildCommand (..), BuildOpts (..), BuildOptsCLI (..)
Expand All @@ -50,6 +49,7 @@ import Stack.Types.CompilerPaths ( cabalVersionL )
import Stack.Types.Config
( Config (..), HasConfig (..), buildOptsL
)
import Stack.Types.ConfigureOpts ( BaseConfigOpts (..) )
import Stack.Types.EnvConfig
( EnvConfig (..), HasEnvConfig (..), HasSourceMap
, actualCompilerVersionL, installationRootDeps
Expand Down
7 changes: 4 additions & 3 deletions src/Stack/Build/Cache.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ import Stack.Storage.User
, precompiledCacheKey, savePrecompiledCache
)
import Stack.Types.Build
( BuildCache (..), BaseConfigOpts (..), ConfigCache
, ConfigureOpts (..), FileCacheInfo, InstallLocation (..)
, Installed (..), PrecompiledCache (..)
( BuildCache (..), ConfigCache, FileCacheInfo
, InstallLocation (..), Installed (..), PrecompiledCache (..)
)
import Stack.Types.Cache ( ConfigCacheType (..) )
import Stack.Types.CompilerPaths ( cabalVersionL )
import Stack.Types.Config ( stackRootL )
import Stack.Types.ConfigureOpts
( BaseConfigOpts (..), ConfigureOpts (..) )
import Stack.Types.EnvConfig
( EnvConfig (..), HasEnvConfig (..), actualCompilerVersionL
, installationRootDeps, installationRootLocal
Expand Down
45 changes: 37 additions & 8 deletions src/Stack/Build/ConstructPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ import Stack.Package ( applyForceCustomBuild )
import Stack.Prelude hiding ( loadPackage )
import Stack.SourceMap ( getPLIVersion, mkProjectPackage )
import Stack.Types.Build
( BaseConfigOpts (..), BadDependency (..)
, BuildException (..), BuildPrettyException (..)
, CachePkgSrc (..), ConfigCache (..), ConfigureOpts (..)
, ConstructPlanException (..), IsMutable (..), ParentMap
, Plan (..), Task (..), TaskConfigOpts (..), TaskType (..)
, configureOpts, installLocationIsMutable, isStackOpt
, taskIsTarget, taskLocation, taskTargetIsMutable
, toCachePkgSrc
( CachePkgSrc (..), ConfigCache (..), Plan (..), Task (..)
, TaskConfigOpts (..), TaskType (..)
, installLocationIsMutable, taskIsTarget, taskLocation
, taskTargetIsMutable, toCachePkgSrc
)
import Stack.Types.Build.Exception
( BadDependency (..), BuildException (..)
, BuildPrettyException (..), ConstructPlanException (..)
)
import Stack.Types.BuildConfig
( BuildConfig (..), HasBuildConfig (..), stackYamlL )
Expand All @@ -46,6 +46,8 @@ import Stack.Types.Compiler ( WhichCompiler (..) )
import Stack.Types.CompilerPaths
( CompilerPaths (..), HasCompiler (..) )
import Stack.Types.Config ( Config (..), HasConfig (..), stackRootL )
import Stack.Types.ConfigureOpts
( BaseConfigOpts (..), ConfigureOpts (..), configureOpts )
import Stack.Types.Curator ( Curator (..) )
import Stack.Types.Dependency
( DepValue (DepValue), DepType (AsLibrary) )
Expand All @@ -55,13 +57,15 @@ import Stack.Types.EnvConfig
import Stack.Types.EnvSettings ( EnvSettings (..), minimalEnvSettings )
import Stack.Types.GHCVariant ( HasGHCVariant (..) )
import Stack.Types.GhcPkgId ( GhcPkgId )
import Stack.Types.IsMutable ( IsMutable (..) )
import Stack.Types.NamedComponent ( exeComponents, renderComponent )
import Stack.Types.Package
( ExeName (..), InstallLocation (..), Installed (..)
, InstalledMap, LocalPackage (..), Package (..)
, PackageLibraries (..), PackageSource (..), installedVersion
, packageIdentifier, psVersion, runMemoizedWith
)
import Stack.Types.ParentMap ( ParentMap )
import Stack.Types.Platform ( HasPlatform (..) )
import Stack.Types.Runner ( HasRunner (..) )
import Stack.Types.SourceMap
Expand Down Expand Up @@ -1129,6 +1133,31 @@ describeConfigDiff config old new
. map T.pack
. (\(ConfigureOpts x y) -> x ++ y)
. configCacheOpts
where
-- options set by Stack
isStackOpt :: Text -> Bool
isStackOpt t = any (`T.isPrefixOf` t)
[ "--dependency="
, "--constraint="
, "--package-db="
, "--libdir="
, "--bindir="
, "--datadir="
, "--libexecdir="
, "--sysconfdir"
, "--docdir="
, "--htmldir="
, "--haddockdir="
, "--enable-tests"
, "--enable-benchmarks"
, "--exact-configuration"
-- Treat these as causing dirtiness, to resolve
-- https://github.com/commercialhaskell/stack/issues/2984
--
-- , "--enable-library-profiling"
-- , "--enable-executable-profiling"
-- , "--enable-profiling"
] || t == "--user"

(oldOpts, newOpts) = removeMatching (userOpts old) (userOpts new)

Expand Down
14 changes: 8 additions & 6 deletions src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,12 @@ import Stack.PackageDump ( conduitDumpPackage, ghcPkgDescribe )
import Stack.Prelude
import Stack.Types.ApplyGhcOptions ( ApplyGhcOptions (..) )
import Stack.Types.Build
( BaseConfigOpts (..), BuildException (..)
, BuildPrettyException (..), ConfigCache (..)
, ConfigureOpts (..), IsMutable (..), Plan (..)
, PrecompiledCache (..), Task (..), TaskConfigOpts (..)
, TaskType (..), configCacheComponents, taskIsTarget
, taskLocation
( ConfigCache (..), Plan (..), PrecompiledCache (..)
, Task (..), TaskConfigOpts (..), TaskType (..)
, configCacheComponents, taskIsTarget, taskLocation
)
import Stack.Types.Build.Exception
( BuildException (..), BuildPrettyException (..) )
import Stack.Types.BuildConfig
( BuildConfig (..), HasBuildConfig (..), projectRootL )
import Stack.Types.BuildOpts
Expand All @@ -153,6 +152,8 @@ import Stack.Types.CompilerPaths
)
import Stack.Types.Config
( Config (..), HasConfig (..), buildOptsL, stackRootL )
import Stack.Types.ConfigureOpts
( BaseConfigOpts (..), ConfigureOpts (..) )
import Stack.Types.DumpLogs ( DumpLogs (..) )
import Stack.Types.DumpPackage ( DumpPackage (..) )
import Stack.Types.EnvConfig
Expand All @@ -165,6 +166,7 @@ import Stack.Types.EnvConfig
import Stack.Types.EnvSettings ( EnvSettings (..) )
import Stack.Types.GhcPkgId ( GhcPkgId, ghcPkgIdString, unGhcPkgId )
import Stack.Types.GlobalOpts ( GlobalOpts (..) )
import Stack.Types.IsMutable ( IsMutable (..) )
import Stack.Types.NamedComponent
( NamedComponent, benchComponents, exeComponents, isCBench
, isCTest, renderComponent, testComponents
Expand Down
3 changes: 2 additions & 1 deletion src/Stack/Build/Haddock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ import RIO.List ( intercalate )
import RIO.Process ( HasProcessContext, withWorkingDir )
import Stack.Constants ( docDirSuffix, relDirAll, relFileIndexHtml )
import Stack.Prelude
import Stack.Types.Build ( BaseConfigOpts (..), BuildException (..) )
import Stack.Types.Build.Exception ( BuildException (..) )
import Stack.Types.CompilerPaths
( CompilerPaths (..), HasCompiler (..) )
import Stack.Types.ConfigureOpts ( BaseConfigOpts (..) )
import Stack.Types.BuildOpts
( BuildOpts (..), BuildOptsCLI (..), HaddockOpts (..) )
import Stack.Types.DumpPackage ( DumpPackage (..) )
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Build/Source.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import Stack.SourceMap
)
import Stack.Types.ApplyGhcOptions ( ApplyGhcOptions (..) )
import Stack.Types.ApplyProgOptions ( ApplyProgOptions (..) )
import Stack.Types.Build ( FlagSource (..) )
import Stack.Types.BuildConfig
( BuildConfig (..), HasBuildConfig (..) )
import Stack.Types.BuildOpts
Expand Down Expand Up @@ -63,6 +62,7 @@ import Stack.Types.SourceMap
, SMActual (..), SMTargets (..), SourceMap (..)
, SourceMapHash (..), Target (..), ppGPD, ppRoot
)
import Stack.Types.UnusedFlags ( FlagSource (..) )
import System.FilePath ( takeFileName )
import System.IO.Error ( isDoesNotExistError )

Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Build/Target.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ import Stack.Types.BuildOpts ( BuildOptsCLI (..) )
import Stack.Types.Config ( Config (..) )
import Stack.Types.NamedComponent
( NamedComponent (..), renderComponent )
import Stack.Types.Build ( BuildPrettyException (..) )
import Stack.Types.Build.Exception ( BuildPrettyException (..) )
import Stack.Types.ProjectConfig ( ProjectConfig (..) )
import Stack.Types.SourceMap
( DepPackage (..), GlobalPackage (..), PackageType (..)
Expand Down
3 changes: 2 additions & 1 deletion src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ import Stack.Storage.Util ( handleMigrationException )
import Stack.Types.AllowNewerDeps ( AllowNewerDeps (..) )
import Stack.Types.ApplyGhcOptions ( ApplyGhcOptions (..) )
import Stack.Types.ApplyProgOptions ( ApplyProgOptions (..) )
import Stack.Types.Build ( BuildException (..), FlagSource (..) )
import Stack.Types.Build.Exception ( BuildException (..) )
import Stack.Types.BuildConfig ( BuildConfig (..) )
import Stack.Types.BuildOpts ( BuildOpts (..) )
import Stack.Types.ColorWhen ( ColorWhen (..) )
Expand Down Expand Up @@ -133,6 +133,7 @@ import Stack.Types.SourceMap
, SMWanted (..)
)
import Stack.Types.StackYamlLoc ( StackYamlLoc (..) )
import Stack.Types.UnusedFlags ( FlagSource (..) )
import Stack.Types.Version
( IntersectingVersionRange (..), VersionCheck (..)
, stackVersion, withinRange
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Ghci.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import Stack.Package
)
import Stack.Prelude
import Stack.Runners ( ShouldReexec (..), withConfig, withEnvConfig )
import Stack.Types.Build
import Stack.Types.Build.Exception
( BuildPrettyException (..), pprintTargetParseErrors )
import Stack.Types.BuildConfig
( BuildConfig (..), HasBuildConfig (..), stackYamlL )
Expand Down
5 changes: 3 additions & 2 deletions src/Stack/SDist.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,15 @@ import Stack.Runners
( ShouldReexec (..), withConfig, withDefaultEnvConfig )
import Stack.SourceMap ( mkProjectPackage )
import Stack.Types.Build
( CachePkgSrc (..), ConfigureOpts (..), Task (..)
, TaskConfigOpts (..), TaskType (..)
( CachePkgSrc (..), Task (..), TaskConfigOpts (..)
, TaskType (..)
)
import Stack.Types.BuildConfig
( BuildConfig (..), HasBuildConfig (..), stackYamlL )
import Stack.Types.BuildOpts
( BuildOpts (..), defaultBuildOpts, defaultBuildOptsCLI )
import Stack.Types.Config ( Config (..), HasConfig (..) )
import Stack.Types.ConfigureOpts ( ConfigureOpts (..) )
import Stack.Types.EnvConfig
( EnvConfig (..), HasEnvConfig (..), actualCompilerVersionL )
import Stack.Types.GhcPkgId ( GhcPkgId )
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ import Stack.Setup.Installed
import Stack.SourceMap
( actualFromGhc, globalsFromDump, pruneGlobals )
import Stack.Storage.User ( loadCompilerPaths, saveCompilerPaths )
import Stack.Types.Build ( BuildException (..) )
import Stack.Types.Build.Exception ( BuildException (..) )
import Stack.Types.BuildConfig
( BuildConfig (..), HasBuildConfig (..), projectRootL
, wantedCompilerVersionL
Expand Down
4 changes: 2 additions & 2 deletions src/Stack/SourceMap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ import RIO.Process ( HasProcessContext )
import qualified RIO.Set as Set
import Stack.PackageDump ( conduitDumpPackage, ghcPkgDump )
import Stack.Prelude
import Stack.Types.Build
( BuildPrettyException (..), FlagSource, UnusedFlags (..) )
import Stack.Types.Build.Exception ( BuildPrettyException (..) )
import Stack.Types.Compiler
( ActualCompiler, actualToWanted, wantedToActual )
import Stack.Types.CompilerPaths
( CompilerPaths (..), GhcPkgExe, HasCompiler (..) )
import Stack.Types.Config ( HasConfig )
import Stack.Types.DumpPackage ( DumpPackage (..) )
import Stack.Types.UnusedFlags ( FlagSource, UnusedFlags (..) )
import Stack.Types.Platform ( HasPlatform (..) )
import Stack.Types.Runner ( rslInLogL )
import Stack.Types.SourceMap
Expand Down
4 changes: 2 additions & 2 deletions src/Stack/Storage/Project.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ import qualified Pantry.Internal as SQLite
import Stack.Prelude
import Stack.Storage.Util
( handleMigrationException, updateList, updateSet )
import Stack.Types.Build
( CachePkgSrc, ConfigCache (..), ConfigureOpts (..) )
import Stack.Types.Build ( CachePkgSrc, ConfigCache (..) )
import Stack.Types.BuildConfig
( BuildConfig (..), HasBuildConfig (..) )
import Stack.Types.Cache ( ConfigCacheType )
import Stack.Types.ConfigureOpts ( ConfigureOpts (..) )
import Stack.Types.GhcPkgId ( GhcPkgId )
import Stack.Types.Storage ( ProjectStorage (..) )

Expand Down
Loading

0 comments on commit 4ed76c3

Please sign in to comment.