Skip to content
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

Use exact GHC versions rather than major-version #736 #784

Merged
merged 3 commits into from
Aug 14, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/Stack/Build/Source.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,13 @@ parseTargetsFromBuildOpts needTargets bopts = do
ResolverSnapshot snapName -> do
$logDebug $ "Checking resolver: " <> renderSnapName snapName
loadMiniBuildPlan snapName
ResolverGhc ghc ->
return
MiniBuildPlan
{ mbpGhcVersion = fromMajorVersion ghc
ResolverCompiler _ -> do
-- We ignore the resolver version, as it might be
-- GhcMajorVersion, and we want the exact version
-- we're using.
version <- asks (envConfigGhcVersion . getEnvConfig)
return MiniBuildPlan
{ mbpGhcVersion = version
, mbpPackages = Map.empty
}
ResolverCustom _ url -> do
Expand Down
4 changes: 2 additions & 2 deletions src/Stack/BuildPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ data CustomSnapshot = CustomSnapshot
instance FromJSON CustomSnapshot where
parseJSON = withObject "CustomSnapshot" $ \o -> CustomSnapshot
<$> ((o .: "compiler") >>= (\t -> maybe (fail $ "Invalid compiler: " ++ T.unpack t) return $ do
t' <- T.stripPrefix "ghc-" t
parseVersionFromString $ T.unpack t'))
GhcVersion v <- parseCompilerVersion t
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably shouldn't use this kind of match, as the compiler will hide the incomplete pattern match, and you're about to add more constructors (I presume).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make the change myself, it will also give me a chance to compile/test it locally.

return v))
<*> o .: "packages"
<*> o .:? "flags" .!= Map.empty
12 changes: 7 additions & 5 deletions src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ configFromConfigMonoid configStackRoot mproject configMonoid@ConfigMonoid{..} =

configImage = Image.imgOptsFromMonoid configMonoidImageOpts

configCompilerCheck = fromMaybe MatchMinor configMonoidCompilerCheck

origEnv <- getEnvOverride configPlatform
let configEnvOverride _ = return origEnv

Expand Down Expand Up @@ -281,20 +283,20 @@ loadBuildConfig mproject config stackRoot mresolver = do
(MiniConfig manager config)
let project = project' { projectResolver = resolver }

ghcVersion <-
wantedCompiler <-
case projectResolver project of
ResolverSnapshot snapName -> do
mbp <- runReaderT (loadMiniBuildPlan snapName) miniConfig
return $ mbpGhcVersion mbp
ResolverGhc m -> return $ fromMajorVersion m
return $ GhcVersion $ mbpGhcVersion mbp
ResolverCustom _name url -> do
mbp <- runReaderT (parseCustomMiniBuildPlan stackYamlFP url) miniConfig
return $ mbpGhcVersion mbp
return $ GhcVersion $ mbpGhcVersion mbp
ResolverCompiler wantedCompiler -> return wantedCompiler

return BuildConfig
{ bcConfig = config
, bcResolver = projectResolver project
, bcGhcVersionExpected = ghcVersion
, bcWantedCompiler = wantedCompiler
, bcPackageEntries = projectPackages project
, bcExtraDeps = projectExtraDeps project
, bcStackYaml = stackYamlFP
Expand Down
4 changes: 2 additions & 2 deletions src/Stack/Fetch.hs
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,14 @@ fuzzyLookupCandidates (PackageIdentifier name ver) caches =
if null sameMajor then Nothing else Just (map fst sameMajor)
where
sameMajor = filter (\(PackageIdentifier _ v, _) ->
getMajorVersion ver == getMajorVersion v)
toMajorVersion ver == toMajorVersion v)
sameIdentCaches
sameIdentCaches = maybe biggerFiltered
(\z -> (zeroIdent, z) : biggerFiltered)
zeroVer
biggerFiltered = takeWhile (\(PackageIdentifier n _, _) -> name == n)
(Map.toList bigger)
zeroIdent = PackageIdentifier name (fromMajorVersion (MajorVersion 0 0))
zeroIdent = PackageIdentifier name $(mkVersion "0.0")
(_, zeroVer, bigger) = Map.splitLookup zeroIdent caches

-- | Figure out where to fetch from.
Expand Down
4 changes: 2 additions & 2 deletions src/Stack/Init.hs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ getDefaultResolver cabalfps gpds initOpts =
mpair <-
case resolver of
ResolverSnapshot name -> findBuildPlan gpds [name]
ResolverGhc _ -> return Nothing
ResolverCompiler _ -> return Nothing
ResolverCustom _ _ -> return Nothing
case mpair of
Just (snap, flags) ->
Expand All @@ -157,7 +157,7 @@ getDefaultResolver cabalfps gpds initOpts =
MethodSolver -> do
(ghcVersion, extraDeps) <- cabalSolver (map parent cabalfps) Map.empty []
return
( ResolverGhc ghcVersion
( ResolverCompiler (GhcVersion ghcVersion)
, Map.filter (not . Map.null) $ fmap snd extraDeps
, fmap fst extraDeps
)
Expand Down
Loading