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

New build plan construction with source maps #4412

Merged
merged 40 commits into from
Dec 20, 2018
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
8037256
Initial gameplan for new build plan construction
snoyberg Sep 15, 2018
f84a62b
Made project compile, SMWanted created in loadBuildConfig
qrilka Sep 24, 2018
b60ac4a
Parse SMTargets, loadSourceMap' using it
qrilka Sep 28, 2018
b7f4310
Migrated to "pure" SourceMap (with no cabal files loaded)
qrilka Oct 1, 2018
0487fd2
Construct build plan from SourceMap
qrilka Oct 5, 2018
e9d34bf
Returned back tellExecutablesUpstream
qrilka Oct 5, 2018
00947fc
Proper build command
qrilka Oct 5, 2018
7a4b51a
SourceMap instead of SMActual in EnvConfig
qrilka Oct 8, 2018
9795649
Partial ghci fix
qrilka Oct 8, 2018
6ddbfc0
Source code cleanup
qrilka Oct 9, 2018
69e2307
fix freeze command
qrilka Oct 9, 2018
bb76969
Fix script command removing loadedSnapshotL
qrilka Oct 9, 2018
a0d2857
Merge branch 'master' into new-build-plan
qrilka Oct 10, 2018
2acc89f
Source code cleanup
qrilka Oct 17, 2018
b18b326
Proper setting of GHC options
qrilka Oct 17, 2018
aef17c1
Source code cleanup
qrilka Oct 19, 2018
3260668
Only 1 buildOptsCLI should be used (hack in withNewLocalBuildTargets)
qrilka Oct 29, 2018
6d57ab5
Proper source map hash
qrilka Nov 2, 2018
dfab51e
Incorporate haddock building flag into source map and use it for hash
qrilka Nov 5, 2018
37bf9d6
source map hash calculated ones, versions from pantry data
qrilka Nov 6, 2018
07f37e0
Fix test 2643-copy-compiler-tool: use per package flag
qrilka Nov 6, 2018
d0b757d
overridable global packages as build plan sources
qrilka Nov 6, 2018
458382c
Fix tests for issue 617 (error messages for incorrect flags)
qrilka Nov 13, 2018
23590f0
Enable back tests during tarball test build
qrilka Nov 14, 2018
81a1e97
Fill empty hackage index when getting package versions
qrilka Nov 14, 2018
7fffb35
General GHC options get prepended and don't override existing ones
qrilka Nov 14, 2018
eac9d99
Return back ignoring dependency bounds between snapshots packages
qrilka Nov 14, 2018
cd408cc
Merge branch 'master' into new-build-plan
qrilka Nov 20, 2018
732dff7
Hlint fixes
qrilka Nov 19, 2018
45d79a7
Global packages from global hints when local GHC wasn't determined
qrilka Nov 21, 2018
62b079c
Code cleanup to minimize diff with master
qrilka Nov 21, 2018
e3462ec
Removed unnecessary MonadIO constraint
qrilka Dec 3, 2018
06757f3
Proper haddocks and correct module hiding in stack script
qrilka Dec 3, 2018
0304d1c
More explicit separation of tasks for building mutable and immutable …
qrilka Dec 3, 2018
0edf7a1
Some fixes due to Alexey's comments
qrilka Dec 12, 2018
d9e8c31
More fixes due to Alexey's comments
qrilka Dec 13, 2018
febd098
Merge branch 'master' into new-build-plan
qrilka Dec 13, 2018
2c5dce5
hlint fixup
qrilka Dec 13, 2018
3b28b7d
Merge branch 'master' into new-build-plan
qrilka Dec 20, 2018
cc7bfd6
Disable failing solver tests to be resolved in #4410
qrilka Dec 20, 2018
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
2 changes: 2 additions & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ library:
- Stack.Sig.Sign
- Stack.Snapshot
- Stack.Solver
- Stack.SourceMap
- Stack.StoreTH
- Stack.Types.Build
- Stack.Types.BuildPlan
Expand All @@ -248,6 +249,7 @@ library:
- Stack.Types.Resolver
- Stack.Types.Runner
- Stack.Types.Sig
- Stack.Types.SourceMap
- Stack.Types.StylesUpdate
- Stack.Types.TemplateName
- Stack.Types.Version
Expand Down
1 change: 1 addition & 0 deletions snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ packages:
- http-api-data-0.3.8.1@rev:1
- cabal-doctest-1.0.6@rev:2
- unliftio-0.2.8.0@sha256:5a47f12ffcee837215c67b05abf35dffb792096564a6f81652d75a54668224cd,2250
- happy-1.19.9@sha256:f8c774230735a390c287b2980cfcd2703d24d8dde85a01ea721b7b4b4c82944f,4667

flags:
cabal-install:
Expand Down
48 changes: 30 additions & 18 deletions src/Stack/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ import Stack.Build.Execute
import Stack.Build.Haddock
import Stack.Build.Installed
import Stack.Build.Source
import Stack.Build.Target
import Stack.Package
import Stack.Types.Build
import Stack.Types.Config
import Stack.Types.NamedComponent
import Stack.Types.Package
import Stack.Types.SourceMap

import Stack.Types.Compiler (compilerVersionText, getGhcVersion)
import System.FileLock (FileLock, unlockFile)
Expand All @@ -57,39 +57,41 @@ import System.Terminal (fixCodePage)
build :: HasEnvConfig env
=> Maybe (Set (Path Abs File) -> IO ()) -- ^ callback after discovering all local files
-> Maybe FileLock
-> BuildOptsCLI
-> RIO env ()
build msetLocalFiles mbuildLk boptsCli = do
build msetLocalFiles mbuildLk = do
mcp <- view $ configL.to configModifyCodePage
ghcVersion <- view $ actualCompilerVersionL.to getGhcVersion
fixCodePage mcp ghcVersion $ do
bopts <- view buildOptsL
let profiling = boptsLibProfile bopts || boptsExeProfile bopts
let symbols = not (boptsLibStrip bopts || boptsExeStrip bopts)

(targets, ls, locals, extraToBuild, sourceMap) <- loadSourceMapFull NeedTargets boptsCli
sourceMap <- view $ envConfigL.to envConfigSourceMap
locals <- projectLocalPackages
depsLocals <- localDependencies
let allLocals = locals <> depsLocals

-- Set local files, necessary for file watching
stackYaml <- view stackYamlL
for_ msetLocalFiles $ \setLocalFiles -> liftIO $ do
for_ msetLocalFiles $ \setLocalFiles -> do
files <- sequence
-- The `locals` value above only contains local project
-- packages, not local dependencies. This will get _all_
-- of the local files we're interested in
-- watching.
[lpFiles lp | PSFilePath lp _ <- Map.elems sourceMap]
setLocalFiles $ Set.insert stackYaml $ Set.unions files
[lpFiles lp | lp <- allLocals]
liftIO $ setLocalFiles $ Set.insert stackYaml $ Set.unions files

checkComponentsBuildable allLocals

installMap <- toInstallMap sourceMap
(installedMap, globalDumpPkgs, snapshotDumpPkgs, localDumpPkgs) <-
getInstalled
GetInstalledOpts
{ getInstalledProfiling = profiling
, getInstalledHaddock = shouldHaddockDeps bopts
, getInstalledSymbols = symbols }
sourceMap
installMap

boptsCli <- view $ envConfigL.to envConfigBuildOptsCLI
baseConfigOpts <- mkBaseConfigOpts boptsCli
plan <- constructPlan ls baseConfigOpts locals extraToBuild localDumpPkgs loadPackage sourceMap installedMap (boptsCLIInitialBuildSteps boptsCli)
plan <- constructPlan baseConfigOpts localDumpPkgs loadPackage sourceMap installedMap (boptsCLIInitialBuildSteps boptsCli)

allowLocals <- view $ configL.to configAllowLocals
unless allowLocals $ case justLocals plan of
Expand Down Expand Up @@ -120,7 +122,7 @@ build msetLocalFiles mbuildLk boptsCli = do
snapshotDumpPkgs
localDumpPkgs
installedMap
targets
(smtTargets $ smTargets sourceMap)
plan

-- | If all the tasks are local, they don't mutate anything outside of our local directory.
Expand Down Expand Up @@ -211,7 +213,7 @@ warnIfExecutablesWithSameNameCouldBeOverwritten locals plan = do
collect
[ (exe,pkgName')
| (pkgName',task) <- Map.toList (planTasks plan)
, TTFilePath lp _ <- [taskType task]
, TTLocalMutable lp <- [taskType task]
, exe <- (Set.toList . exeComponents . lpComponents) lp
]
localExes :: Map Text (NonEmpty PackageName)
Expand All @@ -238,8 +240,8 @@ splitObjsWarning = unwords
]

-- | Get the @BaseConfigOpts@ necessary for constructing configure options
mkBaseConfigOpts :: (MonadIO m, MonadReader env m, HasEnvConfig env, MonadThrow m)
=> BuildOptsCLI -> m BaseConfigOpts
mkBaseConfigOpts :: (HasEnvConfig env)
=> BuildOptsCLI -> RIO env BaseConfigOpts
mkBaseConfigOpts boptsCli = do
bopts <- view buildOptsL
snapDBPath <- packageDatabaseDeps
Expand Down Expand Up @@ -321,7 +323,7 @@ queryBuildInfo selectors0 =
-- | Get the raw build information object
rawBuildInfo :: HasEnvConfig env => RIO env Value
rawBuildInfo = do
(locals, _sourceMap) <- loadSourceMap NeedTargets defaultBuildOptsCLI
locals <- projectLocalPackages
wantedCompiler <- view $ wantedCompilerVersionL.to (utf8BuilderToText . display)
actualCompiler <- view $ actualCompilerVersionL.to compilerVersionText
return $ object
Expand All @@ -340,3 +342,13 @@ rawBuildInfo = do
[ "version" .= CabalString (packageVersion p)
, "path" .= toFilePath (parent $ lpCabalFile lp)
]

checkComponentsBuildable :: MonadThrow m => [LocalPackage] -> m ()
checkComponentsBuildable lps =
unless (null unbuildable) $ throwM $ SomeTargetsNotBuildable unbuildable
where
unbuildable =
[ (packageName (lpPackage lp), c)
| lp <- lps
, c <- Set.toList (lpUnbuildable lp)
]
20 changes: 10 additions & 10 deletions src/Stack/Build/Cache.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ import qualified System.FilePath as FP
import System.PosixCompat.Files (modificationTime, getFileStatus, setFileTimes)

-- | Directory containing files to mark an executable as installed
exeInstalledDir :: (MonadReader env m, HasEnvConfig env, MonadThrow m)
=> InstallLocation -> m (Path Abs Dir)
exeInstalledDir :: (HasEnvConfig env)
=> InstallLocation -> RIO env (Path Abs Dir)
exeInstalledDir Snap = (</> relDirInstalledPackages) `liftM` installationRootDeps
exeInstalledDir Local = (</> relDirInstalledPackages) `liftM` installationRootLocal

-- | Get all of the installed executables
getInstalledExes :: (MonadReader env m, HasEnvConfig env, MonadIO m, MonadThrow m)
=> InstallLocation -> m [PackageIdentifier]
getInstalledExes :: (HasEnvConfig env)
=> InstallLocation -> RIO env [PackageIdentifier]
getInstalledExes loc = do
dir <- exeInstalledDir loc
(_, files) <- liftIO $ handleIO (const $ return ([], [])) $ listDir dir
Expand All @@ -77,8 +77,8 @@ getInstalledExes loc = do
mapMaybe (parsePackageIdentifier . toFilePath . filename) files

-- | Mark the given executable as installed
markExeInstalled :: (MonadReader env m, HasEnvConfig env, MonadIO m, MonadThrow m)
=> InstallLocation -> PackageIdentifier -> m ()
markExeInstalled :: (HasEnvConfig env)
=> InstallLocation -> PackageIdentifier -> RIO env ()
markExeInstalled loc ident = do
dir <- exeInstalledDir loc
ensureDir dir
Expand All @@ -95,8 +95,8 @@ markExeInstalled loc ident = do
liftIO $ B.writeFile fp "Installed"

-- | Mark the given executable as not installed
markExeNotInstalled :: (MonadReader env m, HasEnvConfig env, MonadIO m, MonadThrow m)
=> InstallLocation -> PackageIdentifier -> m ()
markExeNotInstalled :: (HasEnvConfig env)
=> InstallLocation -> PackageIdentifier -> RIO env ()
markExeNotInstalled loc ident = do
dir <- exeInstalledDir loc
ident' <- parseRelFile $ packageIdentifierString ident
Expand Down Expand Up @@ -182,9 +182,9 @@ deleteCaches dir = do
cfp <- configCacheFile dir
liftIO $ ignoringAbsence (removeFile cfp)

flagCacheFile :: (MonadIO m, MonadThrow m, MonadReader env m, HasEnvConfig env)
flagCacheFile :: (HasEnvConfig env)
=> Installed
-> m (Path Abs File)
-> RIO env (Path Abs File)
flagCacheFile installed = do
rel <- parseRelFile $
case installed of
Expand Down
Loading