@@ -14,49 +14,48 @@ module Stack.Build.Source
14
14
, hashSourceMapData
15
15
) where
16
16
17
- import Conduit ( ZipSink (.. ), withSourceFile )
18
- import Data.ByteString.Builder ( toLazyByteString )
19
- import qualified Data.List as L
20
- import qualified Data.Map as Map
21
- import qualified Data.Map.Strict as M
22
- import qualified Data.Set as Set
23
- import qualified Distribution.PackageDescription as C
24
- import qualified Pantry.SHA256 as SHA256
25
- import Stack.Build.Cache ( tryGetBuildCache )
26
- import Stack.Build.Haddock ( shouldHaddockDeps )
27
- import Stack.Package ( resolvePackage )
28
- import Stack.Prelude
29
- import Stack.SourceMap
30
- ( DumpedGlobalPackage , checkFlagsUsedThrowing
31
- , getCompilerInfo , immutableLocSha , mkProjectPackage
32
- , pruneGlobals
33
- )
34
- import Stack.Types.Build ( FlagSource (.. ) )
35
- import Stack.Types.Config
36
- ( ApplyCLIFlag (.. ), ApplyGhcOptions (.. )
37
- , BuildConfig (.. ), BuildOpts (.. ), BuildOptsCLI (.. )
38
- , CabalConfigKey (.. ), Config (.. ), Curator (.. )
39
- , HasBuildConfig (.. ), HasCompiler , HasConfig (.. )
40
- , HasEnvConfig (.. ), HasPlatform (.. ), HasSourceMap (.. )
41
- , ProjectPackage (.. ), TestOpts (.. )
42
- , actualCompilerVersionL , buildOptsL , envConfigSourceMap
43
- , getCompilerPath , ppGPD , ppRoot
44
- )
45
- import Stack.Types.NamedComponent
46
- ( NamedComponent (.. ), isCInternalLib )
47
- import Stack.Types.Package
48
- ( FileCacheInfo (.. ), LocalPackage (.. ), Package (.. )
49
- , PackageConfig (.. ), PackageLibraries (.. )
50
- , dotCabalGetPath , memoizeRefWith , runMemoizedWith
51
- )
52
- import Stack.Types.PackageFile ( PackageWarning , getPackageFiles )
53
- import Stack.Types.SourceMap
54
- ( CommonPackage (.. ), DepPackage (.. ), SMActual (.. )
55
- , SMTargets (.. ), SourceMap (.. ), SourceMapHash (.. )
56
- , Target (.. )
57
- )
58
- import System.FilePath ( takeFileName )
59
- import System.IO.Error ( isDoesNotExistError )
17
+ import Conduit ( ZipSink (.. ), withSourceFile )
18
+ import Data.ByteString.Builder ( toLazyByteString )
19
+ import qualified Data.List as L
20
+ import qualified Data.Map as Map
21
+ import qualified Data.Map.Strict as M
22
+ import qualified Data.Set as Set
23
+ import qualified Distribution.PackageDescription as C
24
+ import qualified Pantry.SHA256 as SHA256
25
+ import Stack.Build.Cache ( tryGetBuildCache )
26
+ import Stack.Build.Haddock ( shouldHaddockDeps )
27
+ import Stack.Package ( resolvePackage )
28
+ import Stack.Prelude
29
+ import Stack.SourceMap
30
+ ( DumpedGlobalPackage , checkFlagsUsedThrowing
31
+ , getCompilerInfo , immutableLocSha , mkProjectPackage
32
+ , pruneGlobals
33
+ )
34
+ import Stack.Types.Build ( FlagSource (.. ) )
35
+ import Stack.Types.Config
36
+ ( ApplyCLIFlag (.. ), ApplyGhcOptions (.. ), BuildConfig (.. )
37
+ , BuildOpts (.. ), BuildOptsCLI (.. ), CabalConfigKey (.. )
38
+ , Config (.. ), Curator (.. ), HasBuildConfig (.. ), HasCompiler
39
+ , HasConfig (.. ), HasEnvConfig (.. ), HasPlatform (.. )
40
+ , HasSourceMap (.. ), ProjectPackage (.. ), TestOpts (.. )
41
+ , actualCompilerVersionL , buildOptsL , envConfigSourceMap
42
+ , getCompilerPath , ppGPD , ppRoot
43
+ )
44
+ import Stack.Types.NamedComponent
45
+ ( NamedComponent (.. ), isCInternalLib )
46
+ import Stack.Types.Package
47
+ ( FileCacheInfo (.. ), LocalPackage (.. ), Package (.. )
48
+ , PackageConfig (.. ), PackageLibraries (.. )
49
+ , dotCabalGetPath , memoizeRefWith , runMemoizedWith
50
+ )
51
+ import Stack.Types.PackageFile ( PackageWarning , getPackageFiles )
52
+ import Stack.Types.SourceMap
53
+ ( CommonPackage (.. ), DepPackage (.. ), SMActual (.. )
54
+ , SMTargets (.. ), SourceMap (.. ), SourceMapHash (.. )
55
+ , Target (.. )
56
+ )
57
+ import System.FilePath ( takeFileName )
58
+ import System.IO.Error ( isDoesNotExistError )
60
59
61
60
-- | loads and returns project packages
62
61
projectLocalPackages :: HasEnvConfig env => RIO env [LocalPackage ]
@@ -162,10 +161,10 @@ hashSourceMapData boptsCli sm = do
162
161
compilerInfo <- getCompilerInfo
163
162
immDeps <- forM (Map. elems (smDeps sm)) depPackageHashableContent
164
163
bc <- view buildConfigL
165
- let -- extra bytestring specifying GHC options supposed to be applied to
166
- -- GHC boot packages so we'll have different hashes when bare
167
- -- resolver 'ghc-X.Y.Z' is used, no extra-deps and e.g. user wants builds
168
- -- with profiling or without
164
+ let -- extra bytestring specifying GHC options supposed to be applied to GHC
165
+ -- boot packages so we'll have different hashes when bare resolver
166
+ -- 'ghc-X.Y.Z' is used, no extra-deps and e.g. user wants builds with
167
+ -- profiling or without
169
168
bootGhcOpts = map display (generalGhcOptions bc boptsCli False False )
170
169
hashedContent =
171
170
toLazyByteString $ compilerPath
@@ -287,7 +286,10 @@ loadLocalPackage pp = do
287
286
let common = ppCommon pp
288
287
bopts <- view buildOptsL
289
288
mcurator <- view $ buildConfigL. to bcCurator
290
- config <- getPackageConfig (cpFlags common) (cpGhcOptions common) (cpCabalConfigOpts common)
289
+ config <- getPackageConfig
290
+ (cpFlags common)
291
+ (cpGhcOptions common)
292
+ (cpCabalConfigOpts common)
291
293
gpkg <- ppGPD pp
292
294
let name = cpName common
293
295
mtarget = M. lookup name (smtTargets $ smTargets sm)
@@ -313,10 +315,9 @@ loadLocalPackage pp = do
313
315
-- See https://github.com/commercialhaskell/stack/issues/2862
314
316
isWanted = case mtarget of
315
317
Nothing -> False
316
- -- FIXME: When issue #1406 ("stack 0.1.8 lost ability to
317
- -- build individual executables or library") is resolved,
318
- -- 'hasLibrary' is only relevant if the library is
319
- -- part of the target spec.
318
+ -- FIXME: When issue #1406 ("stack 0.1.8 lost ability to build
319
+ -- individual executables or library") is resolved, 'hasLibrary' is only
320
+ -- relevant if the library is part of the target spec.
320
321
Just _ ->
321
322
let hasLibrary =
322
323
case packageLibraries pkg of
@@ -326,11 +327,13 @@ loadLocalPackage pp = do
326
327
|| not (Set. null nonLibComponents)
327
328
|| not (Set. null $ packageInternalLibraries pkg)
328
329
329
- filterSkippedComponents = Set. filter (not . (`elem` boptsSkipComponents bopts))
330
+ filterSkippedComponents =
331
+ Set. filter (not . (`elem` boptsSkipComponents bopts))
330
332
331
- (exes, tests, benches) = (filterSkippedComponents exeCandidates,
332
- filterSkippedComponents testCandidates,
333
- filterSkippedComponents benchCandidates)
333
+ (exes, tests, benches) = ( filterSkippedComponents exeCandidates
334
+ , filterSkippedComponents testCandidates
335
+ , filterSkippedComponents benchCandidates
336
+ )
334
337
335
338
nonLibComponents = toComponents exes tests benches
336
339
@@ -374,7 +377,8 @@ loadLocalPackage pp = do
374
377
375
378
let dirtyFiles = do
376
379
checkCacheResults' <- checkCacheResults
377
- let allDirtyFiles = Set. unions $ map (\ (_, (x, _)) -> x) checkCacheResults'
380
+ let allDirtyFiles =
381
+ Set. unions $ map (\ (_, (x, _)) -> x) checkCacheResults'
378
382
pure $
379
383
if not (Set. null allDirtyFiles)
380
384
then let tryStripPrefix y =
@@ -484,12 +488,11 @@ getPackageFilesForTargets pkg cabalFP nonLibComponents = do
484
488
let necessaryComponents =
485
489
Set. insert CLib $ Set. filter isCInternalLib (M. keysSet components')
486
490
components = necessaryComponents `Set.union` nonLibComponents
487
- componentsFiles =
488
- M. map
489
- (\ files ->
490
- Set. union otherFiles (Set. map dotCabalGetPath $ Set. fromList files)
491
- )
492
- $ M. filterWithKey (\ component _ -> component `elem` components) compFiles
491
+ componentsFiles = M. map
492
+ (\ files ->
493
+ Set. union otherFiles (Set. map dotCabalGetPath $ Set. fromList files)
494
+ )
495
+ $ M. filterWithKey (\ component _ -> component `elem` components) compFiles
493
496
pure (componentsFiles, warnings)
494
497
495
498
-- | Get file digest, if it exists
0 commit comments