-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
To prevent download ghc when using stack clean
.
#4268
Changes from all commits
1f51ff7
1f2b95d
8eaed53
1974a24
391d2e5
2d8998e
f4eb713
12f0c43
67c07b2
ae16993
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ module Stack.Runners | |
, withMiniConfigAndLock | ||
, withBuildConfigAndLock | ||
, withBuildConfigAndLockNoDocker | ||
, withBuildConfigAndLockInClean | ||
, withBuildConfigAndLockNoDockerInClean | ||
, withBuildConfig | ||
, withBuildConfigExt | ||
, withBuildConfigDot | ||
|
@@ -127,7 +129,7 @@ withBuildConfigAndLock | |
-> (Maybe FileLock -> RIO EnvConfig ()) | ||
-> IO () | ||
withBuildConfigAndLock go inner = | ||
withBuildConfigExt False go Nothing inner Nothing | ||
withBuildConfigExt WithDocker WithDownloadCompiler go Nothing inner Nothing | ||
|
||
-- | See issue #2010 for why this exists. Currently just used for the | ||
-- specific case of "stack clean --full". | ||
|
@@ -136,10 +138,27 @@ withBuildConfigAndLockNoDocker | |
-> (Maybe FileLock -> RIO EnvConfig ()) | ||
-> IO () | ||
withBuildConfigAndLockNoDocker go inner = | ||
withBuildConfigExt True go Nothing inner Nothing | ||
withBuildConfigExt SkipDocker WithDownloadCompiler go Nothing inner Nothing | ||
|
||
withBuildConfigAndLockInClean | ||
:: GlobalOpts | ||
-> (Maybe FileLock -> RIO EnvConfig ()) | ||
-> IO () | ||
withBuildConfigAndLockInClean go inner = | ||
withBuildConfigExt WithDocker SkipDownloadCompiler go Nothing inner Nothing | ||
|
||
-- | See issue #2010 for why this exists. Currently just used for the | ||
-- specific case of "stack clean --full". | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comment below |
||
withBuildConfigAndLockNoDockerInClean | ||
:: GlobalOpts | ||
-> (Maybe FileLock -> RIO EnvConfig ()) | ||
-> IO () | ||
withBuildConfigAndLockNoDockerInClean go inner = | ||
withBuildConfigExt SkipDocker SkipDownloadCompiler go Nothing inner Nothing | ||
|
||
withBuildConfigExt | ||
:: Bool | ||
:: WithDocker | ||
-> WithDownloadCompiler -- ^ bypassed download compiler if SkipDownloadCompiler. | ||
-> GlobalOpts | ||
-> Maybe (RIO Config ()) | ||
-- ^ Action to perform before the build. This will be run on the host | ||
|
@@ -155,7 +174,7 @@ withBuildConfigExt | |
-- available in this action, since that would require build tools to be | ||
-- installed on the host OS. | ||
-> IO () | ||
withBuildConfigExt skipDocker go@GlobalOpts{..} mbefore inner mafter = loadConfigWithOpts go $ \lc -> do | ||
withBuildConfigExt skipDocker downloadCompiler go@GlobalOpts{..} mbefore inner mafter = loadConfigWithOpts go $ \lc -> do | ||
withUserFileLock go (view stackRootL lc) $ \lk0 -> do | ||
-- A local bit of state for communication between callbacks: | ||
curLk <- newIORef lk0 | ||
|
@@ -173,25 +192,26 @@ withBuildConfigExt skipDocker go@GlobalOpts{..} mbefore inner mafter = loadConfi | |
|
||
let inner'' lk = do | ||
bconfig <- lcLoadBuildConfig lc globalCompiler | ||
envConfig <- runRIO bconfig (setupEnv Nothing) | ||
let bconfig' = bconfig { bcDownloadCompiler = downloadCompiler } | ||
envConfig <- runRIO bconfig' (setupEnv Nothing) | ||
runRIO envConfig (inner' lk) | ||
|
||
let getCompilerVersion = loadCompilerVersion go lc | ||
if skipDocker | ||
then runRIO (lcConfig lc) $ do | ||
forM_ mbefore id | ||
Nix.reexecWithOptionalShell (lcProjectRoot lc) getCompilerVersion (inner'' lk0) | ||
forM_ mafter id | ||
else runRIO (lcConfig lc) $ | ||
Docker.reexecWithOptionalContainer | ||
(lcProjectRoot lc) | ||
mbefore | ||
(runRIO (lcConfig lc) $ | ||
Nix.reexecWithOptionalShell (lcProjectRoot lc) getCompilerVersion (inner'' lk0)) | ||
mafter | ||
(Just $ liftIO $ | ||
do lk' <- readIORef curLk | ||
munlockFile lk') | ||
runRIO (lcConfig lc) $ | ||
case skipDocker of | ||
SkipDocker -> do | ||
forM_ mbefore id | ||
Nix.reexecWithOptionalShell (lcProjectRoot lc) getCompilerVersion (inner'' lk0) | ||
forM_ mafter id | ||
WithDocker -> Docker.reexecWithOptionalContainer | ||
(lcProjectRoot lc) | ||
mbefore | ||
(runRIO (lcConfig lc) $ | ||
Nix.reexecWithOptionalShell (lcProjectRoot lc) getCompilerVersion (inner'' lk0)) | ||
mafter | ||
(Just $ liftIO $ | ||
do lk' <- readIORef curLk | ||
munlockFile lk') | ||
|
||
-- | Load the configuration. Convenience function used | ||
-- throughout this module. | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -81,6 +81,10 @@ module Stack.Types.Config | |||||
,defaultLogLevel | ||||||
-- ** LoadConfig | ||||||
,LoadConfig(..) | ||||||
-- ** WithDocker | ||||||
,WithDocker(..) | ||||||
-- ** WithDownloadCompiler | ||||||
,WithDownloadCompiler(..) | ||||||
|
||||||
-- ** Project & ProjectAndConfigMonoid | ||||||
,Project(..) | ||||||
|
@@ -507,8 +511,17 @@ data BuildConfig = BuildConfig | |||||
-- ^ Are we loading from the implicit global stack.yaml? This is useful | ||||||
-- for providing better error messages. | ||||||
, bcCurator :: !(Maybe Curator) | ||||||
, bcDownloadCompiler :: !WithDownloadCompiler | ||||||
} | ||||||
|
||||||
data WithDocker | ||||||
= SkipDocker | ||||||
| WithDocker | ||||||
|
||||||
data WithDownloadCompiler | ||||||
= SkipDownloadCompiler | ||||||
| WithDownloadCompiler | ||||||
|
||||||
stackYamlL :: HasBuildConfig env => Lens' env (Path Abs File) | ||||||
stackYamlL = buildConfigL.lens bcStackYaml (\x y -> x { bcStackYaml = y }) | ||||||
|
||||||
|
@@ -530,7 +543,7 @@ data EnvConfig = EnvConfig | |||||
-- ^ The actual version of the compiler to be used, as opposed to | ||||||
-- 'wantedCompilerL', which provides the version specified by the | ||||||
-- build plan. | ||||||
,envConfigCompilerBuild :: !CompilerBuild | ||||||
,envConfigCompilerBuild :: !(Maybe CompilerBuild) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think we want to force the whole thing. |
||||||
,envConfigLoadedSnapshot :: !LoadedSnapshot | ||||||
-- ^ The fully resolved snapshot information. | ||||||
} | ||||||
|
@@ -1269,9 +1282,9 @@ platformGhcRelDir | |||||
=> m (Path Rel Dir) | ||||||
platformGhcRelDir = do | ||||||
ec <- view envConfigL | ||||||
let cbSuffix = maybe "" compilerBuildSuffix $ envConfigCompilerBuild ec | ||||||
verOnly <- platformGhcVerOnlyRelDirStr | ||||||
parseRelDir (mconcat [ verOnly | ||||||
, compilerBuildSuffix (envConfigCompilerBuild ec)]) | ||||||
parseRelDir (mconcat [ verOnly, cbSuffix ]) | ||||||
|
||||||
-- | Relative directory for the platform and GHC identifier without GHC bindist build | ||||||
platformGhcVerOnlyRelDir | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -635,8 +635,8 @@ cleanCmd opts go = | |
-- See issues #2010 and #3468 for why "stack clean --full" is not used | ||
-- within docker. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
case opts of | ||
CleanFull{} -> withBuildConfigAndLockNoDocker go (const (clean opts)) | ||
CleanShallow{} -> withBuildConfigAndLock go (const (clean opts)) | ||
CleanFull{} -> withBuildConfigAndLockNoDockerInClean go (const (clean opts)) | ||
CleanShallow{} -> withBuildConfigAndLockInClean go (const (clean opts)) | ||
|
||
-- | Helper for build and install commands | ||
buildCmd :: BuildOptsCLI -> GlobalOpts -> IO () | ||
|
@@ -963,7 +963,8 @@ imgDockerCmd :: (Bool, [Text]) -> GlobalOpts -> IO () | |
imgDockerCmd (rebuild,images) go@GlobalOpts{..} = loadConfigWithOpts go $ \lc -> do | ||
let mProjectRoot = lcProjectRoot lc | ||
withBuildConfigExt | ||
False | ||
WithDocker | ||
WithDownloadCompiler | ||
go | ||
Nothing | ||
(\lk -> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-- | | ||
-- The integration tests have no ghc present, initially. Stack should not | ||
-- require ghc present to run the `clean` command. | ||
|
||
import StackTest | ||
|
||
main :: IO () | ||
main = do | ||
-- `stack clean` should succeed even though there is no ghc available. | ||
-- See the stack.yaml file for how this works. | ||
stack ["clean"] | ||
stack ["clean", "--full"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cabal-version: >= 1.10 | ||
|
||
-- This file has been generated from package.yaml by hpack version 0.29.6. | ||
-- | ||
-- see: https://github.com/sol/hpack | ||
-- | ||
-- hash: 941a1ab4bea2f0ee229dd6ab7fe9730517a0397fb9141fe2841a0f9748dbfd57 | ||
|
||
name: foo | ||
version: 0.1.0.0 | ||
build-type: Simple | ||
|
||
library |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Update the resolver as necessary | ||
resolver: ghc-8.22 | ||
# Do not use the system ghc, as ghc must not be available | ||
system-ghc: false | ||
# Do not install any other ghc, as ghc must not be available | ||
install-ghc: false | ||
packages: | ||
- '.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment below