2020-02-04 20:00:09.9989738 [ThreadId 3] - run entered for hie-wrapper(hie-wrapper) Version 1.0.0.0, Git revision 4bec07d79cf77c8ee855957d20e315a89f799d75 (dirty) (3745 commits) x86_64 ghc-8.6.5 2020-02-04 20:00:10.0009755 [ThreadId 3] - Current directory:c:\Users\flip111\haskell\cabal 2020-02-04 20:00:10.0009755 [ThreadId 3] - Operating system:mingw32 2020-02-04 20:00:10.0009755 [ThreadId 3] - args:["--lsp","-d","--vomit"] 2020-02-04 20:00:10.0139751 [ThreadId 3] - Cabal-Helper found these projects: ["ProjLocV2File {plCabalProjectFile = \"c:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\cabal.project\", plProjectDirV2 = \"c:\\\\Users\\\\flip111\\\\haskell\\\\cabal\"}","ProjLocStackYaml {plStackYaml = \"c:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\stack.yaml\"}"] 2020-02-04 20:00:10.014977 [ThreadId 3] - These projects have the build tools installed: ["ProjLocV2File {plCabalProjectFile = \"c:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\cabal.project\", plProjectDirV2 = \"c:\\\\Users\\\\flip111\\\\haskell\\\\cabal\"}","ProjLocStackYaml {plStackYaml = \"c:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\stack.yaml\"}"] 2020-02-04 20:00:10.014977 [ThreadId 3] - Cabal-Helper decided to use: ProjLocV2File {plCabalProjectFile = "c:\\Users\\flip111\\haskell\\cabal\\cabal.project", plProjectDirV2 = "c:\\Users\\flip111\\haskell\\cabal"} 2020-02-04 20:00:10.014977 [ThreadId 3] - Cabal-Helper dirs: ["c:\\Users\\flip111\\haskell\\cabal","c:\\Users\\flip111\\haskell\\cabal\\File.hs"] cd c:\Users\flip111\haskell\cabal; cabal v2-build --with-ghc=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc.exe --with-ghc-pkg=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc-pkg.exe --with-haddock=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\haddock.exe --project-file=c:\Users\flip111\haskell\cabal\cabal.project --builddir=c:\Users\flip111\haskell\cabal\dist-newstyle --dry-run all Build profile: -w ghc-8.6.5 -O1 In order, the following would be built (use -v for more details): - Cabal-2.4.1.0 (lib) (requires build) - Cabal-3.3.0.0 (lib) (configuration changed) - abstract-deque-0.3 (lib) (requires download & build) - abstract-par-0.3.3 (lib) (requires download & build) - base16-bytestring-0.1.1.6 (lib:base16-bytestring) (requires download & build) - base64-bytestring-1.0.0.3 (lib) (requires download & build) - cereal-0.5.8.1 (lib) (requires download & build) - cryptohash-sha256-0.11.101.0 (lib) (requires download & build) - data-default-class-0.1.2.0 (lib:data-default-class) (requires download & build) - echo-0.1.3 (lib) (requires download & build) - ed25519-0.0.5.0 (lib) (requires download & build) - edit-distance-0.2.2.1 (lib) (requires download & build) - hsc2hs-0.68.6 (exe:hsc2hs) (requires download & build) - network-uri-2.6.1.0 (lib) (requires download & build) - parallel-3.2.2.0 (lib) (requires download & build) - regex-base-0.94.0.0 (lib) (requires download & build) - tar-0.5.1.1 (lib) (requires download & build) - vector-algorithms-0.8.0.3 (lib) (requires download & build) - vector-binary-instances-0.2.5.1 (lib) (requires download & build) - vector-th-unbox-0.2.1.7 (lib) (requires download & build) - zlib-0.6.2.1 (lib) (requires download & build) - Cabal-3.3.0.0 (test:unit-tests) (configuration changed) - Cabal-3.3.0.0 (test:rpmvercmp) (configuration changed) - Cabal-3.3.0.0 (test:parser-tests) (configuration changed) - Cabal-3.3.0.0 (test:custom-setup-tests) (configuration changed) - Cabal-3.3.0.0 (test:check-tests) (configuration changed) - monad-par-extras-0.3.3 (lib) (requires download & build) - windns-0.1.0.1 (lib) (requires download & build) - network-3.1.1.1 (lib:network) (requires download & build) - lukko-0.1.1.1 (lib) (requires download & build) - regex-tdfa-1.3.1.0 (lib) (requires download & build) - math-functions-0.3.3.0 (lib) (requires download & build) - HTTP-4000.3.14 (lib) (requires download & build) - hackage-security-0.6.0.0 (lib) (requires download & build) - regex-compat-tdfa-0.95.1.4 (lib:regex-compat-tdfa) (requires download & build) - mwc-random-0.14.0.0 (lib) (requires download & build) - dense-linear-algebra-0.1.0.0 (lib) (requires download & build) - cabal-install-3.3.0.0 (exe:cabal) (first run) - cabal-testsuite-3 (lib:cabal-testsuite, exe:cabal-tests, exe:setup) (first run) - monad-par-0.3.5 (lib) (requires download & build) - statistics-0.15.2.0 (lib) (requires download & build) - solver-benchmarks-3 (lib) (first run) - solver-benchmarks-3 (test:unit-tests) (first run) - solver-benchmarks-3 (exe:hackage-benchmark) (first run) 2020-02-04 20:00:11.4826344 [ThreadId 3] - Could not find a package for the file: c:\Users\flip111\haskell\cabal\File.hs 2020-02-04 20:00:11.4836343 [ThreadId 3] - This is perfectly fine if we only want to determine the GHC version. 2020-02-04 20:00:11.4836343 [ThreadId 3] - Module "c:\Users\flip111\haskell\cabal\File.hs" is loaded by Cradle: Cradle {cradleRootDir = "c:\\Users\\flip111\\haskell\\cabal", cradleOptsProg = CradleAction: Other CabalNone} 2020-02-04 20:00:11.4836343 [ThreadId 3] - Cradle directory:c:\Users\flip111\haskell\cabal 2020-02-04 20:00:11.4846336 [ThreadId 3] - Executing GHC on path with args: --numeric-version 2020-02-04 20:00:11.5476357 [ThreadId 3] - GHC Output: "Just "8.6.5"" 2020-02-04 20:00:11.5476357 [ThreadId 3] - Project GHC version:8.6.5 2020-02-04 20:00:11.5476357 [ThreadId 3] - hie exe candidates :["hie-8.6.5.exe","hie-8.6.exe","hie.exe"] 2020-02-04 20:00:11.5476357 [ThreadId 3] - found hie exe at:C:\Users\flip111\AppData\Roaming\local\bin\hie-8.6.5.exe 2020-02-04 20:00:11.5476357 [ThreadId 3] - args:["--lsp","-d","--vomit"] 2020-02-04 20:00:11.5476357 [ThreadId 3] - launching .... 2020-02-04 20:00:11.5756411 [ThreadId 3] - Run entered for HIE(hie-8.6.5.exe) Version 1.0.0.0, Git revision 4bec07d79cf77c8ee855957d20e315a89f799d75 (dirty) (3745 commits) x86_64 ghc-8.6.5 2020-02-04 20:00:11.576638 [ThreadId 3] - Operating as a LSP server on stdio 2020-02-04 20:00:11.576638 [ThreadId 3] - Current directory:c:\Users\flip111\haskell\cabal 2020-02-04 20:00:11.576638 [ThreadId 3] - Operating system:mingw32 2020-02-04 20:00:11.576638 [ThreadId 3] - args:["--lsp","-d","--vomit"] 2020-02-04 20:00:11.576638 [ThreadId 3] - Enabling verbose mode for hie-bios. This option currently doesn't do anything. 2020-02-04 20:00:11.5776425 [ThreadId 3] - haskell-lsp:Starting up server ... 2020-02-04 20:00:11.5786383 [ThreadId 3] - ---> {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":13744,"clientInfo":{"name":"vscode","version":"1.41.1"},"rootPath":"c:\\Users\\flip111\\haskell\\cabal","rootUri":"file:///c%3A/Users/flip111/haskell/cabal","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional"},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true},"textDocument":{"publishDiagnostics":{"relatedInformation":true,"tagSupport":{"valueSet":[1,2]}},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}},"contextSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolSupport":true},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true},"declaration":{"dynamicRegistration":true,"linkSupport":true},"selectionRange":{"dynamicRegistration":true},"callHierarchy":{"dynamicRegistration":true}},"window":{"workDoneProgress":true}},"trace":"off","workspaceFolders":[{"uri":"file:///c%3A/Users/flip111/haskell/cabal","name":"cabal"}]}} 2020-02-04 20:00:11.7046519 [ThreadId 3] - haskell-lsp:initializeRequestHandler: setting current dir to project root:c:\Users\flip111\haskell\cabal 2020-02-04 20:00:11.7046519 [ThreadId 3] - Dummy Cradle file result: c:\Users\flip111\haskell\cabal\File.hs 2020-02-04 20:00:11.7096487 [ThreadId 3] - Cabal-Helper found these projects: ["ProjLocV2File {plCabalProjectFile = \"c:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\cabal.project\", plProjectDirV2 = \"c:\\\\Users\\\\flip111\\\\haskell\\\\cabal\"}","ProjLocStackYaml {plStackYaml = \"c:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\stack.yaml\"}"] 2020-02-04 20:00:11.7106553 [ThreadId 3] - These projects have the build tools installed: ["ProjLocV2File {plCabalProjectFile = \"c:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\cabal.project\", plProjectDirV2 = \"c:\\\\Users\\\\flip111\\\\haskell\\\\cabal\"}","ProjLocStackYaml {plStackYaml = \"c:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\stack.yaml\"}"] 2020-02-04 20:00:11.7106553 [ThreadId 3] - Cabal-Helper decided to use: ProjLocV2File {plCabalProjectFile = "c:\\Users\\flip111\\haskell\\cabal\\cabal.project", plProjectDirV2 = "c:\\Users\\flip111\\haskell\\cabal"} 2020-02-04 20:00:11.7106553 [ThreadId 3] - Cabal-Helper dirs: ["c:\\Users\\flip111\\haskell\\cabal","c:\\Users\\flip111\\haskell\\cabal\\File.hs"] cd c:\Users\flip111\haskell\cabal; cabal v2-build --with-ghc=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc.exe --with-ghc-pkg=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc-pkg.exe --with-haddock=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\haddock.exe --project-file=c:\Users\flip111\haskell\cabal\cabal.project --builddir=c:\Users\flip111\haskell\cabal\dist-newstyle --dry-run all Build profile: -w ghc-8.6.5 -O1 In order, the following would be built (use -v for more details): - Cabal-2.4.1.0 (lib) (requires build) - Cabal-3.3.0.0 (lib) (configuration changed) - abstract-deque-0.3 (lib) (requires download & build) - abstract-par-0.3.3 (lib) (requires download & build) - base16-bytestring-0.1.1.6 (lib:base16-bytestring) (requires download & build) - base64-bytestring-1.0.0.3 (lib) (requires download & build) - cereal-0.5.8.1 (lib) (requires download & build) - cryptohash-sha256-0.11.101.0 (lib) (requires download & build) - data-default-class-0.1.2.0 (lib:data-default-class) (requires download & build) - echo-0.1.3 (lib) (requires download & build) - ed25519-0.0.5.0 (lib) (requires download & build) - edit-distance-0.2.2.1 (lib) (requires download & build) - hsc2hs-0.68.6 (exe:hsc2hs) (requires download & build) - network-uri-2.6.1.0 (lib) (requires download & build) - parallel-3.2.2.0 (lib) (requires download & build) - regex-base-0.94.0.0 (lib) (requires download & build) - tar-0.5.1.1 (lib) (requires download & build) - vector-algorithms-0.8.0.3 (lib) (requires download & build) - vector-binary-instances-0.2.5.1 (lib) (requires download & build) - vector-th-unbox-0.2.1.7 (lib) (requires download & build) - zlib-0.6.2.1 (lib) (requires download & build) - Cabal-3.3.0.0 (test:unit-tests) (configuration changed) - Cabal-3.3.0.0 (test:rpmvercmp) (configuration changed) - Cabal-3.3.0.0 (test:parser-tests) (configuration changed) - Cabal-3.3.0.0 (test:custom-setup-tests) (configuration changed) - Cabal-3.3.0.0 (test:check-tests) (configuration changed) - monad-par-extras-0.3.3 (lib) (requires download & build) - windns-0.1.0.1 (lib) (requires download & build) - network-3.1.1.1 (lib:network) (requires download & build) - lukko-0.1.1.1 (lib) (requires download & build) - regex-tdfa-1.3.1.0 (lib) (requires download & build) - math-functions-0.3.3.0 (lib) (requires download & build) - HTTP-4000.3.14 (lib) (requires download & build) - hackage-security-0.6.0.0 (lib) (requires download & build) - regex-compat-tdfa-0.95.1.4 (lib:regex-compat-tdfa) (requires download & build) - mwc-random-0.14.0.0 (lib) (requires download & build) - dense-linear-algebra-0.1.0.0 (lib) (requires download & build) - cabal-install-3.3.0.0 (exe:cabal) (first run) - cabal-testsuite-3 (lib:cabal-testsuite, exe:cabal-tests, exe:setup) (first run) - monad-par-0.3.5 (lib) (requires download & build) - statistics-0.15.2.0 (lib) (requires download & build) - solver-benchmarks-3 (lib) (first run) - solver-benchmarks-3 (test:unit-tests) (first run) - solver-benchmarks-3 (exe:hackage-benchmark) (first run) 2020-02-04 20:00:12.3066973 [ThreadId 3] - Could not find a package for the file: c:\Users\flip111\haskell\cabal\File.hs 2020-02-04 20:00:12.3066973 [ThreadId 3] - This is perfectly fine if we only want to determine the GHC version. 2020-02-04 20:00:12.3066973 [ThreadId 3] - Module "c:\Users\flip111\haskell\cabal\File.hs" is loaded by Cradle: Cradle {cradleRootDir = "c:\\Users\\flip111\\haskell\\cabal", cradleOptsProg = CradleAction: Other CabalNone} 2020-02-04 20:00:12.3066973 [ThreadId 3] - Executing GHC on path with args: --numeric-version 2020-02-04 20:00:12.3687066 [ThreadId 3] - GHC Output: "Just "8.6.5"" 2020-02-04 20:00:12.3687066 [ThreadId 25] - Executing GHC on path with args: --print-libdir 2020-02-04 20:00:12.3737071 [ThreadId 26] - ****** reactor: top of loop 2020-02-04 20:00:12.3737071 [ThreadId 4] - <--2--{"result":{"capabilities":{"typeDefinitionProvider":true,"foldingRangeProvider":false,"textDocumentSync":{"openClose":true,"change":2,"willSave":false,"willSaveWaitUntil":false,"save":{"includeText":false}},"workspace":{},"implementationProvider":true,"documentRangeFormattingProvider":true,"documentHighlightProvider":true,"executeCommandProvider":{"commands":["3024:applyrefact:applyOne","3024:applyrefact:applyAll","3024:generic:type","3024:ghcmod:check","3024:ghcmod:type","3024:ghcmod:casesplit","3024:hsimport:import","3024:package:add","3024:pragmas:addPragma"]},"renameProvider":false,"colorProvider":false,"definitionProvider":true,"hoverProvider":true,"codeActionProvider":true,"completionProvider":{"triggerCharacters":["."],"resolveProvider":true},"documentSymbolProvider":true,"documentFormattingProvider":true,"referencesProvider":true}},"jsonrpc":"2.0","id":0} 2020-02-04 20:00:12.3927065 [ThreadId 3] - ---> {"jsonrpc":"2.0","method":"initialized","params":{}} 2020-02-04 20:00:12.3927065 [ThreadId 3] - ---> {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"languageServerHaskell":{"hlintOn":true,"maxNumberOfProblems":100,"diagnosticsOnChange":true,"liquidOn":false,"completionSnippetsOn":true,"formatOnImportOn":true,"formattingProvider":"brittany","hieExecutablePath":"","useCustomHieWrapper":false,"useCustomHieWrapperPath":"","noLspParam":false,"showTypeForSelection":{"onHover":true,"command":{"location":"dropdown"}},"trace":{"server":"verbose"},"logFile":"","enableHIE":true}}}} 2020-02-04 20:00:12.3927065 [ThreadId 26] - ****** reactor: got message number:0 2020-02-04 20:00:12.3927065 [ThreadId 26] - ****** reactor: processing Initialized Notification 2020-02-04 20:00:12.3927065 [ThreadId 26] - ****** reactor: top of loop 2020-02-04 20:00:12.3927065 [ThreadId 26] - ****** reactor: got message number:1 2020-02-04 20:00:12.3927065 [ThreadId 26] - reactor:didChangeConfiguration notification:NotificationMessage {_jsonrpc = "2.0", _method = WorkspaceDidChangeConfiguration, _params = DidChangeConfigurationParams {_settings = Object (fromList [("languageServerHaskell",Object (fromList [("useCustomHieWrapper",Bool False),("useCustomHieWrapperPath",String ""),("logFile",String ""),("hlintOn",Bool True),("formatOnImportOn",Bool True),("noLspParam",Bool False),("hieExecutablePath",String ""),("enableHIE",Bool True),("liquidOn",Bool False),("showTypeForSelection",Object (fromList [("onHover",Bool True),("command",Object (fromList [("location",String "dropdown")]))])),("diagnosticsOnChange",Bool True),("completionSnippetsOn",Bool True),("maxNumberOfProblems",Number 100.0),("formattingProvider",String "brittany"),("trace",Object (fromList [("server",String "verbose")]))]))])}} 2020-02-04 20:00:12.3937058 [ThreadId 26] - reactor:didChangeConfiguration diagsOn:True 2020-02-04 20:00:12.3937058 [ThreadId 26] - ****** reactor: top of loop 2020-02-04 20:00:12.3937058 [ThreadId 4] - <--2--{"jsonrpc":"2.0","params":{"type":4,"message":"Using hie version: Version 1.0.0.0, Git revision 4bec07d79cf77c8ee855957d20e315a89f799d75 (dirty) (3745 commits) x86_64 ghc-8.6.5"},"method":"window/logMessage"} Using hie version: Version 1.0.0.0, Git revision 4bec07d79cf77c8ee855957d20e315a89f799d75 (dirty) (3745 commits) x86_64 ghc-8.6.5 2020-02-04 20:00:12.3937058 [ThreadId 3] - ---> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///c%3A/Users/flip111/haskell/cabal/cabal-install/Distribution/Client/ProjectPlanning.hs","languageId":"haskell","version":1,"text":"{-# LANGUAGE CPP, RecordWildCards, NamedFieldPuns, RankNTypes #-}\n{-# LANGUAGE ViewPatterns #-}\n{-# LANGUAGE TypeFamilies #-}\n{-# LANGUAGE NoMonoLocalBinds #-}\n{-# LANGUAGE DeriveDataTypeable #-}\n{-# LANGUAGE DeriveFunctor #-}\n\n-- | Planning how to build everything in a project.\n--\nmodule Distribution.Client.ProjectPlanning (\n -- * elaborated install plan types\n ElaboratedInstallPlan,\n ElaboratedConfiguredPackage(..),\n ElaboratedPlanPackage,\n ElaboratedSharedConfig(..),\n ElaboratedReadyPackage,\n BuildStyle(..),\n CabalFileText,\n\n -- * Producing the elaborated install plan\n rebuildProjectConfig,\n rebuildInstallPlan,\n\n -- * Build targets\n availableTargets,\n AvailableTarget(..),\n AvailableTargetStatus(..),\n TargetRequested(..),\n ComponentTarget(..),\n SubComponentTarget(..),\n showComponentTarget,\n nubComponentTargets,\n\n -- * Selecting a plan subset\n pruneInstallPlanToTargets,\n TargetAction(..),\n pruneInstallPlanToDependencies,\n CannotPruneDependencies(..),\n\n -- * Utils required for building\n pkgHasEphemeralBuildTargets,\n elabBuildTargetWholeComponents,\n\n -- * Setup.hs CLI flags for building\n setupHsScriptOptions,\n setupHsConfigureFlags,\n setupHsConfigureArgs,\n setupHsBuildFlags,\n setupHsBuildArgs,\n setupHsReplFlags,\n setupHsReplArgs,\n setupHsTestFlags,\n setupHsTestArgs,\n setupHsBenchFlags,\n setupHsBenchArgs,\n setupHsCopyFlags,\n setupHsRegisterFlags,\n setupHsHaddockFlags,\n setupHsHaddockArgs,\n\n packageHashInputs,\n\n -- * Path construction\n binDirectoryFor,\n binDirectories,\n storePackageInstallDirs,\n storePackageInstallDirs'\n ) where\n\nimport Prelude ()\nimport Distribution.Client.Compat.Prelude\n\nimport Distribution.Client.HashValue\nimport Distribution.Client.ProjectPlanning.Types as Ty\nimport Distribution.Client.PackageHash\nimport Distribution.Client.RebuildMonad\nimport Distribution.Client.Store\nimport Distribution.Client.ProjectConfig\nimport Distribution.Client.ProjectPlanOutput\n\nimport Distribution.Client.Types\nimport qualified Distribution.Client.InstallPlan as InstallPlan\nimport qualified Distribution.Client.SolverInstallPlan as SolverInstallPlan\nimport Distribution.Client.Dependency\nimport Distribution.Client.Dependency.Types\nimport qualified Distribution.Client.IndexUtils as IndexUtils\nimport Distribution.Client.Init (incVersion)\nimport Distribution.Client.Targets (userToPackageConstraint)\nimport Distribution.Client.DistDirLayout\nimport Distribution.Client.SetupWrapper\nimport Distribution.Client.JobControl\nimport Distribution.Client.FetchUtils\nimport Distribution.Client.Config\nimport qualified Hackage.Security.Client as Sec\nimport Distribution.Client.Setup hiding (packageName, cabalVersion)\nimport Distribution.Utils.NubList\nimport Distribution.Utils.LogProgress\nimport Distribution.Utils.MapAccum\n\nimport qualified Distribution.Solver.Types.ComponentDeps as CD\nimport Distribution.Solver.Types.ComponentDeps (ComponentDeps)\nimport Distribution.Solver.Types.ConstraintSource\nimport Distribution.Solver.Types.LabeledPackageConstraint\nimport Distribution.Solver.Types.OptionalStanza\nimport Distribution.Solver.Types.PkgConfigDb\nimport Distribution.Solver.Types.ResolverPackage\nimport Distribution.Solver.Types.SolverId\nimport Distribution.Solver.Types.SolverPackage\nimport Distribution.Solver.Types.InstSolverPackage\nimport Distribution.Solver.Types.SourcePackage\nimport Distribution.Solver.Types.Settings\n\nimport Distribution.ModuleName\nimport Distribution.Package\nimport Distribution.Types.AnnotatedId\nimport Distribution.Types.ComponentName\nimport Distribution.Types.LibraryName\nimport Distribution.Types.GivenComponent\n (GivenComponent(..))\nimport Distribution.Types.PackageVersionConstraint\nimport Distribution.Types.PkgconfigDependency\nimport Distribution.Types.UnqualComponentName\nimport Distribution.System\nimport qualified Distribution.PackageDescription as Cabal\nimport qualified Distribution.PackageDescription as PD\nimport qualified Distribution.PackageDescription.Configuration as PD\nimport Distribution.Simple.PackageIndex (InstalledPackageIndex)\nimport Distribution.Simple.Compiler hiding (Flag)\nimport qualified Distribution.Simple.GHC as GHC --TODO: [code cleanup] eliminate\nimport qualified Distribution.Simple.GHCJS as GHCJS --TODO: [code cleanup] eliminate\nimport Distribution.Simple.Program\nimport Distribution.Simple.Program.Db\nimport Distribution.Simple.Program.Find\nimport qualified Distribution.Simple.Setup as Cabal\nimport Distribution.Simple.Setup\n (Flag(..), toFlag, flagToMaybe, flagToList, fromFlagOrDefault)\nimport qualified Distribution.Simple.Configure as Cabal\nimport qualified Distribution.Simple.LocalBuildInfo as Cabal\nimport Distribution.Simple.LocalBuildInfo\n ( Component(..), pkgComponents, componentBuildInfo\n , componentName )\nimport qualified Distribution.Simple.InstallDirs as InstallDirs\nimport qualified Distribution.InstalledPackageInfo as IPI\n\nimport Distribution.Backpack.ConfiguredComponent\nimport Distribution.Backpack.LinkedComponent\nimport Distribution.Backpack.ComponentsGraph\nimport Distribution.Backpack.ModuleShape\nimport Distribution.Backpack.FullUnitId\nimport Distribution.Backpack\nimport Distribution.Types.ComponentInclude\n\nimport Distribution.Simple.Utils\nimport Distribution.Version\nimport Distribution.Verbosity\nimport Distribution.Deprecated.Text\n\nimport qualified Distribution.Compat.Graph as Graph\nimport Distribution.Compat.Graph(IsNode(..))\n\nimport Text.PrettyPrint hiding ((<>))\nimport qualified Text.PrettyPrint as Disp\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport Control.Monad\nimport qualified Data.Traversable as T\nimport Control.Monad.State as State\nimport Control.Exception\nimport Data.List (groupBy)\nimport qualified Data.List.NonEmpty as NE\nimport Data.Either\nimport Data.Function\nimport System.FilePath\n\n------------------------------------------------------------------------------\n-- * Elaborated install plan\n------------------------------------------------------------------------------\n\n-- \"Elaborated\" -- worked out with great care and nicety of detail;\n-- executed with great minuteness: elaborate preparations;\n-- elaborate care.\n--\n-- So here's the idea:\n--\n-- Rather than a miscellaneous collection of 'ConfigFlags', 'InstallFlags' etc\n-- all passed in as separate args and which are then further selected,\n-- transformed etc during the execution of the build. Instead we construct\n-- an elaborated install plan that includes everything we will need, and then\n-- during the execution of the plan we do as little transformation of this\n-- info as possible.\n--\n-- So we're trying to split the work into two phases: construction of the\n-- elaborated install plan (which as far as possible should be pure) and\n-- then simple execution of that plan without any smarts, just doing what the\n-- plan says to do.\n--\n-- So that means we need a representation of this fully elaborated install\n-- plan. The representation consists of two parts:\n--\n-- * A 'ElaboratedInstallPlan'. This is a 'GenericInstallPlan' with a\n-- representation of source packages that includes a lot more detail about\n-- that package's individual configuration\n--\n-- * A 'ElaboratedSharedConfig'. Some package configuration is the same for\n-- every package in a plan. Rather than duplicate that info every entry in\n-- the 'GenericInstallPlan' we keep that separately.\n--\n-- The division between the shared and per-package config is /not set in stone\n-- for all time/. For example if we wanted to generalise the install plan to\n-- describe a situation where we want to build some packages with GHC and some\n-- with GHCJS then the platform and compiler would no longer be shared between\n-- all packages but would have to be per-package (probably with some sanity\n-- condition on the graph structure).\n--\n\n-- Refer to ProjectPlanning.Types for details of these important types:\n\n-- type ElaboratedInstallPlan = ...\n-- type ElaboratedPlanPackage = ...\n-- data ElaboratedSharedConfig = ...\n-- data ElaboratedConfiguredPackage = ...\n-- data BuildStyle =\n\n\n-- | Check that an 'ElaboratedConfiguredPackage' actually makes\n-- sense under some 'ElaboratedSharedConfig'.\nsanityCheckElaboratedConfiguredPackage\n :: ElaboratedSharedConfig\n -> ElaboratedConfiguredPackage\n -> a\n -> a\nsanityCheckElaboratedConfiguredPackage sharedConfig\n elab@ElaboratedConfiguredPackage{..} =\n (case elabPkgOrComp of\n ElabPackage pkg -> sanityCheckElaboratedPackage elab pkg\n ElabComponent comp -> sanityCheckElaboratedComponent elab comp)\n\n -- either a package is being built inplace, or the\n -- 'installedPackageId' we assigned is consistent with\n -- the 'hashedInstalledPackageId' we would compute from\n -- the elaborated configured package\n . assert (elabBuildStyle == BuildInplaceOnly ||\n elabComponentId == hashedInstalledPackageId\n (packageHashInputs sharedConfig elab))\n\n -- the stanzas explicitly disabled should not be available\n . assert (Set.null (Map.keysSet (Map.filter not elabStanzasRequested)\n `Set.intersection` elabStanzasAvailable))\n\n -- either a package is built inplace, or we are not attempting to\n -- build any test suites or benchmarks (we never build these\n -- for remote packages!)\n . assert (elabBuildStyle == BuildInplaceOnly ||\n Set.null elabStanzasAvailable)\n\nsanityCheckElaboratedComponent\n :: ElaboratedConfiguredPackage\n -> ElaboratedComponent\n -> a\n -> a\nsanityCheckElaboratedComponent ElaboratedConfiguredPackage{..}\n ElaboratedComponent{..} =\n\n -- Should not be building bench or test if not inplace.\n assert (elabBuildStyle == BuildInplaceOnly ||\n case compComponentName of\n Nothing -> True\n Just (CLibName _) -> True\n Just (CExeName _) -> True\n -- This is interesting: there's no way to declare a dependency\n -- on a foreign library at the moment, but you may still want\n -- to install these to the store\n Just (CFLibName _) -> True\n Just (CBenchName _) -> False\n Just (CTestName _) -> False)\n\n\nsanityCheckElaboratedPackage\n :: ElaboratedConfiguredPackage\n -> ElaboratedPackage\n -> a\n -> a\nsanityCheckElaboratedPackage ElaboratedConfiguredPackage{..}\n ElaboratedPackage{..} =\n -- we should only have enabled stanzas that actually can be built\n -- (according to the solver)\n assert (pkgStanzasEnabled `Set.isSubsetOf` elabStanzasAvailable)\n\n -- the stanzas that the user explicitly requested should be\n -- enabled (by the previous test, they are also available)\n . assert (Map.keysSet (Map.filter id elabStanzasRequested)\n `Set.isSubsetOf` pkgStanzasEnabled)\n\n------------------------------------------------------------------------------\n-- * Deciding what to do: making an 'ElaboratedInstallPlan'\n------------------------------------------------------------------------------\n\n-- | Return the up-to-date project config and information about the local\n-- packages within the project.\n--\nrebuildProjectConfig :: Verbosity\n -> DistDirLayout\n -> ProjectConfig\n -> IO ( ProjectConfig\n , [PackageSpecifier UnresolvedSourcePackage] )\nrebuildProjectConfig verbosity\n distDirLayout@DistDirLayout {\n distProjectRootDirectory,\n distDirectory,\n distProjectCacheFile,\n distProjectCacheDirectory,\n distProjectFile\n }\n cliConfig = do\n\n fileMonitorProjectConfigKey <- do\n configPath <- getConfigFilePath projectConfigConfigFile\n return (configPath, distProjectFile \"\")\n\n (projectConfig, localPackages) <-\n runRebuild distProjectRootDirectory\n $ rerunIfChanged verbosity\n fileMonitorProjectConfig\n fileMonitorProjectConfigKey\n $ do\n liftIO $ info verbosity \"Project settings changed, reconfiguring...\"\n projectConfig <- phaseReadProjectConfig\n localPackages <- phaseReadLocalPackages projectConfig\n return (projectConfig, localPackages)\n\n info verbosity\n $ unlines\n $ (\"this build was affected by the following (project) config files:\" :)\n $ [ \"- \" ++ path\n | Explicit path <- Set.toList $ projectConfigProvenance projectConfig\n ]\n\n return (projectConfig <> cliConfig, localPackages)\n\n where\n\n ProjectConfigShared { projectConfigConfigFile } =\n projectConfigShared cliConfig\n\n fileMonitorProjectConfig =\n newFileMonitor (distProjectCacheFile \"config\") :: FileMonitor\n (FilePath, FilePath)\n (ProjectConfig, [PackageSpecifier UnresolvedSourcePackage])\n\n -- Read the cabal.project (or implicit config) and combine it with\n -- arguments from the command line\n --\n phaseReadProjectConfig :: Rebuild ProjectConfig\n phaseReadProjectConfig = do\n readProjectConfig verbosity projectConfigConfigFile distDirLayout\n\n -- Look for all the cabal packages in the project\n -- some of which may be local src dirs, tarballs etc\n --\n phaseReadLocalPackages :: ProjectConfig\n -> Rebuild [PackageSpecifier UnresolvedSourcePackage]\n phaseReadLocalPackages projectConfig@ProjectConfig {\n projectConfigShared,\n projectConfigBuildOnly\n } = do\n pkgLocations <- findProjectPackages distDirLayout projectConfig\n\n -- Create folder only if findProjectPackages did not throw a\n -- BadPackageLocations exception.\n liftIO $ do\n createDirectoryIfMissingVerbose verbosity True distDirectory\n createDirectoryIfMissingVerbose verbosity True distProjectCacheDirectory\n\n fetchAndReadSourcePackages verbosity distDirLayout\n projectConfigShared\n projectConfigBuildOnly\n pkgLocations\n\n\n-- | Return an up-to-date elaborated install plan.\n--\n-- Two variants of the install plan are returned: with and without packages\n-- from the store. That is, the \\\"improved\\\" plan where source packages are\n-- replaced by pre-existing installed packages from the store (when their ids\n-- match), and also the original elaborated plan which uses primarily source\n-- packages.\n\n-- The improved plan is what we use for building, but the original elaborated\n-- plan is useful for reporting and configuration. For example the @freeze@\n-- command needs the source package info to know about flag choices and\n-- dependencies of executables and setup scripts.\n--\nrebuildInstallPlan :: Verbosity\n -> DistDirLayout -> CabalDirLayout\n -> ProjectConfig\n -> [PackageSpecifier UnresolvedSourcePackage]\n -> IO ( ElaboratedInstallPlan -- with store packages\n , ElaboratedInstallPlan -- with source packages\n , ElaboratedSharedConfig )\n -- ^ @(improvedPlan, elaboratedPlan, _, _)@\nrebuildInstallPlan verbosity\n distDirLayout@DistDirLayout {\n distProjectRootDirectory,\n distProjectCacheFile\n }\n CabalDirLayout {\n cabalStoreDirLayout\n } = \\projectConfig localPackages ->\n runRebuild distProjectRootDirectory $ do\n progsearchpath <- liftIO $ getSystemSearchPath\n let projectConfigMonitored = projectConfig { projectConfigBuildOnly = mempty }\n\n -- The overall improved plan is cached\n rerunIfChanged verbosity fileMonitorImprovedPlan\n -- react to changes in the project config,\n -- the package .cabal files and the path\n (projectConfigMonitored, localPackages, progsearchpath) $ do\n\n -- And so is the elaborated plan that the improved plan based on\n (elaboratedPlan, elaboratedShared) <-\n rerunIfChanged verbosity fileMonitorElaboratedPlan\n (projectConfigMonitored, localPackages,\n progsearchpath) $ do\n\n compilerEtc <- phaseConfigureCompiler projectConfig\n _ <- phaseConfigurePrograms projectConfig compilerEtc\n (solverPlan, pkgConfigDB)\n <- phaseRunSolver projectConfig\n compilerEtc\n localPackages\n (elaboratedPlan,\n elaboratedShared) <- phaseElaboratePlan projectConfig\n compilerEtc pkgConfigDB\n solverPlan\n localPackages\n\n phaseMaintainPlanOutputs elaboratedPlan elaboratedShared\n return (elaboratedPlan, elaboratedShared)\n\n -- The improved plan changes each time we install something, whereas\n -- the underlying elaborated plan only changes when input config\n -- changes, so it's worth caching them separately.\n improvedPlan <- phaseImprovePlan elaboratedPlan elaboratedShared\n\n return (improvedPlan, elaboratedPlan, elaboratedShared)\n\n where\n fileMonitorCompiler = newFileMonitorInCacheDir \"compiler\"\n fileMonitorSolverPlan = newFileMonitorInCacheDir \"solver-plan\"\n fileMonitorSourceHashes = newFileMonitorInCacheDir \"source-hashes\"\n fileMonitorElaboratedPlan = newFileMonitorInCacheDir \"elaborated-plan\"\n fileMonitorImprovedPlan = newFileMonitorInCacheDir \"improved-plan\"\n\n newFileMonitorInCacheDir :: Eq a => FilePath -> FileMonitor a b\n newFileMonitorInCacheDir = newFileMonitor . distProjectCacheFile\n\n\n -- Configure the compiler we're using.\n --\n -- This is moderately expensive and doesn't change that often so we cache\n -- it independently.\n --\n phaseConfigureCompiler :: ProjectConfig\n -> Rebuild (Compiler, Platform, ProgramDb)\n phaseConfigureCompiler ProjectConfig {\n projectConfigShared = ProjectConfigShared {\n projectConfigHcFlavor,\n projectConfigHcPath,\n projectConfigHcPkg\n },\n projectConfigLocalPackages = PackageConfig {\n packageConfigProgramPaths,\n packageConfigProgramArgs,\n packageConfigProgramPathExtra\n }\n } = do\n progsearchpath <- liftIO $ getSystemSearchPath\n rerunIfChanged verbosity fileMonitorCompiler\n (hcFlavor, hcPath, hcPkg, progsearchpath,\n packageConfigProgramPaths,\n packageConfigProgramArgs,\n packageConfigProgramPathExtra) $ do\n\n liftIO $ info verbosity \"Compiler settings changed, reconfiguring...\"\n result@(_, _, progdb') <- liftIO $\n Cabal.configCompilerEx\n hcFlavor hcPath hcPkg\n progdb verbosity\n\n -- Note that we added the user-supplied program locations and args\n -- for /all/ programs, not just those for the compiler prog and\n -- compiler-related utils. In principle we don't know which programs\n -- the compiler will configure (and it does vary between compilers).\n -- We do know however that the compiler will only configure the\n -- programs it cares about, and those are the ones we monitor here.\n monitorFiles (programsMonitorFiles progdb')\n\n return result\n where\n hcFlavor = flagToMaybe projectConfigHcFlavor\n hcPath = flagToMaybe projectConfigHcPath\n hcPkg = flagToMaybe projectConfigHcPkg\n progdb =\n userSpecifyPaths (Map.toList (getMapLast packageConfigProgramPaths))\n . userSpecifyArgss (Map.toList (getMapMappend packageConfigProgramArgs))\n . modifyProgramSearchPath\n (++ [ ProgramSearchPathDir dir\n | dir <- fromNubList packageConfigProgramPathExtra ])\n $ defaultProgramDb\n\n\n -- Configuring other programs.\n --\n -- Having configred the compiler, now we configure all the remaining\n -- programs. This is to check we can find them, and to monitor them for\n -- changes.\n --\n -- TODO: [required eventually] we don't actually do this yet.\n --\n -- We rely on the fact that the previous phase added the program config for\n -- all local packages, but that all the programs configured so far are the\n -- compiler program or related util programs.\n --\n phaseConfigurePrograms :: ProjectConfig\n -> (Compiler, Platform, ProgramDb)\n -> Rebuild ()\n phaseConfigurePrograms projectConfig (_, _, compilerprogdb) = do\n -- Users are allowed to specify program locations independently for\n -- each package (e.g. to use a particular version of a pre-processor\n -- for some packages). However they cannot do this for the compiler\n -- itself as that's just not going to work. So we check for this.\n liftIO $ checkBadPerPackageCompilerPaths\n (configuredPrograms compilerprogdb)\n (getMapMappend (projectConfigSpecificPackage projectConfig))\n\n --TODO: [required eventually] find/configure other programs that the\n -- user specifies.\n\n --TODO: [required eventually] find/configure all build-tools\n -- but note that some of them may be built as part of the plan.\n\n\n -- Run the solver to get the initial install plan.\n -- This is expensive so we cache it independently.\n --\n phaseRunSolver :: ProjectConfig\n -> (Compiler, Platform, ProgramDb)\n -> [PackageSpecifier UnresolvedSourcePackage]\n -> Rebuild (SolverInstallPlan, PkgConfigDb)\n phaseRunSolver projectConfig@ProjectConfig {\n projectConfigShared,\n projectConfigBuildOnly\n }\n (compiler, platform, progdb)\n localPackages =\n rerunIfChanged verbosity fileMonitorSolverPlan\n (solverSettings,\n localPackages, localPackagesEnabledStanzas,\n compiler, platform, programDbSignature progdb) $ do\n\n installedPkgIndex <- getInstalledPackages verbosity\n compiler progdb platform\n corePackageDbs\n sourcePkgDb <- getSourcePackages verbosity withRepoCtx\n (solverSettingIndexState solverSettings)\n pkgConfigDB <- getPkgConfigDb verbosity progdb\n\n --TODO: [code cleanup] it'd be better if the Compiler contained the\n -- ConfiguredPrograms that it needs, rather than relying on the progdb\n -- since we don't need to depend on all the programs here, just the\n -- ones relevant for the compiler.\n\n liftIO $ do\n solver <- chooseSolver verbosity\n (solverSettingSolver solverSettings)\n (compilerInfo compiler)\n\n notice verbosity \"Resolving dependencies...\"\n plan <- foldProgress logMsg (die' verbosity) return $\n planPackages verbosity compiler platform solver solverSettings\n installedPkgIndex sourcePkgDb pkgConfigDB\n localPackages localPackagesEnabledStanzas\n return (plan, pkgConfigDB)\n where\n corePackageDbs = [GlobalPackageDB]\n withRepoCtx = projectConfigWithSolverRepoContext verbosity\n projectConfigShared\n projectConfigBuildOnly\n solverSettings = resolveSolverSettings projectConfig\n logMsg message rest = debugNoWrap verbosity message >> rest\n\n localPackagesEnabledStanzas =\n Map.fromList\n [ (pkgname, stanzas)\n | pkg <- localPackages\n , let pkgname = pkgSpecifierTarget pkg\n testsEnabled = lookupLocalPackageConfig\n packageConfigTests\n projectConfig pkgname\n benchmarksEnabled = lookupLocalPackageConfig\n packageConfigBenchmarks\n projectConfig pkgname\n stanzas =\n Map.fromList $\n [ (TestStanzas, enabled)\n | enabled <- flagToList testsEnabled ]\n ++ [ (BenchStanzas , enabled)\n | enabled <- flagToList benchmarksEnabled ]\n ]\n\n -- Elaborate the solver's install plan to get a fully detailed plan. This\n -- version of the plan has the final nix-style hashed ids.\n --\n phaseElaboratePlan :: ProjectConfig\n -> (Compiler, Platform, ProgramDb)\n -> PkgConfigDb\n -> SolverInstallPlan\n -> [PackageSpecifier (SourcePackage (PackageLocation loc))]\n -> Rebuild ( ElaboratedInstallPlan\n , ElaboratedSharedConfig )\n phaseElaboratePlan ProjectConfig {\n projectConfigShared,\n projectConfigAllPackages,\n projectConfigLocalPackages,\n projectConfigSpecificPackage,\n projectConfigBuildOnly\n }\n (compiler, platform, progdb) pkgConfigDB\n solverPlan localPackages = do\n\n liftIO $ debug verbosity \"Elaborating the install plan...\"\n\n sourcePackageHashes <-\n rerunIfChanged verbosity fileMonitorSourceHashes\n (packageLocationsSignature solverPlan) $\n getPackageSourceHashes verbosity withRepoCtx solverPlan\n\n defaultInstallDirs <- liftIO $ userInstallDirTemplates compiler\n (elaboratedPlan, elaboratedShared)\n <- liftIO . runLogProgress verbosity $\n elaborateInstallPlan\n verbosity\n platform compiler progdb pkgConfigDB\n distDirLayout\n cabalStoreDirLayout\n solverPlan\n localPackages\n sourcePackageHashes\n defaultInstallDirs\n projectConfigShared\n projectConfigAllPackages\n projectConfigLocalPackages\n (getMapMappend projectConfigSpecificPackage)\n let instantiatedPlan\n = instantiateInstallPlan\n cabalStoreDirLayout\n defaultInstallDirs\n elaboratedShared\n elaboratedPlan\n liftIO $ debugNoWrap verbosity (InstallPlan.showInstallPlan instantiatedPlan)\n return (instantiatedPlan, elaboratedShared)\n where\n withRepoCtx = projectConfigWithSolverRepoContext verbosity\n projectConfigShared\n projectConfigBuildOnly\n\n -- Update the files we maintain that reflect our current build environment.\n -- In particular we maintain a JSON representation of the elaborated\n -- install plan (but not the improved plan since that reflects the state\n -- of the build rather than just the input environment).\n --\n phaseMaintainPlanOutputs :: ElaboratedInstallPlan\n -> ElaboratedSharedConfig\n -> Rebuild ()\n phaseMaintainPlanOutputs elaboratedPlan elaboratedShared = liftIO $ do\n debug verbosity \"Updating plan.json\"\n writePlanExternalRepresentation\n distDirLayout\n elaboratedPlan\n elaboratedShared\n\n\n -- Improve the elaborated install plan. The elaborated plan consists\n -- mostly of source packages (with full nix-style hashed ids). Where\n -- corresponding installed packages already exist in the store, replace\n -- them in the plan.\n --\n -- Note that we do monitor the store's package db here, so we will redo\n -- this improvement phase when the db changes -- including as a result of\n -- executing a plan and installing things.\n --\n phaseImprovePlan :: ElaboratedInstallPlan\n -> ElaboratedSharedConfig\n -> Rebuild ElaboratedInstallPlan\n phaseImprovePlan elaboratedPlan elaboratedShared = do\n\n liftIO $ debug verbosity \"Improving the install plan...\"\n storePkgIdSet <- getStoreEntries cabalStoreDirLayout compid\n let improvedPlan = improveInstallPlanWithInstalledPackages\n storePkgIdSet\n elaboratedPlan\n liftIO $ debugNoWrap verbosity (InstallPlan.showInstallPlan improvedPlan)\n -- TODO: [nice to have] having checked which packages from the store\n -- we're using, it may be sensible to sanity check those packages\n -- by loading up the compiler package db and checking everything\n -- matches up as expected, e.g. no dangling deps, files deleted.\n return improvedPlan\n where\n compid = compilerId (pkgConfigCompiler elaboratedShared)\n\n\nprogramsMonitorFiles :: ProgramDb -> [MonitorFilePath]\nprogramsMonitorFiles progdb =\n [ monitor\n | prog <- configuredPrograms progdb\n , monitor <- monitorFileSearchPath (programMonitorFiles prog)\n (programPath prog)\n ]\n\n-- | Select the bits of a 'ProgramDb' to monitor for value changes.\n-- Use 'programsMonitorFiles' for the files to monitor.\n--\nprogramDbSignature :: ProgramDb -> [ConfiguredProgram]\nprogramDbSignature progdb =\n [ prog { programMonitorFiles = []\n , programOverrideEnv = filter ((/=\"PATH\") . fst)\n (programOverrideEnv prog) }\n | prog <- configuredPrograms progdb ]\n\ngetInstalledPackages :: Verbosity\n -> Compiler -> ProgramDb -> Platform\n -> PackageDBStack\n -> Rebuild InstalledPackageIndex\ngetInstalledPackages verbosity compiler progdb platform packagedbs = do\n monitorFiles . map monitorFileOrDirectory\n =<< liftIO (IndexUtils.getInstalledPackagesMonitorFiles\n verbosity compiler\n packagedbs progdb platform)\n liftIO $ IndexUtils.getInstalledPackages\n verbosity compiler\n packagedbs progdb\n\n{-\n--TODO: [nice to have] use this but for sanity / consistency checking\ngetPackageDBContents :: Verbosity\n -> Compiler -> ProgramDb -> Platform\n -> PackageDB\n -> Rebuild InstalledPackageIndex\ngetPackageDBContents verbosity compiler progdb platform packagedb = do\n monitorFiles . map monitorFileOrDirectory\n =<< liftIO (IndexUtils.getInstalledPackagesMonitorFiles\n verbosity compiler\n [packagedb] progdb platform)\n liftIO $ do\n createPackageDBIfMissing verbosity compiler progdb packagedb\n Cabal.getPackageDBContents verbosity compiler\n packagedb progdb\n-}\n\ngetSourcePackages :: Verbosity -> (forall a. (RepoContext -> IO a) -> IO a)\n -> Maybe IndexUtils.IndexState -> Rebuild SourcePackageDb\ngetSourcePackages verbosity withRepoCtx idxState = do\n (sourcePkgDb, repos) <-\n liftIO $\n withRepoCtx $ \\repoctx -> do\n sourcePkgDb <- IndexUtils.getSourcePackagesAtIndexState verbosity\n repoctx idxState\n return (sourcePkgDb, repoContextRepos repoctx)\n\n mapM_ needIfExists\n . IndexUtils.getSourcePackagesMonitorFiles\n $ repos\n return sourcePkgDb\n\n\ngetPkgConfigDb :: Verbosity -> ProgramDb -> Rebuild PkgConfigDb\ngetPkgConfigDb verbosity progdb = do\n dirs <- liftIO $ getPkgConfigDbDirs verbosity progdb\n -- Just monitor the dirs so we'll notice new .pc files.\n -- Alternatively we could monitor all the .pc files too.\n mapM_ monitorDirectoryStatus dirs\n liftIO $ readPkgConfigDb verbosity progdb\n\n\n-- | Select the config values to monitor for changes package source hashes.\npackageLocationsSignature :: SolverInstallPlan\n -> [(PackageId, PackageLocation (Maybe FilePath))]\npackageLocationsSignature solverPlan =\n [ (packageId pkg, packageSource pkg)\n | SolverInstallPlan.Configured (SolverPackage { solverPkgSource = pkg})\n <- SolverInstallPlan.toList solverPlan\n ]\n\n\n-- | Get the 'HashValue' for all the source packages where we use hashes,\n-- and download any packages required to do so.\n--\n-- Note that we don't get hashes for local unpacked packages.\n--\ngetPackageSourceHashes :: Verbosity\n -> (forall a. (RepoContext -> IO a) -> IO a)\n -> SolverInstallPlan\n -> Rebuild (Map PackageId PackageSourceHash)\ngetPackageSourceHashes verbosity withRepoCtx solverPlan = do\n\n -- Determine if and where to get the package's source hash from.\n --\n let allPkgLocations :: [(PackageId, PackageLocation (Maybe FilePath))]\n allPkgLocations =\n [ (packageId pkg, packageSource pkg)\n | SolverInstallPlan.Configured (SolverPackage { solverPkgSource = pkg})\n <- SolverInstallPlan.toList solverPlan ]\n\n -- Tarballs that were local in the first place.\n -- We'll hash these tarball files directly.\n localTarballPkgs :: [(PackageId, FilePath)]\n localTarballPkgs =\n [ (pkgid, tarball)\n | (pkgid, LocalTarballPackage tarball) <- allPkgLocations ]\n\n -- Tarballs from remote URLs. We must have downloaded these already\n -- (since we extracted the .cabal file earlier)\n --TODO: [required eventually] finish remote tarball functionality\n-- allRemoteTarballPkgs =\n-- [ (pkgid, )\n-- | (pkgid, RemoteTarballPackage ) <- allPkgLocations ]\n\n -- Tarballs from repositories, either where the repository provides\n -- hashes as part of the repo metadata, or where we will have to\n -- download and hash the tarball.\n repoTarballPkgsWithMetadata :: [(PackageId, Repo)]\n repoTarballPkgsWithoutMetadata :: [(PackageId, Repo)]\n (repoTarballPkgsWithMetadata,\n repoTarballPkgsWithoutMetadata) =\n partitionEithers\n [ case repo of\n RepoSecure{} -> Left (pkgid, repo)\n _ -> Right (pkgid, repo)\n | (pkgid, RepoTarballPackage repo _ _) <- allPkgLocations ]\n\n -- For tarballs from repos that do not have hashes available we now have\n -- to check if the packages were downloaded already.\n --\n (repoTarballPkgsToDownload,\n repoTarballPkgsDownloaded)\n <- fmap partitionEithers $\n liftIO $ sequence\n [ do mtarball <- checkRepoTarballFetched repo pkgid\n case mtarball of\n Nothing -> return (Left (pkgid, repo))\n Just tarball -> return (Right (pkgid, tarball))\n | (pkgid, repo) <- repoTarballPkgsWithoutMetadata ]\n\n (hashesFromRepoMetadata,\n repoTarballPkgsNewlyDownloaded) <-\n -- Avoid having to initialise the repository (ie 'withRepoCtx') if we\n -- don't have to. (The main cost is configuring the http client.)\n if null repoTarballPkgsToDownload && null repoTarballPkgsWithMetadata\n then return (Map.empty, [])\n else liftIO $ withRepoCtx $ \\repoctx -> do\n\n -- For tarballs from repos that do have hashes available as part of the\n -- repo metadata we now load up the index for each repo and retrieve\n -- the hashes for the packages\n --\n hashesFromRepoMetadata <-\n Sec.uncheckClientErrors $ --TODO: [code cleanup] wrap in our own exceptions\n fmap (Map.fromList . concat) $\n sequence\n -- Reading the repo index is expensive so we group the packages by repo\n [ repoContextWithSecureRepo repoctx repo $ \\secureRepo ->\n Sec.withIndex secureRepo $ \\repoIndex ->\n sequence\n [ do hash <- Sec.trusted <$> -- strip off Trusted tag\n Sec.indexLookupHash repoIndex pkgid\n -- Note that hackage-security currently uses SHA256\n -- but this API could in principle give us some other\n -- choice in future.\n return (pkgid, hashFromTUF hash)\n | pkgid <- pkgids ]\n | (repo, pkgids) <-\n map (\\grp@((_,repo):|_) -> (repo, map fst (NE.toList grp)))\n . NE.groupBy ((==) `on` (remoteRepoName . repoRemote . snd))\n . sortBy (compare `on` (remoteRepoName . repoRemote . snd))\n $ repoTarballPkgsWithMetadata\n ]\n\n -- For tarballs from repos that do not have hashes available, download\n -- the ones we previously determined we need.\n --\n repoTarballPkgsNewlyDownloaded <-\n sequence\n [ do tarball <- fetchRepoTarball verbosity repoctx repo pkgid\n return (pkgid, tarball)\n | (pkgid, repo) <- repoTarballPkgsToDownload ]\n\n return (hashesFromRepoMetadata,\n repoTarballPkgsNewlyDownloaded)\n\n -- Hash tarball files for packages where we have to do that. This includes\n -- tarballs that were local in the first place, plus tarballs from repos,\n -- either previously cached or freshly downloaded.\n --\n let allTarballFilePkgs :: [(PackageId, FilePath)]\n allTarballFilePkgs = localTarballPkgs\n ++ repoTarballPkgsDownloaded\n ++ repoTarballPkgsNewlyDownloaded\n hashesFromTarballFiles <- liftIO $\n fmap Map.fromList $\n sequence\n [ do srchash <- readFileHashValue tarball\n return (pkgid, srchash)\n | (pkgid, tarball) <- allTarballFilePkgs\n ]\n monitorFiles [ monitorFile tarball\n | (_pkgid, tarball) <- allTarballFilePkgs ]\n\n -- Return the combination\n return $! hashesFromRepoMetadata\n <> hashesFromTarballFiles\n\n\n-- ------------------------------------------------------------\n-- * Installation planning\n-- ------------------------------------------------------------\n\nplanPackages :: Verbosity\n -> Compiler\n -> Platform\n -> Solver -> SolverSettings\n -> InstalledPackageIndex\n -> SourcePackageDb\n -> PkgConfigDb\n -> [PackageSpecifier UnresolvedSourcePackage]\n -> Map PackageName (Map OptionalStanza Bool)\n -> Progress String String SolverInstallPlan\nplanPackages verbosity comp platform solver SolverSettings{..}\n installedPkgIndex sourcePkgDb pkgConfigDB\n localPackages pkgStanzasEnable =\n\n resolveDependencies\n platform (compilerInfo comp)\n pkgConfigDB solver\n resolverParams\n\n where\n\n --TODO: [nice to have] disable multiple instances restriction in\n -- the solver, but then make sure we can cope with that in the\n -- output.\n resolverParams =\n\n setMaxBackjumps solverSettingMaxBackjumps\n\n . setIndependentGoals solverSettingIndependentGoals\n\n . setReorderGoals solverSettingReorderGoals\n\n . setCountConflicts solverSettingCountConflicts\n\n . setFineGrainedConflicts solverSettingFineGrainedConflicts\n\n . setMinimizeConflictSet solverSettingMinimizeConflictSet\n\n --TODO: [required eventually] should only be configurable for\n --custom installs\n -- . setAvoidReinstalls solverSettingAvoidReinstalls\n\n --TODO: [required eventually] should only be configurable for\n --custom installs\n -- . setShadowPkgs solverSettingShadowPkgs\n\n . setStrongFlags solverSettingStrongFlags\n\n . setAllowBootLibInstalls solverSettingAllowBootLibInstalls\n\n . setOnlyConstrained solverSettingOnlyConstrained\n\n . setSolverVerbosity verbosity\n\n --TODO: [required eventually] decide if we need to prefer\n -- installed for global packages, or prefer latest even for\n -- global packages. Perhaps should be configurable but with a\n -- different name than \"upgrade-dependencies\".\n . setPreferenceDefault PreferLatestForSelected\n {-(if solverSettingUpgradeDeps\n then PreferAllLatest\n else PreferLatestForSelected)-}\n\n . removeLowerBounds solverSettingAllowOlder\n . removeUpperBounds solverSettingAllowNewer\n\n . addDefaultSetupDependencies (defaultSetupDeps comp platform\n . PD.packageDescription\n . packageDescription)\n\n . addSetupCabalMinVersionConstraint setupMinCabalVersionConstraint\n . addSetupCabalMaxVersionConstraint setupMaxCabalVersionConstraint\n\n . addPreferences\n -- preferences from the config file or command line\n [ PackageVersionPreference name ver\n | PackageVersionConstraint name ver <- solverSettingPreferences ]\n\n . addConstraints\n -- version constraints from the config file or command line\n [ LabeledPackageConstraint (userToPackageConstraint pc) src\n | (pc, src) <- solverSettingConstraints ]\n\n . addPreferences\n -- enable stanza preference where the user did not specify\n [ PackageStanzasPreference pkgname stanzas\n | pkg <- localPackages\n , let pkgname = pkgSpecifierTarget pkg\n stanzaM = Map.findWithDefault Map.empty pkgname pkgStanzasEnable\n stanzas = [ stanza | stanza <- [minBound..maxBound]\n , Map.lookup stanza stanzaM == Nothing ]\n , not (null stanzas)\n ]\n\n . addConstraints\n -- enable stanza constraints where the user asked to enable\n [ LabeledPackageConstraint\n (PackageConstraint (scopeToplevel pkgname)\n (PackagePropertyStanzas stanzas))\n ConstraintSourceConfigFlagOrTarget\n | pkg <- localPackages\n , let pkgname = pkgSpecifierTarget pkg\n stanzaM = Map.findWithDefault Map.empty pkgname pkgStanzasEnable\n stanzas = [ stanza | stanza <- [minBound..maxBound]\n , Map.lookup stanza stanzaM == Just True ]\n , not (null stanzas)\n ]\n\n . addConstraints\n --TODO: [nice to have] should have checked at some point that the\n -- package in question actually has these flags.\n [ LabeledPackageConstraint\n (PackageConstraint (scopeToplevel pkgname)\n (PackagePropertyFlags flags))\n ConstraintSourceConfigFlagOrTarget\n | (pkgname, flags) <- Map.toList solverSettingFlagAssignments ]\n\n . addConstraints\n --TODO: [nice to have] we have user-supplied flags for unspecified\n -- local packages (as well as specific per-package flags). For the\n -- former we just apply all these flags to all local targets which\n -- is silly. We should check if the flags are appropriate.\n [ LabeledPackageConstraint\n (PackageConstraint (scopeToplevel pkgname)\n (PackagePropertyFlags flags))\n ConstraintSourceConfigFlagOrTarget\n | let flags = solverSettingFlagAssignment\n , not (PD.nullFlagAssignment flags)\n , pkg <- localPackages\n , let pkgname = pkgSpecifierTarget pkg ]\n\n $ stdResolverParams\n\n stdResolverParams =\n -- Note: we don't use the standardInstallPolicy here, since that uses\n -- its own addDefaultSetupDependencies that is not appropriate for us.\n basicInstallPolicy\n installedPkgIndex sourcePkgDb\n localPackages\n\n -- While we can talk to older Cabal versions (we need to be able to\n -- do so for custom Setup scripts that require older Cabal lib\n -- versions), we have problems talking to some older versions that\n -- don't support certain features.\n --\n -- For example, Cabal-1.16 and older do not know about build targets.\n -- Even worse, 1.18 and older only supported the --constraint flag\n -- with source package ids, not --dependency with installed package\n -- ids. That is bad because we cannot reliably select the right\n -- dependencies in the presence of multiple instances (i.e. the\n -- store). See issue #3932. So we require Cabal 1.20 as a minimum.\n --\n -- Moreover, lib:Cabal generally only supports the interface of\n -- current and past compilers; in fact recent lib:Cabal versions\n -- will warn when they encounter a too new or unknown GHC compiler\n -- version (c.f. #415). To avoid running into unsupported\n -- configurations we encode the compatibility matrix as lower\n -- bounds on lib:Cabal here (effectively corresponding to the\n -- respective major Cabal version bundled with the respective GHC\n -- release).\n --\n -- GHC 8.8 needs Cabal >= 3.0\n -- GHC 8.6 needs Cabal >= 2.4\n -- GHC 8.4 needs Cabal >= 2.2\n -- GHC 8.2 needs Cabal >= 2.0\n -- GHC 8.0 needs Cabal >= 1.24\n -- GHC 7.10 needs Cabal >= 1.22\n --\n -- (NB: we don't need to consider older GHCs as Cabal >= 1.20 is\n -- the absolute lower bound)\n --\n -- TODO: long-term, this compatibility matrix should be\n -- stored as a field inside 'Distribution.Compiler.Compiler'\n setupMinCabalVersionConstraint\n | isGHC, compVer >= mkVersion [8,10] = mkVersion [3,2]\n | isGHC, compVer >= mkVersion [8,8] = mkVersion [3,0]\n | isGHC, compVer >= mkVersion [8,6] = mkVersion [2,4]\n | isGHC, compVer >= mkVersion [8,4] = mkVersion [2,2]\n | isGHC, compVer >= mkVersion [8,2] = mkVersion [2,0]\n | isGHC, compVer >= mkVersion [8,0] = mkVersion [1,24]\n | isGHC, compVer >= mkVersion [7,10] = mkVersion [1,22]\n | otherwise = mkVersion [1,20]\n where\n isGHC = compFlav `elem` [GHC,GHCJS]\n compFlav = compilerFlavor comp\n compVer = compilerVersion comp\n\n -- As we can't predict the future, we also place a global upper\n -- bound on the lib:Cabal version we know how to interact with:\n --\n -- The upper bound is computed by incrementing the current major\n -- version twice in order to allow for the current version, as\n -- well as the next adjacent major version (one of which will not\n -- be released, as only \"even major\" versions of Cabal are\n -- released to Hackage or bundled with proper GHC releases).\n --\n -- For instance, if the current version of cabal-install is an odd\n -- development version, e.g. Cabal-2.1.0.0, then we impose an\n -- upper bound `setup.Cabal < 2.3`; if `cabal-install` is on a\n -- stable/release even version, e.g. Cabal-2.2.1.0, the upper\n -- bound is `setup.Cabal < 2.4`. This gives us enough flexibility\n -- when dealing with development snapshots of Cabal and cabal-install.\n --\n setupMaxCabalVersionConstraint =\n alterVersion (take 2) $ incVersion 1 $ incVersion 1 cabalVersion\n\n------------------------------------------------------------------------------\n-- * Install plan post-processing\n------------------------------------------------------------------------------\n\n-- This phase goes from the InstallPlan we get from the solver and has to\n-- make an elaborated install plan.\n--\n-- We go in two steps:\n--\n-- 1. elaborate all the source packages that the solver has chosen.\n-- 2. swap source packages for pre-existing installed packages wherever\n-- possible.\n--\n-- We do it in this order, elaborating and then replacing, because the easiest\n-- way to calculate the installed package ids used for the replacement step is\n-- from the elaborated configuration for each package.\n\n\n\n\n------------------------------------------------------------------------------\n-- * Install plan elaboration\n------------------------------------------------------------------------------\n\n-- Note [SolverId to ConfiguredId]\n-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n-- Dependency solving is a per package affair, so after we're done, we\n-- end up with 'SolverInstallPlan' that records in 'solverPkgLibDeps'\n-- and 'solverPkgExeDeps' what packages provide the libraries and executables\n-- needed by each component of the package (phew!) For example, if I have\n--\n-- library\n-- build-depends: lib\n-- build-tool-depends: pkg:exe1\n-- build-tools: alex\n--\n-- After dependency solving, I find out that this library component has\n-- library dependencies on lib-0.2, and executable dependencies on pkg-0.1\n-- and alex-0.3 (other components of the package may have different\n-- dependencies). Note that I've \"lost\" the knowledge that I depend\n-- *specifically* on the exe1 executable from pkg.\n--\n-- So, we have a this graph of packages, and we need to transform it into\n-- a graph of components which we are actually going to build. In particular:\n--\n-- NODE changes from PACKAGE (SolverPackage) to COMPONENTS (ElaboratedConfiguredPackage)\n-- EDGE changes from PACKAGE DEP (SolverId) to COMPONENT DEPS (ConfiguredId)\n--\n-- In both cases, what was previously a single node/edge may turn into multiple\n-- nodes/edges. Multiple components, because there may be multiple components\n-- in a package; multiple component deps, because we may depend upon multiple\n-- executables from the same package (and maybe, some day, multiple libraries\n-- from the same package.)\n--\n-- Let's talk about how to do this transformation. Naively, we might consider\n-- just processing each package, converting it into (zero or) one or more\n-- components. But we also have to update the edges; this leads to\n-- two complications:\n--\n-- 1. We don't know what the ConfiguredId of a component is until\n-- we've configured it, but we cannot configure a component unless\n-- we know the ConfiguredId of all its dependencies. Thus, we must\n-- process the 'SolverInstallPlan' in topological order.\n--\n-- 2. When we process a package, we know the SolverIds of its\n-- dependencies, but we have to do some work to turn these into\n-- ConfiguredIds. For example, in the case of build-tool-depends, the\n-- SolverId isn't enough to uniquely determine the ConfiguredId we should\n-- elaborate to: we have to look at the executable name attached to\n-- the package name in the package description to figure it out.\n-- At the same time, we NEED to use the SolverId, because there might\n-- be multiple versions of the same package in the build plan\n-- (due to setup dependencies); we can't just look up the package name\n-- from the package description.\n--\n-- We can adopt the following strategy:\n--\n-- * When a package is transformed into components, record\n-- a mapping from SolverId to ALL of the components\n-- which were elaborated.\n--\n-- * When we look up an edge, we use our knowledge of the\n-- component name to *filter* the list of components into\n-- the ones we actually wanted to refer to.\n--\n-- By the way, we can tell that SolverInstallPlan is not the \"right\" type\n-- because a SolverId cannot adequately represent all possible dependency\n-- solver states: we may need to record foo-0.1 multiple times in\n-- the solver install plan with different dependencies. This imprecision in the\n-- type currently doesn't cause any problems because the dependency solver\n-- continues to enforce the single instance restriction regardless of compiler\n-- version. The right way to solve this is to come up with something very much\n-- like a 'ConfiguredId', in that it incorporates the version choices of its\n-- dependencies, but less fine grained.\n\n\n-- | Produce an elaborated install plan using the policy for local builds with\n-- a nix-style shared store.\n--\n-- In theory should be able to make an elaborated install plan with a policy\n-- matching that of the classic @cabal install --user@ or @--global@\n--\nelaborateInstallPlan\n :: Verbosity -> Platform -> Compiler -> ProgramDb -> PkgConfigDb\n -> DistDirLayout\n -> StoreDirLayout\n -> SolverInstallPlan\n -> [PackageSpecifier (SourcePackage (PackageLocation loc))]\n -> Map PackageId PackageSourceHash\n -> InstallDirs.InstallDirTemplates\n -> ProjectConfigShared\n -> PackageConfig\n -> PackageConfig\n -> Map PackageName PackageConfig\n -> LogProgress (ElaboratedInstallPlan, ElaboratedSharedConfig)\nelaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB\n distDirLayout@DistDirLayout{..}\n storeDirLayout@StoreDirLayout{storePackageDBStack}\n solverPlan localPackages\n sourcePackageHashes\n defaultInstallDirs\n sharedPackageConfig\n allPackagesConfig\n localPackagesConfig\n perPackageConfig = do\n x <- elaboratedInstallPlan\n return (x, elaboratedSharedConfig)\n where\n elaboratedSharedConfig =\n ElaboratedSharedConfig {\n pkgConfigPlatform = platform,\n pkgConfigCompiler = compiler,\n pkgConfigCompilerProgs = compilerprogdb,\n pkgConfigReplOptions = []\n }\n\n preexistingInstantiatedPkgs =\n Map.fromList (mapMaybe f (SolverInstallPlan.toList solverPlan))\n where\n f (SolverInstallPlan.PreExisting inst)\n | let ipkg = instSolverPkgIPI inst\n , not (IPI.indefinite ipkg)\n = Just (IPI.installedUnitId ipkg,\n (FullUnitId (IPI.installedComponentId ipkg)\n (Map.fromList (IPI.instantiatedWith ipkg))))\n f _ = Nothing\n\n elaboratedInstallPlan =\n flip InstallPlan.fromSolverInstallPlanWithProgress solverPlan $ \\mapDep planpkg ->\n case planpkg of\n SolverInstallPlan.PreExisting pkg ->\n return [InstallPlan.PreExisting (instSolverPkgIPI pkg)]\n\n SolverInstallPlan.Configured pkg ->\n let inplace_doc | shouldBuildInplaceOnly pkg = text \"inplace\"\n | otherwise = Disp.empty\n in addProgressCtx (text \"In the\" <+> inplace_doc <+> text \"package\" <+>\n quotes (disp (packageId pkg))) $\n map InstallPlan.Configured <$> elaborateSolverToComponents mapDep pkg\n\n -- NB: We don't INSTANTIATE packages at this point. That's\n -- a post-pass. This makes it simpler to compute dependencies.\n elaborateSolverToComponents\n :: (SolverId -> [ElaboratedPlanPackage])\n -> SolverPackage UnresolvedPkgLoc\n -> LogProgress [ElaboratedConfiguredPackage]\n elaborateSolverToComponents mapDep spkg@(SolverPackage _ _ _ deps0 exe_deps0)\n = case mkComponentsGraph (elabEnabledSpec elab0) pd of\n Right g -> do\n let src_comps = componentsGraphToList g\n infoProgress $ hang (text \"Component graph for\" <+> disp pkgid <<>> colon)\n 4 (dispComponentsWithDeps src_comps)\n (_, comps) <- mapAccumM buildComponent\n (Map.empty, Map.empty, Map.empty)\n (map fst src_comps)\n let not_per_component_reasons = why_not_per_component src_comps\n if null not_per_component_reasons\n then return comps\n else do checkPerPackageOk comps not_per_component_reasons\n return [elaborateSolverToPackage spkg g $\n comps ++ maybeToList setupComponent]\n Left cns ->\n dieProgress $\n hang (text \"Dependency cycle between the following components:\") 4\n (vcat (map (text . componentNameStanza) cns))\n where\n -- You are eligible to per-component build if this list is empty\n why_not_per_component g\n = cuz_buildtype ++ cuz_spec ++ cuz_length ++ cuz_flag ++ cuz_coverage\n where\n cuz reason = [text reason]\n -- We have to disable per-component for now with\n -- Configure-type scripts in order to prevent parallel\n -- invocation of the same `./configure` script.\n -- See https://github.com/haskell/cabal/issues/4548\n --\n -- Moreoever, at this point in time, only non-Custom setup scripts\n -- are supported. Implementing per-component builds with\n -- Custom would require us to create a new 'ElabSetup'\n -- type, and teach all of the code paths how to handle it.\n -- Once you've implemented this, swap it for the code below.\n cuz_buildtype =\n case PD.buildType (elabPkgDescription elab0) of\n PD.Configure -> cuz \"build-type is Configure\"\n PD.Custom -> cuz \"build-type is Custom\"\n _ -> []\n -- cabal-format versions prior to 1.8 have different build-depends semantics\n -- for now it's easier to just fallback to legacy-mode when specVersion < 1.8\n -- see, https://github.com/haskell/cabal/issues/4121\n cuz_spec\n | PD.specVersion pd >= mkVersion [1,8] = []\n | otherwise = cuz \"cabal-version is less than 1.8\"\n -- In the odd corner case that a package has no components at all\n -- then keep it as a whole package, since otherwise it turns into\n -- 0 component graph nodes and effectively vanishes. We want to\n -- keep it around at least for error reporting purposes.\n cuz_length\n | length g > 0 = []\n | otherwise = cuz \"there are no buildable components\"\n -- For ease of testing, we let per-component builds be toggled\n -- at the top level\n cuz_flag\n | fromFlagOrDefault True (projectConfigPerComponent sharedPackageConfig)\n = []\n | otherwise = cuz \"you passed --disable-per-component\"\n -- Enabling program coverage introduces odd runtime dependencies\n -- between components.\n cuz_coverage\n | fromFlagOrDefault False (packageConfigCoverage localPackagesConfig)\n = cuz \"program coverage is enabled\"\n | otherwise = []\n\n -- | Sometimes a package may make use of features which are only\n -- supported in per-package mode. If this is the case, we should\n -- give an error when this occurs.\n checkPerPackageOk comps reasons = do\n let is_sublib (CLibName (LSubLibName _)) = True\n is_sublib _ = False\n when (any (matchElabPkg is_sublib) comps) $\n dieProgress $\n text \"Internal libraries only supported with per-component builds.\" $$\n text \"Per-component builds were disabled because\" <+>\n fsep (punctuate comma reasons)\n -- TODO: Maybe exclude Backpack too\n\n elab0 = elaborateSolverToCommon spkg\n pkgid = elabPkgSourceId elab0\n pd = elabPkgDescription elab0\n\n -- TODO: This is just a skeleton to get elaborateSolverToPackage\n -- working correctly\n -- TODO: When we actually support building these components, we\n -- have to add dependencies on this from all other components\n setupComponent :: Maybe ElaboratedConfiguredPackage\n setupComponent\n | PD.buildType (elabPkgDescription elab0) == PD.Custom\n = Just elab0 {\n elabModuleShape = emptyModuleShape,\n elabUnitId = notImpl \"elabUnitId\",\n elabComponentId = notImpl \"elabComponentId\",\n elabLinkedInstantiatedWith = Map.empty,\n elabInstallDirs = notImpl \"elabInstallDirs\",\n elabPkgOrComp = ElabComponent (ElaboratedComponent {..})\n }\n | otherwise\n = Nothing\n where\n compSolverName = CD.ComponentSetup\n compComponentName = Nothing\n dep_pkgs = elaborateLibSolverId mapDep =<< CD.setupDeps deps0\n compLibDependencies\n = map configuredId dep_pkgs\n compLinkedLibDependencies = notImpl \"compLinkedLibDependencies\"\n compOrderLibDependencies = notImpl \"compOrderLibDependencies\"\n -- Not supported:\n compExeDependencies = []\n compExeDependencyPaths = []\n compPkgConfigDependencies = []\n\n notImpl f =\n error $ \"Distribution.Client.ProjectPlanning.setupComponent: \" ++\n f ++ \" not implemented yet\"\n\n\n buildComponent\n :: (ConfiguredComponentMap,\n LinkedComponentMap,\n Map ComponentId FilePath)\n -> Cabal.Component\n -> LogProgress\n ((ConfiguredComponentMap,\n LinkedComponentMap,\n Map ComponentId FilePath),\n ElaboratedConfiguredPackage)\n buildComponent (cc_map, lc_map, exe_map) comp =\n addProgressCtx (text \"In the stanza\" <+>\n quotes (text (componentNameStanza cname))) $ do\n\n -- 1. Configure the component, but with a place holder ComponentId.\n cc0 <- toConfiguredComponent\n pd\n (error \"Distribution.Client.ProjectPlanning.cc_cid: filled in later\")\n (Map.unionWith Map.union external_lib_cc_map cc_map)\n (Map.unionWith Map.union external_exe_cc_map cc_map)\n comp\n\n\n -- 2. Read out the dependencies from the ConfiguredComponent cc0\n let compLibDependencies =\n -- Nub because includes can show up multiple times\n ordNub (map (annotatedIdToConfiguredId . ci_ann_id)\n (cc_includes cc0))\n compExeDependencies =\n map annotatedIdToConfiguredId\n (cc_exe_deps cc0)\n compExeDependencyPaths =\n [ (annotatedIdToConfiguredId aid', path)\n | aid' <- cc_exe_deps cc0\n , Just paths <- [Map.lookup (ann_id aid') exe_map1]\n , path <- paths ]\n elab_comp = ElaboratedComponent {..}\n\n -- 3. Construct a preliminary ElaboratedConfiguredPackage,\n -- and use this to compute the component ID. Fix up cc_id\n -- correctly.\n let elab1 = elab0 {\n elabPkgOrComp = ElabComponent $ elab_comp\n }\n cid = case elabBuildStyle elab0 of\n BuildInplaceOnly ->\n mkComponentId $\n display pkgid ++ \"-inplace\" ++\n (case Cabal.componentNameString cname of\n Nothing -> \"\"\n Just s -> \"-\" ++ display s)\n BuildAndInstall ->\n hashedInstalledPackageId\n (packageHashInputs\n elaboratedSharedConfig\n elab1) -- knot tied\n cc = cc0 { cc_ann_id = fmap (const cid) (cc_ann_id cc0) }\n infoProgress $ dispConfiguredComponent cc\n\n -- 4. Perform mix-in linking\n let lookup_uid def_uid =\n case Map.lookup (unDefUnitId def_uid) preexistingInstantiatedPkgs of\n Just full -> full\n Nothing -> error (\"lookup_uid: \" ++ display def_uid)\n lc <- toLinkedComponent verbosity lookup_uid (elabPkgSourceId elab0)\n (Map.union external_lc_map lc_map) cc\n infoProgress $ dispLinkedComponent lc\n -- NB: elab is setup to be the correct form for an\n -- indefinite library, or a definite library with no holes.\n -- We will modify it in 'instantiateInstallPlan' to handle\n -- instantiated packages.\n\n -- 5. Construct the final ElaboratedConfiguredPackage\n let\n elab2 = elab1 {\n elabModuleShape = lc_shape lc,\n elabUnitId = abstractUnitId (lc_uid lc),\n elabComponentId = lc_cid lc,\n elabLinkedInstantiatedWith = Map.fromList (lc_insts lc),\n elabPkgOrComp = ElabComponent $ elab_comp {\n compLinkedLibDependencies = ordNub (map ci_id (lc_includes lc)),\n compOrderLibDependencies =\n ordNub (map (abstractUnitId . ci_id)\n (lc_includes lc ++ lc_sig_includes lc))\n }\n }\n elab = elab2 {\n elabInstallDirs = computeInstallDirs\n storeDirLayout\n defaultInstallDirs\n elaboratedSharedConfig\n elab2\n }\n\n -- 6. Construct the updated local maps\n let cc_map' = extendConfiguredComponentMap cc cc_map\n lc_map' = extendLinkedComponentMap lc lc_map\n exe_map' = Map.insert cid (inplace_bin_dir elab) exe_map\n\n return ((cc_map', lc_map', exe_map'), elab)\n where\n compLinkedLibDependencies = error \"buildComponent: compLinkedLibDependencies\"\n compOrderLibDependencies = error \"buildComponent: compOrderLibDependencies\"\n\n cname = Cabal.componentName comp\n compComponentName = Just cname\n compSolverName = CD.componentNameToComponent cname\n\n -- NB: compLinkedLibDependencies and\n -- compOrderLibDependencies are defined when we define\n -- 'elab'.\n external_lib_dep_sids = CD.select (== compSolverName) deps0\n external_exe_dep_sids = CD.select (== compSolverName) exe_deps0\n\n external_lib_dep_pkgs = concatMap mapDep external_lib_dep_sids\n\n -- Combine library and build-tool dependencies, for backwards\n -- compatibility (See issue #5412 and the documentation for\n -- InstallPlan.fromSolverInstallPlan), but prefer the versions\n -- specified as build-tools.\n external_exe_dep_pkgs =\n concatMap mapDep $\n ordNubBy (pkgName . packageId) $\n external_exe_dep_sids ++ external_lib_dep_sids\n\n external_exe_map = Map.fromList $\n [ (getComponentId pkg, paths)\n | pkg <- external_exe_dep_pkgs\n , let paths = planPackageExePaths pkg ]\n exe_map1 = Map.union external_exe_map $ fmap (\\x -> [x]) exe_map\n\n external_lib_cc_map = Map.fromListWith Map.union\n $ map mkCCMapping external_lib_dep_pkgs\n external_exe_cc_map = Map.fromListWith Map.union\n $ map mkCCMapping external_exe_dep_pkgs\n external_lc_map =\n Map.fromList $ map mkShapeMapping $\n external_lib_dep_pkgs ++ concatMap mapDep external_exe_dep_sids\n\n compPkgConfigDependencies =\n [ (pn, fromMaybe (error $ \"compPkgConfigDependencies: impossible! \"\n ++ display pn ++ \" from \"\n ++ display (elabPkgSourceId elab0))\n (pkgConfigDbPkgVersion pkgConfigDB pn))\n | PkgconfigDependency pn _ <- PD.pkgconfigDepends\n (Cabal.componentBuildInfo comp) ]\n\n inplace_bin_dir elab =\n binDirectoryFor\n distDirLayout\n elaboratedSharedConfig\n elab $\n case Cabal.componentNameString cname of\n Just n -> display n\n Nothing -> \"\"\n\n\n -- | Given a 'SolverId' referencing a dependency on a library, return\n -- the 'ElaboratedPlanPackage' corresponding to the library. This\n -- returns at most one result.\n elaborateLibSolverId :: (SolverId -> [ElaboratedPlanPackage])\n -> SolverId -> [ElaboratedPlanPackage]\n elaborateLibSolverId mapDep = filter (matchPlanPkg (== (CLibName LMainLibName))) . mapDep\n\n -- | Given an 'ElaboratedPlanPackage', return the paths to where the\n -- executables that this package represents would be installed.\n -- The only case where multiple paths can be returned is the inplace\n -- monolithic package one, since there can be multiple exes and each one\n -- has its own directory.\n planPackageExePaths :: ElaboratedPlanPackage -> [FilePath]\n planPackageExePaths =\n -- Pre-existing executables are assumed to be in PATH\n -- already. In fact, this should be impossible.\n InstallPlan.foldPlanPackage (const []) $ \\elab ->\n let\n executables :: [FilePath]\n executables =\n case elabPkgOrComp elab of\n -- Monolithic mode: all exes of the package\n ElabPackage _ -> unUnqualComponentName . PD.exeName\n <$> PD.executables (elabPkgDescription elab)\n -- Per-component mode: just the selected exe\n ElabComponent comp ->\n case fmap Cabal.componentNameString\n (compComponentName comp) of\n Just (Just n) -> [display n]\n _ -> [\"\"]\n in\n binDirectoryFor\n distDirLayout\n elaboratedSharedConfig\n elab\n <$> executables\n\n elaborateSolverToPackage :: SolverPackage UnresolvedPkgLoc\n -> ComponentsGraph\n -> [ElaboratedConfiguredPackage]\n -> ElaboratedConfiguredPackage\n elaborateSolverToPackage\n pkg@(SolverPackage (SourcePackage pkgid _gdesc _srcloc _descOverride)\n _flags _stanzas _deps0 _exe_deps0)\n compGraph comps =\n -- Knot tying: the final elab includes the\n -- pkgInstalledId, which is calculated by hashing many\n -- of the other fields of the elaboratedPackage.\n elab\n where\n elab0@ElaboratedConfiguredPackage{..} = elaborateSolverToCommon pkg\n elab1 = elab0 {\n elabUnitId = newSimpleUnitId pkgInstalledId,\n elabComponentId = pkgInstalledId,\n elabLinkedInstantiatedWith = Map.empty,\n elabPkgOrComp = ElabPackage $ ElaboratedPackage {..},\n elabModuleShape = modShape\n }\n elab = elab1 {\n elabInstallDirs =\n computeInstallDirs storeDirLayout\n defaultInstallDirs\n elaboratedSharedConfig\n elab1\n }\n\n modShape = case find (matchElabPkg (== (CLibName LMainLibName))) comps of\n Nothing -> emptyModuleShape\n Just e -> Ty.elabModuleShape e\n\n pkgInstalledId\n | shouldBuildInplaceOnly pkg\n = mkComponentId (display pkgid ++ \"-inplace\")\n\n | otherwise\n = assert (isJust elabPkgSourceHash) $\n hashedInstalledPackageId\n (packageHashInputs\n elaboratedSharedConfig\n elab) -- recursive use of elab\n\n | otherwise\n = error $ \"elaborateInstallPlan: non-inplace package \"\n ++ \" is missing a source hash: \" ++ display pkgid\n\n -- Need to filter out internal dependencies, because they don't\n -- correspond to anything real anymore.\n isExt confid = confSrcId confid /= pkgid\n filterExt = filter isExt\n filterExt' = filter (isExt . fst)\n\n pkgLibDependencies\n = buildComponentDeps (filterExt . compLibDependencies)\n pkgExeDependencies\n = buildComponentDeps (filterExt . compExeDependencies)\n pkgExeDependencyPaths\n = buildComponentDeps (filterExt' . compExeDependencyPaths)\n -- TODO: Why is this flat?\n pkgPkgConfigDependencies\n = CD.flatDeps $ buildComponentDeps compPkgConfigDependencies\n\n pkgDependsOnSelfLib\n = CD.fromList [ (CD.componentNameToComponent cn, [()])\n | Graph.N _ cn _ <- fromMaybe [] mb_closure ]\n where\n mb_closure = Graph.revClosure compGraph [ k | k <- Graph.keys compGraph, is_lib k ]\n -- NB: the sublib case should not occur, because sub-libraries\n -- are not supported without per-component builds\n is_lib (CLibName _) = True\n is_lib _ = False\n\n buildComponentDeps f\n = CD.fromList [ (compSolverName comp, f comp)\n | ElaboratedConfiguredPackage{\n elabPkgOrComp = ElabComponent comp\n } <- comps\n ]\n\n -- NB: This is not the final setting of 'pkgStanzasEnabled'.\n -- See [Sticky enabled testsuites]; we may enable some extra\n -- stanzas opportunistically when it is cheap to do so.\n --\n -- However, we start off by enabling everything that was\n -- requested, so that we can maintain an invariant that\n -- pkgStanzasEnabled is a superset of elabStanzasRequested\n pkgStanzasEnabled = Map.keysSet (Map.filter (id :: Bool -> Bool) elabStanzasRequested)\n\n elaborateSolverToCommon :: SolverPackage UnresolvedPkgLoc\n -> ElaboratedConfiguredPackage\n elaborateSolverToCommon\n pkg@(SolverPackage (SourcePackage pkgid gdesc srcloc descOverride)\n flags stanzas deps0 _exe_deps0) =\n elaboratedPackage\n where\n elaboratedPackage = ElaboratedConfiguredPackage {..}\n\n -- These get filled in later\n elabUnitId = error \"elaborateSolverToCommon: elabUnitId\"\n elabComponentId = error \"elaborateSolverToCommon: elabComponentId\"\n elabInstantiatedWith = Map.empty\n elabLinkedInstantiatedWith = error \"elaborateSolverToCommon: elabLinkedInstantiatedWith\"\n elabPkgOrComp = error \"elaborateSolverToCommon: elabPkgOrComp\"\n elabInstallDirs = error \"elaborateSolverToCommon: elabInstallDirs\"\n elabModuleShape = error \"elaborateSolverToCommon: elabModuleShape\"\n\n elabIsCanonical = True\n elabPkgSourceId = pkgid\n elabPkgDescription = case PD.finalizePD\n flags elabEnabledSpec (const True)\n platform (compilerInfo compiler)\n [] gdesc of\n Right (desc, _) -> desc\n Left _ -> error \"Failed to finalizePD in elaborateSolverToCommon\"\n elabFlagAssignment = flags\n elabFlagDefaults = PD.mkFlagAssignment\n [ (Cabal.flagName flag, Cabal.flagDefault flag)\n | flag <- PD.genPackageFlags gdesc ]\n\n elabEnabledSpec = enableStanzas stanzas\n elabStanzasAvailable = Set.fromList stanzas\n elabStanzasRequested =\n -- NB: even if a package stanza is requested, if the package\n -- doesn't actually have any of that stanza we omit it from\n -- the request, to ensure that we don't decide that this\n -- package needs to be rebuilt. (It needs to be done here,\n -- because the ElaboratedConfiguredPackage is where we test\n -- whether or not there have been changes.)\n Map.fromList $ [ (TestStanzas, v) | v <- maybeToList tests\n , _ <- PD.testSuites elabPkgDescription ]\n ++ [ (BenchStanzas, v) | v <- maybeToList benchmarks\n , _ <- PD.benchmarks elabPkgDescription ]\n where\n tests, benchmarks :: Maybe Bool\n tests = perPkgOptionMaybe pkgid packageConfigTests\n benchmarks = perPkgOptionMaybe pkgid packageConfigBenchmarks\n\n -- This is a placeholder which will get updated by 'pruneInstallPlanPass1'\n -- and 'pruneInstallPlanPass2'. We can't populate it here\n -- because whether or not tests/benchmarks should be enabled\n -- is heuristically calculated based on whether or not the\n -- dependencies of the test suite have already been installed,\n -- but this function doesn't know what is installed (since\n -- we haven't improved the plan yet), so we do it in another pass.\n -- Check the comments of those functions for more details.\n elabConfigureTargets = []\n elabBuildTargets = []\n elabTestTargets = []\n elabBenchTargets = []\n elabReplTarget = Nothing\n elabHaddockTargets = []\n\n elabBuildHaddocks =\n perPkgOptionFlag pkgid False packageConfigDocumentation\n\n elabPkgSourceLocation = srcloc\n elabPkgSourceHash = Map.lookup pkgid sourcePackageHashes\n elabLocalToProject = isLocalToProject pkg\n elabBuildStyle = if shouldBuildInplaceOnly pkg\n then BuildInplaceOnly else BuildAndInstall\n elabBuildPackageDBStack = buildAndRegisterDbs\n elabRegisterPackageDBStack = buildAndRegisterDbs\n\n elabSetupScriptStyle = packageSetupScriptStyle elabPkgDescription\n elabSetupScriptCliVersion =\n packageSetupScriptSpecVersion\n elabSetupScriptStyle elabPkgDescription libDepGraph deps0\n elabSetupPackageDBStack = buildAndRegisterDbs\n\n buildAndRegisterDbs\n | shouldBuildInplaceOnly pkg = inplacePackageDbs\n | otherwise = storePackageDbs\n\n elabPkgDescriptionOverride = descOverride\n\n elabVanillaLib = perPkgOptionFlag pkgid True packageConfigVanillaLib --TODO: [required feature]: also needs to be handled recursively\n elabSharedLib = pkgid `Set.member` pkgsUseSharedLibrary\n elabStaticLib = perPkgOptionFlag pkgid False packageConfigStaticLib\n elabDynExe = perPkgOptionFlag pkgid False packageConfigDynExe\n elabFullyStaticExe = perPkgOptionFlag pkgid False packageConfigFullyStaticExe\n elabGHCiLib = perPkgOptionFlag pkgid False packageConfigGHCiLib --TODO: [required feature] needs to default to enabled on windows still\n\n elabProfExe = perPkgOptionFlag pkgid False packageConfigProf\n elabProfLib = pkgid `Set.member` pkgsUseProfilingLibrary\n\n (elabProfExeDetail,\n elabProfLibDetail) = perPkgOptionLibExeFlag pkgid ProfDetailDefault\n packageConfigProfDetail\n packageConfigProfLibDetail\n elabCoverage = perPkgOptionFlag pkgid False packageConfigCoverage\n\n elabOptimization = perPkgOptionFlag pkgid NormalOptimisation packageConfigOptimization\n elabSplitObjs = perPkgOptionFlag pkgid False packageConfigSplitObjs\n elabSplitSections = perPkgOptionFlag pkgid False packageConfigSplitSections\n elabStripLibs = perPkgOptionFlag pkgid False packageConfigStripLibs\n elabStripExes = perPkgOptionFlag pkgid False packageConfigStripExes\n elabDebugInfo = perPkgOptionFlag pkgid NoDebugInfo packageConfigDebugInfo\n\n -- Combine the configured compiler prog settings with the user-supplied\n -- config. For the compiler progs any user-supplied config was taken\n -- into account earlier when configuring the compiler so its ok that\n -- our configured settings for the compiler override the user-supplied\n -- config here.\n elabProgramPaths = Map.fromList\n [ (programId prog, programPath prog)\n | prog <- configuredPrograms compilerprogdb ]\n <> perPkgOptionMapLast pkgid packageConfigProgramPaths\n elabProgramArgs = Map.fromList\n [ (programId prog, args)\n | prog <- configuredPrograms compilerprogdb\n , let args = programOverrideArgs prog\n , not (null args)\n ]\n <> perPkgOptionMapMappend pkgid packageConfigProgramArgs\n elabProgramPathExtra = perPkgOptionNubList pkgid packageConfigProgramPathExtra\n elabConfigureScriptArgs = perPkgOptionList pkgid packageConfigConfigureArgs\n elabExtraLibDirs = perPkgOptionList pkgid packageConfigExtraLibDirs\n elabExtraFrameworkDirs = perPkgOptionList pkgid packageConfigExtraFrameworkDirs\n elabExtraIncludeDirs = perPkgOptionList pkgid packageConfigExtraIncludeDirs\n elabProgPrefix = perPkgOptionMaybe pkgid packageConfigProgPrefix\n elabProgSuffix = perPkgOptionMaybe pkgid packageConfigProgSuffix\n\n\n elabHaddockHoogle = perPkgOptionFlag pkgid False packageConfigHaddockHoogle\n elabHaddockHtml = perPkgOptionFlag pkgid False packageConfigHaddockHtml\n elabHaddockHtmlLocation = perPkgOptionMaybe pkgid packageConfigHaddockHtmlLocation\n elabHaddockForeignLibs = perPkgOptionFlag pkgid False packageConfigHaddockForeignLibs\n elabHaddockForHackage = perPkgOptionFlag pkgid Cabal.ForDevelopment packageConfigHaddockForHackage\n elabHaddockExecutables = perPkgOptionFlag pkgid False packageConfigHaddockExecutables\n elabHaddockTestSuites = perPkgOptionFlag pkgid False packageConfigHaddockTestSuites\n elabHaddockBenchmarks = perPkgOptionFlag pkgid False packageConfigHaddockBenchmarks\n elabHaddockInternal = perPkgOptionFlag pkgid False packageConfigHaddockInternal\n elabHaddockCss = perPkgOptionMaybe pkgid packageConfigHaddockCss\n elabHaddockLinkedSource = perPkgOptionFlag pkgid False packageConfigHaddockLinkedSource\n elabHaddockQuickJump = perPkgOptionFlag pkgid False packageConfigHaddockQuickJump\n elabHaddockHscolourCss = perPkgOptionMaybe pkgid packageConfigHaddockHscolourCss\n elabHaddockContents = perPkgOptionMaybe pkgid packageConfigHaddockContents\n\n elabTestMachineLog = perPkgOptionMaybe pkgid packageConfigTestMachineLog\n elabTestHumanLog = perPkgOptionMaybe pkgid packageConfigTestHumanLog\n elabTestShowDetails = perPkgOptionMaybe pkgid packageConfigTestShowDetails\n elabTestKeepTix = perPkgOptionFlag pkgid False packageConfigTestKeepTix\n elabTestWrapper = perPkgOptionMaybe pkgid packageConfigTestWrapper\n elabTestFailWhenNoTestSuites = perPkgOptionFlag pkgid False packageConfigTestFailWhenNoTestSuites\n elabTestTestOptions = perPkgOptionList pkgid packageConfigTestTestOptions\n\n elabBenchmarkOptions = perPkgOptionList pkgid packageConfigBenchmarkOptions\n\n perPkgOptionFlag :: PackageId -> a -> (PackageConfig -> Flag a) -> a\n perPkgOptionMaybe :: PackageId -> (PackageConfig -> Flag a) -> Maybe a\n perPkgOptionList :: PackageId -> (PackageConfig -> [a]) -> [a]\n\n perPkgOptionFlag pkgid def f = fromFlagOrDefault def (lookupPerPkgOption pkgid f)\n perPkgOptionMaybe pkgid f = flagToMaybe (lookupPerPkgOption pkgid f)\n perPkgOptionList pkgid f = lookupPerPkgOption pkgid f\n perPkgOptionNubList pkgid f = fromNubList (lookupPerPkgOption pkgid f)\n perPkgOptionMapLast pkgid f = getMapLast (lookupPerPkgOption pkgid f)\n perPkgOptionMapMappend pkgid f = getMapMappend (lookupPerPkgOption pkgid f)\n\n perPkgOptionLibExeFlag pkgid def fboth flib = (exe, lib)\n where\n exe = fromFlagOrDefault def bothflag\n lib = fromFlagOrDefault def (bothflag <> libflag)\n\n bothflag = lookupPerPkgOption pkgid fboth\n libflag = lookupPerPkgOption pkgid flib\n\n lookupPerPkgOption :: (Package pkg, Monoid m)\n => pkg -> (PackageConfig -> m) -> m\n lookupPerPkgOption pkg f =\n -- This is where we merge the options from the project config that\n -- apply to all packages, all project local packages, and to specific\n -- named packages\n global `mappend` local `mappend` perpkg\n where\n global = f allPackagesConfig\n local | isLocalToProject pkg\n = f localPackagesConfig\n | otherwise\n = mempty\n perpkg = maybe mempty f (Map.lookup (packageName pkg) perPackageConfig)\n\n inplacePackageDbs = storePackageDbs\n ++ [ distPackageDB (compilerId compiler) ]\n\n storePackageDbs = storePackageDBStack (compilerId compiler)\n\n -- For this local build policy, every package that lives in a local source\n -- dir (as opposed to a tarball), or depends on such a package, will be\n -- built inplace into a shared dist dir. Tarball packages that depend on\n -- source dir packages will also get unpacked locally.\n shouldBuildInplaceOnly :: SolverPackage loc -> Bool\n shouldBuildInplaceOnly pkg = Set.member (packageId pkg)\n pkgsToBuildInplaceOnly\n\n pkgsToBuildInplaceOnly :: Set PackageId\n pkgsToBuildInplaceOnly =\n Set.fromList\n $ map packageId\n $ SolverInstallPlan.reverseDependencyClosure\n solverPlan\n (map PlannedId (Set.toList pkgsLocalToProject))\n\n isLocalToProject :: Package pkg => pkg -> Bool\n isLocalToProject pkg = Set.member (packageId pkg)\n pkgsLocalToProject\n\n pkgsLocalToProject :: Set PackageId\n pkgsLocalToProject =\n Set.fromList (catMaybes (map shouldBeLocal localPackages))\n --TODO: localPackages is a misnomer, it's all project packages\n -- here is where we decide which ones will be local!\n where\n shouldBeLocal :: PackageSpecifier (SourcePackage (PackageLocation loc)) -> Maybe PackageId\n shouldBeLocal NamedPackage{} = Nothing\n shouldBeLocal (SpecificSourcePackage pkg)\n | LocalTarballPackage _ <- packageSource pkg = Nothing\n | otherwise = Just (packageId pkg)\n -- TODO: Is it only LocalTarballPackages we can know about without\n -- them being \"local\" in the sense meant here?\n --\n -- Also, review use of SourcePackage's loc vs ProjectPackageLocation\n\n pkgsUseSharedLibrary :: Set PackageId\n pkgsUseSharedLibrary =\n packagesWithLibDepsDownwardClosedProperty needsSharedLib\n where\n needsSharedLib pkg =\n fromMaybe compilerShouldUseSharedLibByDefault\n (liftM2 (||) pkgSharedLib pkgDynExe)\n where\n pkgid = packageId pkg\n pkgSharedLib = perPkgOptionMaybe pkgid packageConfigSharedLib\n pkgDynExe = perPkgOptionMaybe pkgid packageConfigDynExe\n\n --TODO: [code cleanup] move this into the Cabal lib. It's currently open\n -- coded in Distribution.Simple.Configure, but should be made a proper\n -- function of the Compiler or CompilerInfo.\n compilerShouldUseSharedLibByDefault =\n case compilerFlavor compiler of\n GHC -> GHC.isDynamic compiler\n GHCJS -> GHCJS.isDynamic compiler\n _ -> False\n\n pkgsUseProfilingLibrary :: Set PackageId\n pkgsUseProfilingLibrary =\n packagesWithLibDepsDownwardClosedProperty needsProfilingLib\n where\n needsProfilingLib pkg =\n fromFlagOrDefault False (profBothFlag <> profLibFlag)\n where\n pkgid = packageId pkg\n profBothFlag = lookupPerPkgOption pkgid packageConfigProf\n profLibFlag = lookupPerPkgOption pkgid packageConfigProfLib\n --TODO: [code cleanup] unused: the old deprecated packageConfigProfExe\n\n libDepGraph = Graph.fromDistinctList $\n map NonSetupLibDepSolverPlanPackage\n (SolverInstallPlan.toList solverPlan)\n\n packagesWithLibDepsDownwardClosedProperty property =\n Set.fromList\n . map packageId\n . fromMaybe []\n $ Graph.closure\n libDepGraph\n [ Graph.nodeKey pkg\n | pkg <- SolverInstallPlan.toList solverPlan\n , property pkg ] -- just the packages that satisfy the property\n --TODO: [nice to have] this does not check the config consistency,\n -- e.g. a package explicitly turning off profiling, but something\n -- depending on it that needs profiling. This really needs a separate\n -- package config validation/resolution pass.\n\n --TODO: [nice to have] config consistency checking:\n -- + profiling libs & exes, exe needs lib, recursive\n -- + shared libs & exes, exe needs lib, recursive\n -- + vanilla libs & exes, exe needs lib, recursive\n -- + ghci or shared lib needed by TH, recursive, ghc version dependent\n\n-- TODO: Drop matchPlanPkg/matchElabPkg in favor of mkCCMapping\n\n-- | Given a 'ElaboratedPlanPackage', report if it matches a 'ComponentName'.\nmatchPlanPkg :: (ComponentName -> Bool) -> ElaboratedPlanPackage -> Bool\nmatchPlanPkg p = InstallPlan.foldPlanPackage (p . ipiComponentName) (matchElabPkg p)\n\n-- | Get the appropriate 'ComponentName' which identifies an installed\n-- component.\nipiComponentName :: IPI.InstalledPackageInfo -> ComponentName\nipiComponentName = CLibName . IPI.sourceLibName\n\n-- | Given a 'ElaboratedConfiguredPackage', report if it matches a\n-- 'ComponentName'.\nmatchElabPkg :: (ComponentName -> Bool) -> ElaboratedConfiguredPackage -> Bool\nmatchElabPkg p elab =\n case elabPkgOrComp elab of\n ElabComponent comp -> maybe False p (compComponentName comp)\n ElabPackage _ ->\n -- So, what should we do here? One possibility is to\n -- unconditionally return 'True', because whatever it is\n -- that we're looking for, it better be in this package.\n -- But this is a bit dodgy if the package doesn't actually\n -- have, e.g., a library. Fortunately, it's not possible\n -- for the build of the library/executables to be toggled\n -- by 'pkgStanzasEnabled', so the only thing we have to\n -- test is if the component in question is *buildable.*\n any (p . componentName)\n (Cabal.pkgBuildableComponents (elabPkgDescription elab))\n\n-- | Given an 'ElaboratedPlanPackage', generate the mapping from 'PackageName'\n-- and 'ComponentName' to the 'ComponentId' that that should be used\n-- in this case.\nmkCCMapping :: ElaboratedPlanPackage\n -> (PackageName, Map ComponentName (AnnotatedId ComponentId))\nmkCCMapping =\n InstallPlan.foldPlanPackage\n (\\ipkg -> (packageName ipkg,\n Map.singleton (ipiComponentName ipkg)\n -- TODO: libify\n (AnnotatedId {\n ann_id = IPI.installedComponentId ipkg,\n ann_pid = packageId ipkg,\n ann_cname = IPI.sourceComponentName ipkg\n })))\n $ \\elab ->\n let mk_aid cn = AnnotatedId {\n ann_id = elabComponentId elab,\n ann_pid = packageId elab,\n ann_cname = cn\n }\n in (packageName elab,\n case elabPkgOrComp elab of\n ElabComponent comp ->\n case compComponentName comp of\n Nothing -> Map.empty\n Just n -> Map.singleton n (mk_aid n)\n ElabPackage _ ->\n Map.fromList $\n map (\\comp -> let cn = Cabal.componentName comp in (cn, mk_aid cn))\n (Cabal.pkgBuildableComponents (elabPkgDescription elab)))\n\n-- | Given an 'ElaboratedPlanPackage', generate the mapping from 'ComponentId'\n-- to the shape of this package, as per mix-in linking.\nmkShapeMapping :: ElaboratedPlanPackage\n -> (ComponentId, (OpenUnitId, ModuleShape))\nmkShapeMapping dpkg =\n (getComponentId dpkg, (indef_uid, shape))\n where\n (dcid, shape) =\n InstallPlan.foldPlanPackage\n -- Uses Monad (->)\n (liftM2 (,) IPI.installedComponentId shapeInstalledPackage)\n (liftM2 (,) elabComponentId elabModuleShape)\n dpkg\n indef_uid =\n IndefFullUnitId dcid\n (Map.fromList [ (req, OpenModuleVar req)\n | req <- Set.toList (modShapeRequires shape)])\n\n-- | Get the bin\\/ directories that a package's executables should reside in.\n--\n-- The result may be empty if the package does not build any executables.\n--\n-- The result may have several entries if this is an inplace build of a package\n-- with multiple executables.\nbinDirectories\n :: DistDirLayout\n -> ElaboratedSharedConfig\n -> ElaboratedConfiguredPackage\n -> [FilePath]\nbinDirectories layout config package = case elabBuildStyle package of\n -- quick sanity check: no sense returning a bin directory if we're not going\n -- to put any executables in it, that will just clog up the PATH\n _ | noExecutables -> []\n BuildAndInstall -> [installedBinDirectory package]\n BuildInplaceOnly -> map (root) $ case elabPkgOrComp package of\n ElabComponent comp -> case compSolverName comp of\n CD.ComponentExe n -> [display n]\n _ -> []\n ElabPackage _ -> map (display . PD.exeName)\n . PD.executables\n . elabPkgDescription\n $ package\n where\n noExecutables = null . PD.executables . elabPkgDescription $ package\n root = distBuildDirectory layout (elabDistDirParams config package)\n \"build\"\n\n-- | A newtype for 'SolverInstallPlan.SolverPlanPackage' for which the\n-- dependency graph considers only dependencies on libraries which are\n-- NOT from setup dependencies. Used to compute the set\n-- of packages needed for profiling and dynamic libraries.\nnewtype NonSetupLibDepSolverPlanPackage\n = NonSetupLibDepSolverPlanPackage\n { unNonSetupLibDepSolverPlanPackage :: SolverInstallPlan.SolverPlanPackage }\n\ninstance Package NonSetupLibDepSolverPlanPackage where\n packageId = packageId . unNonSetupLibDepSolverPlanPackage\n\ninstance IsNode NonSetupLibDepSolverPlanPackage where\n type Key NonSetupLibDepSolverPlanPackage = SolverId\n nodeKey = nodeKey . unNonSetupLibDepSolverPlanPackage\n nodeNeighbors (NonSetupLibDepSolverPlanPackage spkg)\n = ordNub $ CD.nonSetupDeps (resolverPackageLibDeps spkg)\n\ntype InstS = Map UnitId ElaboratedPlanPackage\ntype InstM a = State InstS a\n\ngetComponentId :: ElaboratedPlanPackage\n -> ComponentId\ngetComponentId (InstallPlan.PreExisting dipkg) = IPI.installedComponentId dipkg\ngetComponentId (InstallPlan.Configured elab) = elabComponentId elab\ngetComponentId (InstallPlan.Installed elab) = elabComponentId elab\n\ninstantiateInstallPlan :: StoreDirLayout -> InstallDirs.InstallDirTemplates -> ElaboratedSharedConfig -> ElaboratedInstallPlan -> ElaboratedInstallPlan\ninstantiateInstallPlan storeDirLayout defaultInstallDirs elaboratedShared plan =\n InstallPlan.new (IndependentGoals False)\n (Graph.fromDistinctList (Map.elems ready_map))\n where\n pkgs = InstallPlan.toList plan\n\n cmap = Map.fromList [ (getComponentId pkg, pkg) | pkg <- pkgs ]\n\n instantiateUnitId :: ComponentId -> Map ModuleName Module\n -> InstM DefUnitId\n instantiateUnitId cid insts = state $ \\s ->\n case Map.lookup uid s of\n Nothing ->\n -- Knot tied\n let (r, s') = runState (instantiateComponent uid cid insts)\n (Map.insert uid r s)\n in (def_uid, Map.insert uid r s')\n Just _ -> (def_uid, s)\n where\n def_uid = mkDefUnitId cid insts\n uid = unDefUnitId def_uid\n\n instantiateComponent\n :: UnitId -> ComponentId -> Map ModuleName Module\n -> InstM ElaboratedPlanPackage\n instantiateComponent uid cid insts\n | Just planpkg <- Map.lookup cid cmap\n = case planpkg of\n InstallPlan.Configured (elab0@ElaboratedConfiguredPackage\n { elabPkgOrComp = ElabComponent comp }) -> do\n deps <- mapM (substUnitId insts)\n (compLinkedLibDependencies comp)\n let getDep (Module dep_uid _) = [dep_uid]\n elab1 = elab0 {\n elabUnitId = uid,\n elabComponentId = cid,\n elabInstantiatedWith = insts,\n elabIsCanonical = Map.null insts,\n elabPkgOrComp = ElabComponent comp {\n compOrderLibDependencies =\n (if Map.null insts then [] else [newSimpleUnitId cid]) ++\n ordNub (map unDefUnitId\n (deps ++ concatMap getDep (Map.elems insts)))\n }\n }\n elab = elab1 {\n elabInstallDirs = computeInstallDirs storeDirLayout\n defaultInstallDirs\n elaboratedShared\n elab1\n }\n return $ InstallPlan.Configured elab\n _ -> return planpkg\n | otherwise = error (\"instantiateComponent: \" ++ display cid)\n\n substUnitId :: Map ModuleName Module -> OpenUnitId -> InstM DefUnitId\n substUnitId _ (DefiniteUnitId uid) =\n return uid\n substUnitId subst (IndefFullUnitId cid insts) = do\n insts' <- substSubst subst insts\n instantiateUnitId cid insts'\n\n -- NB: NOT composition\n substSubst :: Map ModuleName Module\n -> Map ModuleName OpenModule\n -> InstM (Map ModuleName Module)\n substSubst subst insts = T.mapM (substModule subst) insts\n\n substModule :: Map ModuleName Module -> OpenModule -> InstM Module\n substModule subst (OpenModuleVar mod_name)\n | Just m <- Map.lookup mod_name subst = return m\n | otherwise = error \"substModule: non-closing substitution\"\n substModule subst (OpenModule uid mod_name) = do\n uid' <- substUnitId subst uid\n return (Module uid' mod_name)\n\n indefiniteUnitId :: ComponentId -> InstM UnitId\n indefiniteUnitId cid = do\n let uid = newSimpleUnitId cid\n r <- indefiniteComponent uid cid\n state $ \\s -> (uid, Map.insert uid r s)\n\n indefiniteComponent :: UnitId -> ComponentId -> InstM ElaboratedPlanPackage\n indefiniteComponent _uid cid\n -- Only need Configured; this phase happens before improvement, so\n -- there shouldn't be any Installed packages here.\n | Just (InstallPlan.Configured epkg) <- Map.lookup cid cmap\n , ElabComponent elab_comp <- elabPkgOrComp epkg\n = do -- We need to do a little more processing of the includes: some\n -- of them are fully definite even without substitution. We\n -- want to build those too; see #5634.\n --\n -- This code mimics similar code in Distribution.Backpack.ReadyComponent;\n -- however, unlike the conversion from LinkedComponent to\n -- ReadyComponent, this transformation is done *without*\n -- changing the type in question; and what we are simply\n -- doing is enforcing tighter invariants on the data\n -- structure in question. The new invariant is that there\n -- is no IndefFullUnitId in compLinkedLibDependencies that actually\n -- has no holes. We couldn't specify this invariant when\n -- we initially created the ElaboratedPlanPackage because\n -- we have no way of actually refiying the UnitId into a\n -- DefiniteUnitId (that's what substUnitId does!)\n new_deps <- forM (compLinkedLibDependencies elab_comp) $ \\uid ->\n if Set.null (openUnitIdFreeHoles uid)\n then fmap DefiniteUnitId (substUnitId Map.empty uid)\n else return uid\n return $ InstallPlan.Configured epkg {\n elabPkgOrComp = ElabComponent elab_comp {\n compLinkedLibDependencies = new_deps,\n -- I think this is right: any new definite unit ids we\n -- minted in the phase above need to be built before us.\n -- Add 'em in. This doesn't remove any old dependencies\n -- on the indefinite package; they're harmless.\n compOrderLibDependencies =\n ordNub $ compOrderLibDependencies elab_comp ++\n [unDefUnitId d | DefiniteUnitId d <- new_deps]\n }\n }\n | Just planpkg <- Map.lookup cid cmap\n = return planpkg\n | otherwise = error (\"indefiniteComponent: \" ++ display cid)\n\n ready_map = execState work Map.empty\n\n work = forM_ pkgs $ \\pkg ->\n case pkg of\n InstallPlan.Configured elab\n | not (Map.null (elabLinkedInstantiatedWith elab))\n -> indefiniteUnitId (elabComponentId elab)\n >> return ()\n _ -> instantiateUnitId (getComponentId pkg) Map.empty\n >> return ()\n\n---------------------------\n-- Build targets\n--\n\n-- Refer to ProjectPlanning.Types for details of these important types:\n\n-- data ComponentTarget = ...\n-- data SubComponentTarget = ...\n\n-- One step in the build system is to translate higher level intentions like\n-- \"build this package\", \"test that package\", or \"repl that component\" into\n-- a more detailed specification of exactly which components to build (or other\n-- actions like repl or build docs). This translation is somewhat different for\n-- different commands. For example \"test\" for a package will build a different\n-- set of components than \"build\". In addition, the translation of these\n-- intentions can fail. For example \"run\" for a package is only unambiguous\n-- when the package has a single executable.\n--\n-- So we need a little bit of infrastructure to make it easy for the command\n-- implementations to select what component targets are meant when a user asks\n-- to do something with a package or component. To do this (and to be able to\n-- produce good error messages for mistakes and when targets are not available)\n-- we need to gather and summarise accurate information about all the possible\n-- targets, both available and unavailable. Then a command implementation can\n-- decide which of the available component targets should be selected.\n\n-- | An available target represents a component within a package that a user\n-- command could plausibly refer to. In this sense, all the components defined\n-- within the package are things the user could refer to, whether or not it\n-- would actually be possible to build that component.\n--\n-- In particular the available target contains an 'AvailableTargetStatus' which\n-- informs us about whether it's actually possible to select this component to\n-- be built, and if not why not. This detail makes it possible for command\n-- implementations (like @build@, @test@ etc) to accurately report why a target\n-- cannot be used.\n--\n-- Note that the type parameter is used to help enforce that command\n-- implementations can only select targets that can actually be built (by\n-- forcing them to return the @k@ value for the selected targets).\n-- In particular 'resolveTargets' makes use of this (with @k@ as\n-- @('UnitId', ComponentName')@) to identify the targets thus selected.\n--\ndata AvailableTarget k = AvailableTarget {\n availableTargetPackageId :: PackageId,\n availableTargetComponentName :: ComponentName,\n availableTargetStatus :: AvailableTargetStatus k,\n availableTargetLocalToProject :: Bool\n }\n deriving (Eq, Show, Functor)\n\n-- | The status of a an 'AvailableTarget' component. This tells us whether\n-- it's actually possible to select this component to be built, and if not\n-- why not.\n--\ndata AvailableTargetStatus k =\n TargetDisabledByUser -- ^ When the user does @tests: False@\n | TargetDisabledBySolver -- ^ When the solver could not enable tests\n | TargetNotBuildable -- ^ When the component has @buildable: False@\n | TargetNotLocal -- ^ When the component is non-core in a non-local package\n | TargetBuildable k TargetRequested -- ^ The target can or should be built\n deriving (Eq, Ord, Show, Functor)\n\n-- | This tells us whether a target ought to be built by default, or only if\n-- specifically requested. The policy is that components like libraries and\n-- executables are built by default by @build@, but test suites and benchmarks\n-- are not, unless this is overridden in the project configuration.\n--\ndata TargetRequested =\n TargetRequestedByDefault -- ^ To be built by default\n | TargetNotRequestedByDefault -- ^ Not to be built by default\n deriving (Eq, Ord, Show)\n\n-- | Given the install plan, produce the set of 'AvailableTarget's for each\n-- package-component pair.\n--\n-- Typically there will only be one such target for each component, but for\n-- example if we have a plan with both normal and profiling variants of a\n-- component then we would get both as available targets, or similarly if we\n-- had a plan that contained two instances of the same version of a package.\n-- This approach makes it relatively easy to select all instances\\/variants\n-- of a component.\n--\navailableTargets :: ElaboratedInstallPlan\n -> Map (PackageId, ComponentName)\n [AvailableTarget (UnitId, ComponentName)]\navailableTargets installPlan =\n let rs = [ (pkgid, cname, fake, target)\n | pkg <- InstallPlan.toList installPlan\n , (pkgid, cname, fake, target) <- case pkg of\n InstallPlan.PreExisting ipkg -> availableInstalledTargets ipkg\n InstallPlan.Installed elab -> availableSourceTargets elab\n InstallPlan.Configured elab -> availableSourceTargets elab\n ]\n in Map.union\n (Map.fromListWith (++)\n [ ((pkgid, cname), [target])\n | (pkgid, cname, fake, target) <- rs, not fake])\n (Map.fromList\n [ ((pkgid, cname), [target])\n | (pkgid, cname, fake, target) <- rs, fake])\n -- The normal targets mask the fake ones. We get all instances of the\n -- normal ones and only one copy of the fake ones (as there are many\n -- duplicates of the fake ones). See 'availableSourceTargets' below for\n -- more details on this fake stuff is about.\n\navailableInstalledTargets :: IPI.InstalledPackageInfo\n -> [(PackageId, ComponentName, Bool,\n AvailableTarget (UnitId, ComponentName))]\navailableInstalledTargets ipkg =\n let unitid = installedUnitId ipkg\n cname = CLibName LMainLibName\n status = TargetBuildable (unitid, cname) TargetRequestedByDefault\n target = AvailableTarget (packageId ipkg) cname status False\n fake = False\n in [(packageId ipkg, cname, fake, target)]\n\navailableSourceTargets :: ElaboratedConfiguredPackage\n -> [(PackageId, ComponentName, Bool,\n AvailableTarget (UnitId, ComponentName))]\navailableSourceTargets elab =\n -- We have a somewhat awkward problem here. We need to know /all/ the\n -- components from /all/ the packages because these are the things that\n -- users could refer to. Unfortunately, at this stage the elaborated install\n -- plan does /not/ contain all components: some components have already\n -- been deleted because they cannot possibly be built. This is the case\n -- for components that are marked @buildable: False@ in their .cabal files.\n -- (It's not unreasonable that the unbuildable components have been pruned\n -- as the plan invariant is considerably simpler if all nodes can be built)\n --\n -- We can recover the missing components but it's not exactly elegant. For\n -- a graph node corresponding to a component we still have the information\n -- about the package that it came from, and this includes the names of\n -- /all/ the other components in the package. So in principle this lets us\n -- find the names of all components, plus full details of the buildable\n -- components.\n --\n -- Consider for example a package with 3 exe components: foo, bar and baz\n -- where foo and bar are buildable, but baz is not. So the plan contains\n -- nodes for the components foo and bar. Now we look at each of these two\n -- nodes and look at the package they come from and the names of the\n -- components in this package. This will give us the names foo, bar and\n -- baz, twice (once for each of the two buildable components foo and bar).\n --\n -- We refer to these reconstructed missing components as fake targets.\n -- It is an invariant that they are not available to be built.\n --\n -- To produce the final set of targets we put the fake targets in a finite\n -- map (thus eliminating the duplicates) and then we overlay that map with\n -- the normal buildable targets. (This is done above in 'availableTargets'.)\n --\n [ (packageId elab, cname, fake, target)\n | component <- pkgComponents (elabPkgDescription elab)\n , let cname = componentName component\n status = componentAvailableTargetStatus component\n target = AvailableTarget {\n availableTargetPackageId = packageId elab,\n availableTargetComponentName = cname,\n availableTargetStatus = status,\n availableTargetLocalToProject = elabLocalToProject elab\n }\n fake = isFakeTarget cname\n\n -- TODO: The goal of this test is to exclude \"instantiated\"\n -- packages as available targets. This means that you can't\n -- ask for a particular instantiated component to be built;\n -- it will only get built by a dependency. Perhaps the\n -- correct way to implement this is to run selection\n -- prior to instantiating packages. If you refactor\n -- this, then you can delete this test.\n , elabIsCanonical elab\n\n -- Filter out some bogus parts of the cross product that are never needed\n , case status of\n TargetBuildable{} | fake -> False\n _ -> True\n ]\n where\n isFakeTarget cname =\n case elabPkgOrComp elab of\n ElabPackage _ -> False\n ElabComponent elabComponent -> compComponentName elabComponent\n /= Just cname\n\n componentAvailableTargetStatus\n :: Component -> AvailableTargetStatus (UnitId, ComponentName)\n componentAvailableTargetStatus component =\n case componentOptionalStanza $ CD.componentNameToComponent cname of\n -- it is not an optional stanza, so a library, exe or foreign lib\n Nothing\n | not buildable -> TargetNotBuildable\n | otherwise -> TargetBuildable (elabUnitId elab, cname)\n TargetRequestedByDefault\n\n -- it is not an optional stanza, so a testsuite or benchmark\n Just stanza ->\n case (Map.lookup stanza (elabStanzasRequested elab),\n Set.member stanza (elabStanzasAvailable elab)) of\n _ | not withinPlan -> TargetNotLocal\n (Just False, _) -> TargetDisabledByUser\n (Nothing, False) -> TargetDisabledBySolver\n _ | not buildable -> TargetNotBuildable\n (Just True, True) -> TargetBuildable (elabUnitId elab, cname)\n TargetRequestedByDefault\n (Nothing, True) -> TargetBuildable (elabUnitId elab, cname)\n TargetNotRequestedByDefault\n (Just True, False) ->\n error \"componentAvailableTargetStatus: impossible\"\n where\n cname = componentName component\n buildable = PD.buildable (componentBuildInfo component)\n withinPlan = elabLocalToProject elab\n || case elabPkgOrComp elab of\n ElabComponent elabComponent ->\n compComponentName elabComponent == Just cname\n ElabPackage _ ->\n case componentName component of\n CLibName (LMainLibName) -> True\n CExeName _ -> True\n --TODO: what about sub-libs and foreign libs?\n _ -> False\n\n-- | Merge component targets that overlap each other. Specially when we have\n-- multiple targets for the same component and one of them refers to the whole\n-- component (rather than a module or file within) then all the other targets\n-- for that component are subsumed.\n--\n-- We also allow for information associated with each component target, and\n-- whenever we targets subsume each other we aggregate their associated info.\n--\nnubComponentTargets :: [(ComponentTarget, a)] -> [(ComponentTarget, [a])]\nnubComponentTargets =\n concatMap (wholeComponentOverrides . map snd)\n . groupBy ((==) `on` fst)\n . sortBy (compare `on` fst)\n . map (\\t@((ComponentTarget cname _, _)) -> (cname, t))\n . map compatSubComponentTargets\n where\n -- If we're building the whole component then that the only target all we\n -- need, otherwise we can have several targets within the component.\n wholeComponentOverrides :: [(ComponentTarget, a )]\n -> [(ComponentTarget, [a])]\n wholeComponentOverrides ts =\n case [ t | (t@(ComponentTarget _ WholeComponent), _) <- ts ] of\n (t:_) -> [ (t, map snd ts) ]\n [] -> [ (t,[x]) | (t,x) <- ts ]\n\n -- Not all Cabal Setup.hs versions support sub-component targets, so switch\n -- them over to the whole component\n compatSubComponentTargets :: (ComponentTarget, a) -> (ComponentTarget, a)\n compatSubComponentTargets target@(ComponentTarget cname _subtarget, x)\n | not setupHsSupportsSubComponentTargets\n = (ComponentTarget cname WholeComponent, x)\n | otherwise = target\n\n -- Actually the reality is that no current version of Cabal's Setup.hs\n -- build command actually support building specific files or modules.\n setupHsSupportsSubComponentTargets = False\n -- TODO: when that changes, adjust this test, e.g.\n -- | pkgSetupScriptCliVersion >= Version [x,y] []\n\npkgHasEphemeralBuildTargets :: ElaboratedConfiguredPackage -> Bool\npkgHasEphemeralBuildTargets elab =\n isJust (elabReplTarget elab)\n || (not . null) (elabTestTargets elab)\n || (not . null) (elabBenchTargets elab)\n || (not . null) (elabHaddockTargets elab)\n || (not . null) [ () | ComponentTarget _ subtarget <- elabBuildTargets elab\n , subtarget /= WholeComponent ]\n\n-- | The components that we'll build all of, meaning that after they're built\n-- we can skip building them again (unlike with building just some modules or\n-- other files within a component).\n--\nelabBuildTargetWholeComponents :: ElaboratedConfiguredPackage\n -> Set ComponentName\nelabBuildTargetWholeComponents elab =\n Set.fromList\n [ cname | ComponentTarget cname WholeComponent <- elabBuildTargets elab ]\n\n\n\n------------------------------------------------------------------------------\n-- * Install plan pruning\n------------------------------------------------------------------------------\n\n-- | How 'pruneInstallPlanToTargets' should interpret the per-package\n-- 'ComponentTarget's: as build, repl or haddock targets.\n--\ndata TargetAction = TargetActionConfigure\n | TargetActionBuild\n | TargetActionRepl\n | TargetActionTest\n | TargetActionBench\n | TargetActionHaddock\n\n-- | Given a set of per-package\\/per-component targets, take the subset of the\n-- install plan needed to build those targets. Also, update the package config\n-- to specify which optional stanzas to enable, and which targets within each\n-- package to build.\n--\n-- NB: Pruning happens after improvement, which is important because we\n-- will prune differently depending on what is already installed (to\n-- implement \"sticky\" test suite enabling behavior).\n--\npruneInstallPlanToTargets :: TargetAction\n -> Map UnitId [ComponentTarget]\n -> ElaboratedInstallPlan -> ElaboratedInstallPlan\npruneInstallPlanToTargets targetActionType perPkgTargetsMap elaboratedPlan =\n InstallPlan.new (InstallPlan.planIndepGoals elaboratedPlan)\n . Graph.fromDistinctList\n -- We have to do the pruning in two passes\n . pruneInstallPlanPass2\n . pruneInstallPlanPass1\n -- Set the targets that will be the roots for pruning\n . setRootTargets targetActionType perPkgTargetsMap\n . InstallPlan.toList\n $ elaboratedPlan\n\n-- | This is a temporary data type, where we temporarily\n-- override the graph dependencies of an 'ElaboratedPackage',\n-- so we can take a closure over them. We'll throw out the\n-- overriden dependencies when we're done so it's strictly temporary.\n--\n-- For 'ElaboratedComponent', this the cached unit IDs always\n-- coincide with the real thing.\ndata PrunedPackage = PrunedPackage ElaboratedConfiguredPackage [UnitId]\n\ninstance Package PrunedPackage where\n packageId (PrunedPackage elab _) = packageId elab\n\ninstance HasUnitId PrunedPackage where\n installedUnitId = nodeKey\n\ninstance IsNode PrunedPackage where\n type Key PrunedPackage = UnitId\n nodeKey (PrunedPackage elab _) = nodeKey elab\n nodeNeighbors (PrunedPackage _ deps) = deps\n\nfromPrunedPackage :: PrunedPackage -> ElaboratedConfiguredPackage\nfromPrunedPackage (PrunedPackage elab _) = elab\n\n-- | Set the build targets based on the user targets (but not rev deps yet).\n-- This is required before we can prune anything.\n--\nsetRootTargets :: TargetAction\n -> Map UnitId [ComponentTarget]\n -> [ElaboratedPlanPackage]\n -> [ElaboratedPlanPackage]\nsetRootTargets targetAction perPkgTargetsMap =\n assert (not (Map.null perPkgTargetsMap)) $\n assert (all (not . null) (Map.elems perPkgTargetsMap)) $\n\n map (mapConfiguredPackage setElabBuildTargets)\n where\n -- Set the targets we'll build for this package/component. This is just\n -- based on the root targets from the user, not targets implied by reverse\n -- dependencies. Those comes in the second pass once we know the rev deps.\n --\n setElabBuildTargets elab =\n case (Map.lookup (installedUnitId elab) perPkgTargetsMap,\n targetAction) of\n (Nothing, _) -> elab\n (Just tgts, TargetActionConfigure) -> elab { elabConfigureTargets = tgts }\n (Just tgts, TargetActionBuild) -> elab { elabBuildTargets = tgts }\n (Just tgts, TargetActionTest) -> elab { elabTestTargets = tgts }\n (Just tgts, TargetActionBench) -> elab { elabBenchTargets = tgts }\n (Just [tgt], TargetActionRepl) -> elab { elabReplTarget = Just tgt\n , elabBuildHaddocks = False }\n (Just tgts, TargetActionHaddock) ->\n foldr setElabHaddockTargets (elab { elabHaddockTargets = tgts\n , elabBuildHaddocks = True }) tgts\n (Just _, TargetActionRepl) ->\n error \"pruneInstallPlanToTargets: multiple repl targets\"\n\n setElabHaddockTargets tgt elab\n | isTestComponentTarget tgt = elab { elabHaddockTestSuites = True }\n | isBenchComponentTarget tgt = elab { elabHaddockBenchmarks = True }\n | isForeignLibComponentTarget tgt = elab { elabHaddockForeignLibs = True }\n | isExeComponentTarget tgt = elab { elabHaddockExecutables = True }\n | isSubLibComponentTarget tgt = elab { elabHaddockInternal = True }\n | otherwise = elab\n\n-- | Assuming we have previously set the root build targets (i.e. the user\n-- targets but not rev deps yet), the first pruning pass does two things:\n--\n-- * A first go at determining which optional stanzas (testsuites, benchmarks)\n-- are needed. We have a second go in the next pass.\n-- * Take the dependency closure using pruned dependencies. We prune deps that\n-- are used only by unneeded optional stanzas. These pruned deps are only\n-- used for the dependency closure and are not persisted in this pass.\n--\npruneInstallPlanPass1 :: [ElaboratedPlanPackage]\n -> [ElaboratedPlanPackage]\npruneInstallPlanPass1 pkgs =\n map (mapConfiguredPackage fromPrunedPackage)\n (fromMaybe [] $ Graph.closure graph roots)\n where\n pkgs' = map (mapConfiguredPackage prune) pkgs\n graph = Graph.fromDistinctList pkgs'\n roots = mapMaybe find_root pkgs'\n\n prune elab = PrunedPackage elab' (pruneOptionalDependencies elab')\n where elab' =\n setDocumentation\n $ addOptionalStanzas elab\n\n find_root (InstallPlan.Configured (PrunedPackage elab _)) =\n if not $ and [ null (elabConfigureTargets elab)\n , null (elabBuildTargets elab)\n , null (elabTestTargets elab)\n , null (elabBenchTargets elab)\n , isNothing (elabReplTarget elab)\n , null (elabHaddockTargets elab)\n ]\n then Just (installedUnitId elab)\n else Nothing\n find_root _ = Nothing\n\n -- Note [Sticky enabled testsuites]\n -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n -- The testsuite and benchmark targets are somewhat special in that we need\n -- to configure the packages with them enabled, and we need to do that even\n -- if we only want to build one of several testsuites.\n --\n -- There are two cases in which we will enable the testsuites (or\n -- benchmarks): if one of the targets is a testsuite, or if all of the\n -- testsuite dependencies are already cached in the store. The rationale\n -- for the latter is to minimise how often we have to reconfigure due to\n -- the particular targets we choose to build. Otherwise choosing to build\n -- a testsuite target, and then later choosing to build an exe target\n -- would involve unnecessarily reconfiguring the package with testsuites\n -- disabled. Technically this introduces a little bit of stateful\n -- behaviour to make this \"sticky\", but it should be benign.\n\n -- Decide whether or not to enable testsuites and benchmarks.\n -- See [Sticky enabled testsuites]\n addOptionalStanzas :: ElaboratedConfiguredPackage -> ElaboratedConfiguredPackage\n addOptionalStanzas elab@ElaboratedConfiguredPackage{ elabPkgOrComp = ElabPackage pkg } =\n elab {\n elabPkgOrComp = ElabPackage (pkg { pkgStanzasEnabled = stanzas })\n }\n where\n stanzas :: Set OptionalStanza\n -- By default, we enabled all stanzas requested by the user,\n -- as per elabStanzasRequested, done in\n -- 'elaborateSolverToPackage'\n stanzas = pkgStanzasEnabled pkg\n -- optionalStanzasRequiredByTargets has to be done at\n -- prune-time because it depends on 'elabTestTargets'\n -- et al, which is done by 'setRootTargets' at the\n -- beginning of pruning.\n <> optionalStanzasRequiredByTargets elab\n -- optionalStanzasWithDepsAvailable has to be done at\n -- prune-time because it depends on what packages are\n -- installed, which is not known until after improvement\n -- (pruning is done after improvement)\n <> optionalStanzasWithDepsAvailable availablePkgs elab pkg\n addOptionalStanzas elab = elab\n\n setDocumentation :: ElaboratedConfiguredPackage -> ElaboratedConfiguredPackage\n setDocumentation elab@ElaboratedConfiguredPackage { elabPkgOrComp = ElabComponent comp } =\n elab {\n elabBuildHaddocks =\n elabBuildHaddocks elab && documentationEnabled (compSolverName comp) elab\n }\n\n where\n documentationEnabled c =\n case c of\n CD.ComponentLib -> const True\n CD.ComponentSubLib _ -> elabHaddockInternal\n CD.ComponentFLib _ -> elabHaddockForeignLibs\n CD.ComponentExe _ -> elabHaddockExecutables\n CD.ComponentTest _ -> elabHaddockTestSuites\n CD.ComponentBench _ -> elabHaddockBenchmarks\n CD.ComponentSetup -> const False\n\n setDocumentation elab = elab\n\n -- Calculate package dependencies but cut out those needed only by\n -- optional stanzas that we've determined we will not enable.\n -- These pruned deps are not persisted in this pass since they're based on\n -- the optional stanzas and we'll make further tweaks to the optional\n -- stanzas in the next pass.\n --\n pruneOptionalDependencies :: ElaboratedConfiguredPackage -> [UnitId]\n pruneOptionalDependencies elab@ElaboratedConfiguredPackage{ elabPkgOrComp = ElabComponent _ }\n = InstallPlan.depends elab -- no pruning\n pruneOptionalDependencies ElaboratedConfiguredPackage{ elabPkgOrComp = ElabPackage pkg }\n = (CD.flatDeps . CD.filterDeps keepNeeded) (pkgOrderDependencies pkg)\n where\n keepNeeded (CD.ComponentTest _) _ = TestStanzas `Set.member` stanzas\n keepNeeded (CD.ComponentBench _) _ = BenchStanzas `Set.member` stanzas\n keepNeeded _ _ = True\n stanzas = pkgStanzasEnabled pkg\n\n optionalStanzasRequiredByTargets :: ElaboratedConfiguredPackage\n -> Set OptionalStanza\n optionalStanzasRequiredByTargets pkg =\n Set.fromList\n [ stanza\n | ComponentTarget cname _ <- elabBuildTargets pkg\n ++ elabTestTargets pkg\n ++ elabBenchTargets pkg\n ++ maybeToList (elabReplTarget pkg)\n ++ elabHaddockTargets pkg\n , stanza <- maybeToList $\n componentOptionalStanza $\n CD.componentNameToComponent cname\n ]\n\n availablePkgs =\n Set.fromList\n [ installedUnitId pkg\n | InstallPlan.PreExisting pkg <- pkgs ]\n\n-- | Given a set of already installed packages @availablePkgs@,\n-- determine the set of available optional stanzas from @pkg@\n-- which have all of their dependencies already installed. This is used\n-- to implement \"sticky\" testsuites, where once we have installed\n-- all of the deps needed for the test suite, we go ahead and\n-- enable it always.\noptionalStanzasWithDepsAvailable :: Set UnitId\n -> ElaboratedConfiguredPackage\n -> ElaboratedPackage\n -> Set OptionalStanza\noptionalStanzasWithDepsAvailable availablePkgs elab pkg =\n Set.fromList\n [ stanza\n | stanza <- Set.toList (elabStanzasAvailable elab)\n , let deps :: [UnitId]\n deps = CD.select (optionalStanzaDeps stanza)\n -- TODO: probably need to select other\n -- dep types too eventually\n (pkgOrderDependencies pkg)\n , all (`Set.member` availablePkgs) deps\n ]\n where\n optionalStanzaDeps TestStanzas (CD.ComponentTest _) = True\n optionalStanzaDeps BenchStanzas (CD.ComponentBench _) = True\n optionalStanzaDeps _ _ = False\n\n\n-- The second pass does three things:\n--\n-- * A second go at deciding which optional stanzas to enable.\n-- * Prune the dependencies based on the final choice of optional stanzas.\n-- * Extend the targets within each package to build, now we know the reverse\n-- dependencies, ie we know which libs are needed as deps by other packages.\n--\n-- Achieving sticky behaviour with enabling\\/disabling optional stanzas is\n-- tricky. The first approximation was handled by the first pass above, but\n-- it's not quite enough. That pass will enable stanzas if all of the deps\n-- of the optional stanza are already installed /in the store/. That's important\n-- but it does not account for dependencies that get built inplace as part of\n-- the project. We cannot take those inplace build deps into account in the\n-- pruning pass however because we don't yet know which ones we're going to\n-- build. Once we do know, we can have another go and enable stanzas that have\n-- all their deps available. Now we can consider all packages in the pruned\n-- plan to be available, including ones we already decided to build from\n-- source.\n--\n-- Deciding which targets to build depends on knowing which packages have\n-- reverse dependencies (ie are needed). This requires the result of first\n-- pass, which is another reason we have to split it into two passes.\n--\n-- Note that just because we might enable testsuites or benchmarks (in the\n-- first or second pass) doesn't mean that we build all (or even any) of them.\n-- That depends on which targets we picked in the first pass.\n--\npruneInstallPlanPass2 :: [ElaboratedPlanPackage]\n -> [ElaboratedPlanPackage]\npruneInstallPlanPass2 pkgs =\n map (mapConfiguredPackage setStanzasDepsAndTargets) pkgs\n where\n setStanzasDepsAndTargets elab =\n elab {\n elabBuildTargets = ordNub\n $ elabBuildTargets elab\n ++ libTargetsRequiredForRevDeps\n ++ exeTargetsRequiredForRevDeps,\n elabPkgOrComp =\n case elabPkgOrComp elab of\n ElabPackage pkg ->\n let stanzas = pkgStanzasEnabled pkg\n <> optionalStanzasWithDepsAvailable availablePkgs elab pkg\n keepNeeded (CD.ComponentTest _) _ = TestStanzas `Set.member` stanzas\n keepNeeded (CD.ComponentBench _) _ = BenchStanzas `Set.member` stanzas\n keepNeeded _ _ = True\n in ElabPackage $ pkg {\n pkgStanzasEnabled = stanzas,\n pkgLibDependencies = CD.filterDeps keepNeeded (pkgLibDependencies pkg),\n pkgExeDependencies = CD.filterDeps keepNeeded (pkgExeDependencies pkg),\n pkgExeDependencyPaths = CD.filterDeps keepNeeded (pkgExeDependencyPaths pkg)\n }\n r@(ElabComponent _) -> r\n }\n where\n libTargetsRequiredForRevDeps =\n [ ComponentTarget (CLibName Cabal.defaultLibName) WholeComponent\n | installedUnitId elab `Set.member` hasReverseLibDeps\n ]\n exeTargetsRequiredForRevDeps =\n -- TODO: allow requesting executable with different name\n -- than package name\n [ ComponentTarget (Cabal.CExeName\n $ packageNameToUnqualComponentName\n $ packageName $ elabPkgSourceId elab)\n WholeComponent\n | installedUnitId elab `Set.member` hasReverseExeDeps\n ]\n\n\n availablePkgs :: Set UnitId\n availablePkgs = Set.fromList (map installedUnitId pkgs)\n\n hasReverseLibDeps :: Set UnitId\n hasReverseLibDeps =\n Set.fromList [ depid\n | InstallPlan.Configured pkg <- pkgs\n , depid <- elabOrderLibDependencies pkg ]\n\n hasReverseExeDeps :: Set UnitId\n hasReverseExeDeps =\n Set.fromList [ depid\n | InstallPlan.Configured pkg <- pkgs\n , depid <- elabOrderExeDependencies pkg ]\n\nmapConfiguredPackage :: (srcpkg -> srcpkg')\n -> InstallPlan.GenericPlanPackage ipkg srcpkg\n -> InstallPlan.GenericPlanPackage ipkg srcpkg'\nmapConfiguredPackage f (InstallPlan.Configured pkg) =\n InstallPlan.Configured (f pkg)\nmapConfiguredPackage f (InstallPlan.Installed pkg) =\n InstallPlan.Installed (f pkg)\nmapConfiguredPackage _ (InstallPlan.PreExisting pkg) =\n InstallPlan.PreExisting pkg\n\n------------------------------------\n-- Support for --only-dependencies\n--\n\n-- | Try to remove the given targets from the install plan.\n--\n-- This is not always possible.\n--\npruneInstallPlanToDependencies :: Set UnitId\n -> ElaboratedInstallPlan\n -> Either CannotPruneDependencies\n ElaboratedInstallPlan\npruneInstallPlanToDependencies pkgTargets installPlan =\n assert (all (isJust . InstallPlan.lookup installPlan)\n (Set.toList pkgTargets)) $\n\n fmap (InstallPlan.new (InstallPlan.planIndepGoals installPlan))\n . checkBrokenDeps\n . Graph.fromDistinctList\n . filter (\\pkg -> installedUnitId pkg `Set.notMember` pkgTargets)\n . InstallPlan.toList\n $ installPlan\n where\n -- Our strategy is to remove the packages we don't want and then check\n -- if the remaining graph is broken or not, ie any packages with dangling\n -- dependencies. If there are then we cannot prune the given targets.\n checkBrokenDeps :: Graph.Graph ElaboratedPlanPackage\n -> Either CannotPruneDependencies\n (Graph.Graph ElaboratedPlanPackage)\n checkBrokenDeps graph =\n case Graph.broken graph of\n [] -> Right graph\n brokenPackages ->\n Left $ CannotPruneDependencies\n [ (pkg, missingDeps)\n | (pkg, missingDepIds) <- brokenPackages\n , let missingDeps = mapMaybe lookupDep missingDepIds\n ]\n where\n -- lookup in the original unpruned graph\n lookupDep = InstallPlan.lookup installPlan\n\n-- | It is not always possible to prune to only the dependencies of a set of\n-- targets. It may be the case that removing a package leaves something else\n-- that still needed the pruned package.\n--\n-- This lists all the packages that would be broken, and their dependencies\n-- that would be missing if we did prune.\n--\nnewtype CannotPruneDependencies =\n CannotPruneDependencies [(ElaboratedPlanPackage,\n [ElaboratedPlanPackage])]\n deriving (Show)\n\n\n---------------------------\n-- Setup.hs script policy\n--\n\n-- Handling for Setup.hs scripts is a bit tricky, part of it lives in the\n-- solver phase, and part in the elaboration phase. We keep the helper\n-- functions for both phases together here so at least you can see all of it\n-- in one place.\n--\n-- There are four major cases for Setup.hs handling:\n--\n-- 1. @build-type@ Custom with a @custom-setup@ section\n-- 2. @build-type@ Custom without a @custom-setup@ section\n-- 3. @build-type@ not Custom with @cabal-version > $our-cabal-version@\n-- 4. @build-type@ not Custom with @cabal-version <= $our-cabal-version@\n--\n-- It's also worth noting that packages specifying @cabal-version: >= 1.23@\n-- or later that have @build-type@ Custom will always have a @custom-setup@\n-- section. Therefore in case 2, the specified @cabal-version@ will always be\n-- less than 1.23.\n--\n-- In cases 1 and 2 we obviously have to build an external Setup.hs script,\n-- while in case 4 we can use the internal library API. In case 3 we also have\n-- to build an external Setup.hs script because the package needs a later\n-- Cabal lib version than we can support internally.\n--\n-- data SetupScriptStyle = ... -- see ProjectPlanning.Types\n\n-- | Work out the 'SetupScriptStyle' given the package description.\n--\npackageSetupScriptStyle :: PD.PackageDescription -> SetupScriptStyle\npackageSetupScriptStyle pkg\n | buildType == PD.Custom\n , Just setupbi <- PD.setupBuildInfo pkg -- does have a custom-setup stanza\n , not (PD.defaultSetupDepends setupbi) -- but not one we added internally\n = SetupCustomExplicitDeps\n\n | buildType == PD.Custom\n , Just setupbi <- PD.setupBuildInfo pkg -- we get this case post-solver as\n , PD.defaultSetupDepends setupbi -- the solver fills in the deps\n = SetupCustomImplicitDeps\n\n | buildType == PD.Custom\n , Nothing <- PD.setupBuildInfo pkg -- we get this case pre-solver\n = SetupCustomImplicitDeps\n\n | PD.specVersion pkg > cabalVersion -- one cabal-install is built against\n = SetupNonCustomExternalLib\n\n | otherwise\n = SetupNonCustomInternalLib\n where\n buildType = PD.buildType pkg\n\n\n-- | Part of our Setup.hs handling policy is implemented by getting the solver\n-- to work out setup dependencies for packages. The solver already handles\n-- packages that explicitly specify setup dependencies, but we can also tell\n-- the solver to treat other packages as if they had setup dependencies.\n-- That's what this function does, it gets called by the solver for all\n-- packages that don't already have setup dependencies.\n--\n-- The dependencies we want to add is different for each 'SetupScriptStyle'.\n--\n-- Note that adding default deps means these deps are actually /added/ to the\n-- packages that we get out of the solver in the 'SolverInstallPlan'. Making\n-- implicit setup deps explicit is a problem in the post-solver stages because\n-- we still need to distinguish the case of explicit and implict setup deps.\n-- See 'rememberImplicitSetupDeps'.\n--\n-- Note in addition to adding default setup deps, we also use\n-- 'addSetupCabalMinVersionConstraint' (in 'planPackages') to require\n-- @Cabal >= 1.20@ for Setup scripts.\n--\ndefaultSetupDeps :: Compiler -> Platform\n -> PD.PackageDescription\n -> Maybe [Dependency]\ndefaultSetupDeps compiler platform pkg =\n case packageSetupScriptStyle pkg of\n\n -- For packages with build type custom that do not specify explicit\n -- setup dependencies, we add a dependency on Cabal and a number\n -- of other packages.\n SetupCustomImplicitDeps ->\n Just $\n [ Dependency depPkgname anyVersion (Set.singleton LMainLibName)\n | depPkgname <- legacyCustomSetupPkgs compiler platform ] ++\n [ Dependency cabalPkgname cabalConstraint (Set.singleton LMainLibName)\n | packageName pkg /= cabalPkgname ]\n where\n -- The Cabal dep is slightly special:\n -- * We omit the dep for the Cabal lib itself, since it bootstraps.\n -- * We constrain it to be < 1.25\n --\n -- Note: we also add a global constraint to require Cabal >= 1.20\n -- for Setup scripts (see use addSetupCabalMinVersionConstraint).\n --\n cabalConstraint = orLaterVersion (PD.specVersion pkg)\n `intersectVersionRanges`\n earlierVersion cabalCompatMaxVer\n -- The idea here is that at some point we will make significant\n -- breaking changes to the Cabal API that Setup.hs scripts use.\n -- So for old custom Setup scripts that do not specify explicit\n -- constraints, we constrain them to use a compatible Cabal version.\n cabalCompatMaxVer = mkVersion [1,25]\n\n -- For other build types (like Simple) if we still need to compile an\n -- external Setup.hs, it'll be one of the simple ones that only depends\n -- on Cabal and base.\n SetupNonCustomExternalLib ->\n Just [ Dependency cabalPkgname cabalConstraint (Set.singleton LMainLibName)\n , Dependency basePkgname anyVersion (Set.singleton LMainLibName)]\n where\n cabalConstraint = orLaterVersion (PD.specVersion pkg)\n\n -- The internal setup wrapper method has no deps at all.\n SetupNonCustomInternalLib -> Just []\n\n -- This case gets ruled out by the caller, planPackages, see the note\n -- above in the SetupCustomImplicitDeps case.\n SetupCustomExplicitDeps ->\n error $ \"defaultSetupDeps: called for a package with explicit \"\n ++ \"setup deps: \" ++ display (packageId pkg)\n\n\n-- | Work out which version of the Cabal spec we will be using to talk to the\n-- Setup.hs interface for this package.\n--\n-- This depends somewhat on the 'SetupScriptStyle' but most cases are a result\n-- of what the solver picked for us, based on the explicit setup deps or the\n-- ones added implicitly by 'defaultSetupDeps'.\n--\npackageSetupScriptSpecVersion :: SetupScriptStyle\n -> PD.PackageDescription\n -> Graph.Graph NonSetupLibDepSolverPlanPackage\n -> ComponentDeps [SolverId]\n -> Version\n\n-- We're going to be using the internal Cabal library, so the spec version of\n-- that is simply the version of the Cabal library that cabal-install has been\n-- built with.\npackageSetupScriptSpecVersion SetupNonCustomInternalLib _ _ _ =\n cabalVersion\n\n-- If we happen to be building the Cabal lib itself then because that\n-- bootstraps itself then we use the version of the lib we're building.\npackageSetupScriptSpecVersion SetupCustomImplicitDeps pkg _ _\n | packageName pkg == cabalPkgname\n = packageVersion pkg\n\n-- In all other cases we have a look at what version of the Cabal lib the\n-- solver picked. Or if it didn't depend on Cabal at all (which is very rare)\n-- then we look at the .cabal file to see what spec version it declares.\npackageSetupScriptSpecVersion _ pkg libDepGraph deps =\n case find ((cabalPkgname ==) . packageName) setupLibDeps of\n Just dep -> packageVersion dep\n Nothing -> PD.specVersion pkg\n where\n setupLibDeps = map packageId $ fromMaybe [] $\n Graph.closure libDepGraph (CD.setupDeps deps)\n\n\ncabalPkgname, basePkgname :: PackageName\ncabalPkgname = mkPackageName \"Cabal\"\nbasePkgname = mkPackageName \"base\"\n\n\nlegacyCustomSetupPkgs :: Compiler -> Platform -> [PackageName]\nlegacyCustomSetupPkgs compiler (Platform _ os) =\n map mkPackageName $\n [ \"array\", \"base\", \"binary\", \"bytestring\", \"containers\"\n , \"deepseq\", \"directory\", \"filepath\", \"old-time\", \"pretty\"\n , \"process\", \"time\", \"transformers\" ]\n ++ [ \"Win32\" | os == Windows ]\n ++ [ \"unix\" | os /= Windows ]\n ++ [ \"ghc-prim\" | isGHC ]\n ++ [ \"template-haskell\" | isGHC ]\n where\n isGHC = compilerCompatFlavor GHC compiler\n\n-- The other aspects of our Setup.hs policy lives here where we decide on\n-- the 'SetupScriptOptions'.\n--\n-- Our current policy for the 'SetupCustomImplicitDeps' case is that we\n-- try to make the implicit deps cover everything, and we don't allow the\n-- compiler to pick up other deps. This may or may not be sustainable, and\n-- we might have to allow the deps to be non-exclusive, but that itself would\n-- be tricky since we would have to allow the Setup access to all the packages\n-- in the store and local dbs.\n\nsetupHsScriptOptions :: ElaboratedReadyPackage\n -> ElaboratedInstallPlan\n -> ElaboratedSharedConfig\n -> DistDirLayout\n -> FilePath\n -> FilePath\n -> Bool\n -> Lock\n -> SetupScriptOptions\n-- TODO: Fix this so custom is a separate component. Custom can ALWAYS\n-- be a separate component!!!\nsetupHsScriptOptions (ReadyPackage elab@ElaboratedConfiguredPackage{..})\n plan ElaboratedSharedConfig{..} distdir srcdir builddir\n isParallelBuild cacheLock =\n SetupScriptOptions {\n useCabalVersion = thisVersion elabSetupScriptCliVersion,\n useCabalSpecVersion = Just elabSetupScriptCliVersion,\n useCompiler = Just pkgConfigCompiler,\n usePlatform = Just pkgConfigPlatform,\n usePackageDB = elabSetupPackageDBStack,\n usePackageIndex = Nothing,\n useDependencies = [ (uid, srcid)\n | ConfiguredId srcid (Just (CLibName LMainLibName)) uid\n <- elabSetupDependencies elab ],\n useDependenciesExclusive = True,\n useVersionMacros = elabSetupScriptStyle == SetupCustomExplicitDeps,\n useProgramDb = pkgConfigCompilerProgs,\n useDistPref = builddir,\n useLoggingHandle = Nothing, -- this gets set later\n useWorkingDir = Just srcdir,\n useExtraPathEnv = elabExeDependencyPaths elab,\n useExtraEnvOverrides = dataDirsEnvironmentForPlan distdir plan,\n useWin32CleanHack = False, --TODO: [required eventually]\n forceExternalSetupMethod = isParallelBuild,\n setupCacheLock = Just cacheLock,\n isInteractive = False\n }\n\n\n-- | To be used for the input for elaborateInstallPlan.\n--\n-- TODO: [code cleanup] make InstallDirs.defaultInstallDirs pure.\n--\nuserInstallDirTemplates :: Compiler\n -> IO InstallDirs.InstallDirTemplates\nuserInstallDirTemplates compiler = do\n InstallDirs.defaultInstallDirs\n (compilerFlavor compiler)\n True -- user install\n False -- unused\n\nstorePackageInstallDirs :: StoreDirLayout\n -> CompilerId\n -> InstalledPackageId\n -> InstallDirs.InstallDirs FilePath\nstorePackageInstallDirs storeDirLayout compid ipkgid =\n storePackageInstallDirs' storeDirLayout compid $ newSimpleUnitId ipkgid\n\nstorePackageInstallDirs' :: StoreDirLayout\n -> CompilerId\n -> UnitId\n -> InstallDirs.InstallDirs FilePath\nstorePackageInstallDirs' StoreDirLayout{ storePackageDirectory\n , storeDirectory }\n compid unitid =\n InstallDirs.InstallDirs {..}\n where\n store = storeDirectory compid\n prefix = storePackageDirectory compid unitid\n bindir = prefix \"bin\"\n libdir = prefix \"lib\"\n libsubdir = \"\"\n -- Note: on macOS, we place libraries into\n -- @store/lib@ to work around the load\n -- command size limit of macOSs mach-o linker.\n -- See also @PackageHash.hashedInstalledPackageIdVeryShort@\n dynlibdir | buildOS == OSX = store \"lib\"\n | otherwise = libdir\n flibdir = libdir\n libexecdir = prefix \"libexec\"\n libexecsubdir= \"\"\n includedir = libdir \"include\"\n datadir = prefix \"share\"\n datasubdir = \"\"\n docdir = datadir \"doc\"\n mandir = datadir \"man\"\n htmldir = docdir \"html\"\n haddockdir = htmldir\n sysconfdir = prefix \"etc\"\n\n\n\ncomputeInstallDirs :: StoreDirLayout\n -> InstallDirs.InstallDirTemplates\n -> ElaboratedSharedConfig\n -> ElaboratedConfiguredPackage\n -> InstallDirs.InstallDirs FilePath\ncomputeInstallDirs storeDirLayout defaultInstallDirs elaboratedShared elab\n | elabBuildStyle elab == BuildInplaceOnly\n -- use the ordinary default install dirs\n = (InstallDirs.absoluteInstallDirs\n (elabPkgSourceId elab)\n (elabUnitId elab)\n (compilerInfo (pkgConfigCompiler elaboratedShared))\n InstallDirs.NoCopyDest\n (pkgConfigPlatform elaboratedShared)\n defaultInstallDirs) {\n\n -- absoluteInstallDirs sets these as 'undefined' but we have\n -- to use them as \"Setup.hs configure\" args\n InstallDirs.libsubdir = \"\",\n InstallDirs.libexecsubdir = \"\",\n InstallDirs.datasubdir = \"\"\n }\n\n | otherwise\n -- use special simplified install dirs\n = storePackageInstallDirs'\n storeDirLayout\n (compilerId (pkgConfigCompiler elaboratedShared))\n (elabUnitId elab)\n\n\n--TODO: [code cleanup] perhaps reorder this code\n-- based on the ElaboratedInstallPlan + ElaboratedSharedConfig,\n-- make the various Setup.hs {configure,build,copy} flags\n\n\nsetupHsConfigureFlags :: ElaboratedReadyPackage\n -> ElaboratedSharedConfig\n -> Verbosity\n -> FilePath\n -> Cabal.ConfigFlags\nsetupHsConfigureFlags (ReadyPackage elab@ElaboratedConfiguredPackage{..})\n sharedConfig@ElaboratedSharedConfig{..}\n verbosity builddir =\n sanityCheckElaboratedConfiguredPackage sharedConfig elab\n (Cabal.ConfigFlags {..})\n where\n configArgs = mempty -- unused, passed via args\n configDistPref = toFlag builddir\n configCabalFilePath = mempty\n configVerbosity = toFlag verbosity\n\n configInstantiateWith = Map.toList elabInstantiatedWith\n\n configDeterministic = mempty -- doesn't matter, configIPID/configCID overridese\n configIPID = case elabPkgOrComp of\n ElabPackage pkg -> toFlag (display (pkgInstalledId pkg))\n ElabComponent _ -> mempty\n configCID = case elabPkgOrComp of\n ElabPackage _ -> mempty\n ElabComponent _ -> toFlag elabComponentId\n\n configProgramPaths = Map.toList elabProgramPaths\n configProgramArgs\n | {- elabSetupScriptCliVersion < mkVersion [1,24,3] -} True\n -- workaround for \n --\n -- It turns out, that even with Cabal 2.0, there's still cases such as e.g.\n -- custom Setup.hs scripts calling out to GHC even when going via\n -- @runProgram ghcProgram@, as e.g. happy does in its\n -- \n -- (see also )\n --\n -- So for now, let's pass the rather harmless and idempotent\n -- `-hide-all-packages` flag to all invocations (which has\n -- the benefit that every GHC invocation starts with a\n -- conistently well-defined clean slate) until we find a\n -- better way.\n = Map.toList $\n Map.insertWith (++) \"ghc\" [\"-hide-all-packages\"]\n elabProgramArgs\n | otherwise = Map.toList elabProgramArgs\n configProgramPathExtra = toNubList elabProgramPathExtra\n configHcFlavor = toFlag (compilerFlavor pkgConfigCompiler)\n configHcPath = mempty -- we use configProgramPaths instead\n configHcPkg = mempty -- we use configProgramPaths instead\n\n configVanillaLib = toFlag elabVanillaLib\n configSharedLib = toFlag elabSharedLib\n configStaticLib = toFlag elabStaticLib\n\n configDynExe = toFlag elabDynExe\n configFullyStaticExe = toFlag elabFullyStaticExe\n configGHCiLib = toFlag elabGHCiLib\n configProfExe = mempty\n configProfLib = toFlag elabProfLib\n configProf = toFlag elabProfExe\n\n -- configProfDetail is for exe+lib, but overridden by configProfLibDetail\n -- so we specify both so we can specify independently\n configProfDetail = toFlag elabProfExeDetail\n configProfLibDetail = toFlag elabProfLibDetail\n\n configCoverage = toFlag elabCoverage\n configLibCoverage = mempty\n\n configOptimization = toFlag elabOptimization\n configSplitSections = toFlag elabSplitSections\n configSplitObjs = toFlag elabSplitObjs\n configStripExes = toFlag elabStripExes\n configStripLibs = toFlag elabStripLibs\n configDebugInfo = toFlag elabDebugInfo\n\n configConfigurationsFlags = elabFlagAssignment\n configConfigureArgs = elabConfigureScriptArgs\n configExtraLibDirs = elabExtraLibDirs\n configExtraFrameworkDirs = elabExtraFrameworkDirs\n configExtraIncludeDirs = elabExtraIncludeDirs\n configProgPrefix = maybe mempty toFlag elabProgPrefix\n configProgSuffix = maybe mempty toFlag elabProgSuffix\n\n configInstallDirs = fmap (toFlag . InstallDirs.toPathTemplate)\n elabInstallDirs\n\n -- we only use configDependencies, unless we're talking to an old Cabal\n -- in which case we use configConstraints\n -- NB: This does NOT use InstallPlan.depends, which includes executable\n -- dependencies which should NOT be fed in here (also you don't have\n -- enough info anyway)\n configDependencies = [ GivenComponent\n (packageName srcid)\n ln\n cid\n | ConfiguredId srcid mb_cn cid <- elabLibDependencies elab\n , let ln = case mb_cn\n of Just (CLibName lname) -> lname\n Just _ -> error \"non-library dependency\"\n Nothing -> LMainLibName\n ]\n configConstraints =\n case elabPkgOrComp of\n ElabPackage _ ->\n [ thisPackageVersion srcid\n | ConfiguredId srcid _ _uid <- elabLibDependencies elab ]\n ElabComponent _ -> []\n\n\n -- explicitly clear, then our package db stack\n -- TODO: [required eventually] have to do this differently for older Cabal versions\n configPackageDBs = Nothing : map Just elabBuildPackageDBStack\n\n configTests = case elabPkgOrComp of\n ElabPackage pkg -> toFlag (TestStanzas `Set.member` pkgStanzasEnabled pkg)\n ElabComponent _ -> mempty\n configBenchmarks = case elabPkgOrComp of\n ElabPackage pkg -> toFlag (BenchStanzas `Set.member` pkgStanzasEnabled pkg)\n ElabComponent _ -> mempty\n\n configExactConfiguration = toFlag True\n configFlagError = mempty --TODO: [research required] appears not to be implemented\n configRelocatable = mempty --TODO: [research required] ???\n configScratchDir = mempty -- never use\n configUserInstall = mempty -- don't rely on defaults\n configPrograms_ = mempty -- never use, shouldn't exist\n configUseResponseFiles = mempty\n -- TODO set to true when the solver can prevent private-library-deps by itself\n -- (issue #6039)\n configAllowDependingOnPrivateLibs = mempty\n\nsetupHsConfigureArgs :: ElaboratedConfiguredPackage\n -> [String]\nsetupHsConfigureArgs (ElaboratedConfiguredPackage { elabPkgOrComp = ElabPackage _ }) = []\nsetupHsConfigureArgs elab@(ElaboratedConfiguredPackage { elabPkgOrComp = ElabComponent comp }) =\n [showComponentTarget (packageId elab) (ComponentTarget cname WholeComponent)]\n where\n cname = fromMaybe (error \"setupHsConfigureArgs: trying to configure setup\")\n (compComponentName comp)\n\nsetupHsBuildFlags :: ElaboratedConfiguredPackage\n -> ElaboratedSharedConfig\n -> Verbosity\n -> FilePath\n -> Cabal.BuildFlags\nsetupHsBuildFlags _ _ verbosity builddir =\n Cabal.BuildFlags {\n buildProgramPaths = mempty, --unused, set at configure time\n buildProgramArgs = mempty, --unused, set at configure time\n buildVerbosity = toFlag verbosity,\n buildDistPref = toFlag builddir,\n buildNumJobs = mempty, --TODO: [nice to have] sometimes want to use toFlag (Just numBuildJobs),\n buildArgs = mempty, -- unused, passed via args not flags\n buildCabalFilePath= mempty\n }\n\n\nsetupHsBuildArgs :: ElaboratedConfiguredPackage -> [String]\nsetupHsBuildArgs elab@(ElaboratedConfiguredPackage { elabPkgOrComp = ElabPackage _ })\n -- Fix for #3335, don't pass build arguments if it's not supported\n | elabSetupScriptCliVersion elab >= mkVersion [1,17]\n = map (showComponentTarget (packageId elab)) (elabBuildTargets elab)\n | otherwise\n = []\nsetupHsBuildArgs (ElaboratedConfiguredPackage { elabPkgOrComp = ElabComponent _ })\n = []\n\n\nsetupHsTestFlags :: ElaboratedConfiguredPackage\n -> ElaboratedSharedConfig\n -> Verbosity\n -> FilePath\n -> Cabal.TestFlags\nsetupHsTestFlags (ElaboratedConfiguredPackage{..}) _ verbosity builddir = Cabal.TestFlags\n { testDistPref = toFlag builddir\n , testVerbosity = toFlag verbosity\n , testMachineLog = maybe mempty toFlag elabTestMachineLog\n , testHumanLog = maybe mempty toFlag elabTestHumanLog\n , testShowDetails = maybe (Flag Cabal.Always) toFlag elabTestShowDetails\n , testKeepTix = toFlag elabTestKeepTix\n , testWrapper = maybe mempty toFlag elabTestWrapper\n , testFailWhenNoTestSuites = toFlag elabTestFailWhenNoTestSuites\n , testOptions = elabTestTestOptions\n }\n\nsetupHsTestArgs :: ElaboratedConfiguredPackage -> [String]\n-- TODO: Does the issue #3335 affects test as well\nsetupHsTestArgs elab =\n mapMaybe (showTestComponentTarget (packageId elab)) (elabTestTargets elab)\n\n\nsetupHsBenchFlags :: ElaboratedConfiguredPackage\n -> ElaboratedSharedConfig\n -> Verbosity\n -> FilePath\n -> Cabal.BenchmarkFlags\nsetupHsBenchFlags (ElaboratedConfiguredPackage{..}) _ verbosity builddir = Cabal.BenchmarkFlags\n { benchmarkDistPref = toFlag builddir\n , benchmarkVerbosity = toFlag verbosity\n , benchmarkOptions = elabBenchmarkOptions\n }\n\nsetupHsBenchArgs :: ElaboratedConfiguredPackage -> [String]\nsetupHsBenchArgs elab =\n mapMaybe (showBenchComponentTarget (packageId elab)) (elabBenchTargets elab)\n\n\nsetupHsReplFlags :: ElaboratedConfiguredPackage\n -> ElaboratedSharedConfig\n -> Verbosity\n -> FilePath\n -> Cabal.ReplFlags\nsetupHsReplFlags _ sharedConfig verbosity builddir =\n Cabal.ReplFlags {\n replProgramPaths = mempty, --unused, set at configure time\n replProgramArgs = mempty, --unused, set at configure time\n replVerbosity = toFlag verbosity,\n replDistPref = toFlag builddir,\n replReload = mempty, --only used as callback from repl\n replReplOptions = pkgConfigReplOptions sharedConfig --runtime override for repl flags\n }\n\n\nsetupHsReplArgs :: ElaboratedConfiguredPackage -> [String]\nsetupHsReplArgs elab =\n maybe [] (\\t -> [showComponentTarget (packageId elab) t]) (elabReplTarget elab)\n --TODO: should be able to give multiple modules in one component\n\n\nsetupHsCopyFlags :: ElaboratedConfiguredPackage\n -> ElaboratedSharedConfig\n -> Verbosity\n -> FilePath\n -> FilePath\n -> Cabal.CopyFlags\nsetupHsCopyFlags _ _ verbosity builddir destdir =\n Cabal.CopyFlags {\n copyArgs = [], -- TODO: could use this to only copy what we enabled\n copyDest = toFlag (InstallDirs.CopyTo destdir),\n copyDistPref = toFlag builddir,\n copyVerbosity = toFlag verbosity,\n copyCabalFilePath = mempty\n }\n\nsetupHsRegisterFlags :: ElaboratedConfiguredPackage\n -> ElaboratedSharedConfig\n -> Verbosity\n -> FilePath\n -> FilePath\n -> Cabal.RegisterFlags\nsetupHsRegisterFlags ElaboratedConfiguredPackage{..} _\n verbosity builddir pkgConfFile =\n Cabal.RegisterFlags {\n regPackageDB = mempty, -- misfeature\n regGenScript = mempty, -- never use\n regGenPkgConf = toFlag (Just pkgConfFile),\n regInPlace = case elabBuildStyle of\n BuildInplaceOnly -> toFlag True\n _ -> toFlag False,\n regPrintId = mempty, -- never use\n regDistPref = toFlag builddir,\n regArgs = [],\n regVerbosity = toFlag verbosity,\n regCabalFilePath = mempty\n }\n\nsetupHsHaddockFlags :: ElaboratedConfiguredPackage\n -> ElaboratedSharedConfig\n -> Verbosity\n -> FilePath\n -> Cabal.HaddockFlags\nsetupHsHaddockFlags (ElaboratedConfiguredPackage{..}) _ verbosity builddir =\n Cabal.HaddockFlags {\n haddockProgramPaths = mempty, --unused, set at configure time\n haddockProgramArgs = mempty, --unused, set at configure time\n haddockHoogle = toFlag elabHaddockHoogle,\n haddockHtml = toFlag elabHaddockHtml,\n haddockHtmlLocation = maybe mempty toFlag elabHaddockHtmlLocation,\n haddockForHackage = toFlag elabHaddockForHackage,\n haddockForeignLibs = toFlag elabHaddockForeignLibs,\n haddockExecutables = toFlag elabHaddockExecutables,\n haddockTestSuites = toFlag elabHaddockTestSuites,\n haddockBenchmarks = toFlag elabHaddockBenchmarks,\n haddockInternal = toFlag elabHaddockInternal,\n haddockCss = maybe mempty toFlag elabHaddockCss,\n haddockLinkedSource = toFlag elabHaddockLinkedSource,\n haddockQuickJump = toFlag elabHaddockQuickJump,\n haddockHscolourCss = maybe mempty toFlag elabHaddockHscolourCss,\n haddockContents = maybe mempty toFlag elabHaddockContents,\n haddockDistPref = toFlag builddir,\n haddockKeepTempFiles = mempty, --TODO: from build settings\n haddockVerbosity = toFlag verbosity,\n haddockCabalFilePath = mempty,\n haddockArgs = mempty\n }\n\nsetupHsHaddockArgs :: ElaboratedConfiguredPackage -> [String]\n-- TODO: Does the issue #3335 affects test as well\nsetupHsHaddockArgs elab =\n map (showComponentTarget (packageId elab)) (elabHaddockTargets elab)\n\n{-\nsetupHsTestFlags :: ElaboratedConfiguredPackage\n -> ElaboratedSharedConfig\n -> Verbosity\n -> FilePath\n -> Cabal.TestFlags\nsetupHsTestFlags _ _ verbosity builddir =\n Cabal.TestFlags {\n }\n-}\n\n------------------------------------------------------------------------------\n-- * Sharing installed packages\n------------------------------------------------------------------------------\n\n--\n-- Nix style store management for tarball packages\n--\n-- So here's our strategy:\n--\n-- We use a per-user nix-style hashed store, but /only/ for tarball packages.\n-- So that includes packages from hackage repos (and other http and local\n-- tarballs). For packages in local directories we do not register them into\n-- the shared store by default, we just build them locally inplace.\n--\n-- The reason we do it like this is that it's easy to make stable hashes for\n-- tarball packages, and these packages benefit most from sharing. By contrast\n-- unpacked dir packages are harder to hash and they tend to change more\n-- frequently so there's less benefit to sharing them.\n--\n-- When using the nix store approach we have to run the solver *without*\n-- looking at the packages installed in the store, just at the source packages\n-- (plus core\\/global installed packages). Then we do a post-processing pass\n-- to replace configured packages in the plan with pre-existing ones, where\n-- possible. Where possible of course means where the nix-style package hash\n-- equals one that's already in the store.\n--\n-- One extra wrinkle is that unless we know package tarball hashes upfront, we\n-- will have to download the tarballs to find their hashes. So we have two\n-- options: delay replacing source with pre-existing installed packages until\n-- the point during the execution of the install plan where we have the\n-- tarball, or try to do as much up-front as possible and then check again\n-- during plan execution. The former isn't great because we would end up\n-- telling users we're going to re-install loads of packages when in fact we\n-- would just share them. It'd be better to give as accurate a prediction as\n-- we can. The latter is better for users, but we do still have to check\n-- during plan execution because it's important that we don't replace existing\n-- installed packages even if they have the same package hash, because we\n-- don't guarantee ABI stability.\n\n-- TODO: [required eventually] for safety of concurrent installs, we must make sure we register but\n-- not replace installed packages with ghc-pkg.\n\npackageHashInputs :: ElaboratedSharedConfig\n -> ElaboratedConfiguredPackage\n -> PackageHashInputs\npackageHashInputs\n pkgshared\n elab@(ElaboratedConfiguredPackage {\n elabPkgSourceHash = Just srchash\n }) =\n PackageHashInputs {\n pkgHashPkgId = packageId elab,\n pkgHashComponent =\n case elabPkgOrComp elab of\n ElabPackage _ -> Nothing\n ElabComponent comp -> Just (compSolverName comp),\n pkgHashSourceHash = srchash,\n pkgHashPkgConfigDeps = Set.fromList (elabPkgConfigDependencies elab),\n pkgHashDirectDeps =\n case elabPkgOrComp elab of\n ElabPackage (ElaboratedPackage{..}) ->\n Set.fromList $\n [ confInstId dep\n | dep <- CD.select relevantDeps pkgLibDependencies ] ++\n [ confInstId dep\n | dep <- CD.select relevantDeps pkgExeDependencies ]\n ElabComponent comp ->\n Set.fromList (map confInstId (compLibDependencies comp\n ++ compExeDependencies comp)),\n pkgHashOtherConfig = packageHashConfigInputs pkgshared elab\n }\n where\n -- Obviously the main deps are relevant\n relevantDeps CD.ComponentLib = True\n relevantDeps (CD.ComponentSubLib _) = True\n relevantDeps (CD.ComponentFLib _) = True\n relevantDeps (CD.ComponentExe _) = True\n -- Setup deps can affect the Setup.hs behaviour and thus what is built\n relevantDeps CD.ComponentSetup = True\n -- However testsuites and benchmarks do not get installed and should not\n -- affect the result, so we do not include them.\n relevantDeps (CD.ComponentTest _) = False\n relevantDeps (CD.ComponentBench _) = False\n\npackageHashInputs _ pkg =\n error $ \"packageHashInputs: only for packages with source hashes. \"\n ++ display (packageId pkg)\n\npackageHashConfigInputs :: ElaboratedSharedConfig\n -> ElaboratedConfiguredPackage\n -> PackageHashConfigInputs\npackageHashConfigInputs shared@ElaboratedSharedConfig{..} pkg =\n PackageHashConfigInputs {\n pkgHashCompilerId = compilerId pkgConfigCompiler,\n pkgHashPlatform = pkgConfigPlatform,\n pkgHashFlagAssignment = elabFlagAssignment,\n pkgHashConfigureScriptArgs = elabConfigureScriptArgs,\n pkgHashVanillaLib = elabVanillaLib,\n pkgHashSharedLib = elabSharedLib,\n pkgHashDynExe = elabDynExe,\n pkgHashFullyStaticExe = elabFullyStaticExe,\n pkgHashGHCiLib = elabGHCiLib,\n pkgHashProfLib = elabProfLib,\n pkgHashProfExe = elabProfExe,\n pkgHashProfLibDetail = elabProfLibDetail,\n pkgHashProfExeDetail = elabProfExeDetail,\n pkgHashCoverage = elabCoverage,\n pkgHashOptimization = elabOptimization,\n pkgHashSplitSections = elabSplitSections,\n pkgHashSplitObjs = elabSplitObjs,\n pkgHashStripLibs = elabStripLibs,\n pkgHashStripExes = elabStripExes,\n pkgHashDebugInfo = elabDebugInfo,\n pkgHashProgramArgs = elabProgramArgs,\n pkgHashExtraLibDirs = elabExtraLibDirs,\n pkgHashExtraFrameworkDirs = elabExtraFrameworkDirs,\n pkgHashExtraIncludeDirs = elabExtraIncludeDirs,\n pkgHashProgPrefix = elabProgPrefix,\n pkgHashProgSuffix = elabProgSuffix,\n\n pkgHashDocumentation = elabBuildHaddocks,\n pkgHashHaddockHoogle = elabHaddockHoogle,\n pkgHashHaddockHtml = elabHaddockHtml,\n pkgHashHaddockHtmlLocation = elabHaddockHtmlLocation,\n pkgHashHaddockForeignLibs = elabHaddockForeignLibs,\n pkgHashHaddockExecutables = elabHaddockExecutables,\n pkgHashHaddockTestSuites = elabHaddockTestSuites,\n pkgHashHaddockBenchmarks = elabHaddockBenchmarks,\n pkgHashHaddockInternal = elabHaddockInternal,\n pkgHashHaddockCss = elabHaddockCss,\n pkgHashHaddockLinkedSource = elabHaddockLinkedSource,\n pkgHashHaddockQuickJump = elabHaddockQuickJump,\n pkgHashHaddockContents = elabHaddockContents\n }\n where\n ElaboratedConfiguredPackage{..} = normaliseConfiguredPackage shared pkg\n\n-- | Given the 'InstalledPackageIndex' for a nix-style package store, and an\n-- 'ElaboratedInstallPlan', replace configured source packages by installed\n-- packages from the store whenever they exist.\n--\nimproveInstallPlanWithInstalledPackages :: Set UnitId\n -> ElaboratedInstallPlan\n -> ElaboratedInstallPlan\nimproveInstallPlanWithInstalledPackages installedPkgIdSet =\n InstallPlan.installed canPackageBeImproved\n where\n canPackageBeImproved pkg =\n installedUnitId pkg `Set.member` installedPkgIdSet\n --TODO: sanity checks:\n -- * the installed package must have the expected deps etc\n -- * the installed package must not be broken, valid dep closure\n\n --TODO: decide what to do if we encounter broken installed packages,\n -- since overwriting is never safe.\n\n\n-- Path construction\n------\n\n-- | The path to the directory that contains a specific executable.\n-- NB: For inplace NOT InstallPaths.bindir installDirs; for an\n-- inplace build those values are utter nonsense. So we\n-- have to guess where the directory is going to be.\n-- Fortunately this is \"stable\" part of Cabal API.\n-- But the way we get the build directory is A HORRIBLE\n-- HACK.\nbinDirectoryFor\n :: DistDirLayout\n -> ElaboratedSharedConfig\n -> ElaboratedConfiguredPackage\n -> FilePath\n -> FilePath\nbinDirectoryFor layout config package exe = case elabBuildStyle package of\n BuildAndInstall -> installedBinDirectory package\n BuildInplaceOnly -> inplaceBinRoot layout config package exe\n\n-- package has been built and installed.\ninstalledBinDirectory :: ElaboratedConfiguredPackage -> FilePath\ninstalledBinDirectory = InstallDirs.bindir . elabInstallDirs\n\n-- | The path to the @build@ directory for an inplace build.\ninplaceBinRoot\n :: DistDirLayout\n -> ElaboratedSharedConfig\n -> ElaboratedConfiguredPackage\n -> FilePath\ninplaceBinRoot layout config package\n = distBuildDirectory layout (elabDistDirParams config package)\n \"build\"\n"}}} 2020-02-04 20:00:12.4977097 [ThreadId 3] - ---> {"jsonrpc":"2.0","id":1,"method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///c%3A/Users/flip111/haskell/cabal/cabal-install/Distribution/Client/ProjectPlanning.hs"}}} 2020-02-04 20:00:12.4977097 [ThreadId 26] - ****** reactor: got message number:2 2020-02-04 20:00:12.4977097 [ThreadId 3] - ---> {"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///c%3A/Users/flip111/haskell/cabal/cabal-install/Distribution/Client/ProjectPlanning.hs"},"range":{"start":{"line":1417,"character":25},"end":{"line":1417,"character":25}},"context":{"diagnostics":[]}}} 2020-02-04 20:00:12.4987107 [ThreadId 26] - ****** reactor: processing NotDidOpenTextDocument 2020-02-04 20:00:12.4987107 [ThreadId 26] - requestDiagnostics: no diagFunc for:DiagnosticOnOpen 2020-02-04 20:00:12.4987107 [ThreadId 26] - ****** reactor: top of loop 2020-02-04 20:00:12.4987107 [ThreadId 26] - ****** reactor: got message number:3 2020-02-04 20:00:12.4987107 [ThreadId 26] - reactor:got Document symbol request:RequestMessage {_jsonrpc = "2.0", _id = IdInt 1, _method = TextDocumentDocumentSymbol, _params = DocumentSymbolParams {_textDocument = TextDocumentIdentifier {_uri = Uri {getUri = "file:///c%3A/Users/flip111/haskell/cabal/cabal-install/Distribution/Client/ProjectPlanning.hs"}}, _workDoneToken = Nothing}} 2020-02-04 20:00:12.4987107 [ThreadId 26] - ****** reactor: top of loop 2020-02-04 20:00:12.4987107 [ThreadId 26] - ****** reactor: got message number:4 2020-02-04 20:00:12.4987107 [ThreadId 26] - reactor:got CodeActionRequest:RequestMessage {_jsonrpc = "2.0", _id = IdInt 2, _method = TextDocumentCodeAction, _params = CodeActionParams {_textDocument = TextDocumentIdentifier {_uri = Uri {getUri = "file:///c%3A/Users/flip111/haskell/cabal/cabal-install/Distribution/Client/ProjectPlanning.hs"}}, _range = Range {_start = Position {_line = 1417, _character = 25}, _end = Position {_line = 1417, _character = 25}}, _context = CodeActionContext {_diagnostics = List [], only = Nothing}, _workDoneToken = Nothing}} 2020-02-04 20:00:12.4987107 [ThreadId 26] - ****** reactor: top of loop 2020-02-04 20:00:12.505713 [ThreadId 25] - GHC Output: "Just "C:\\Users\\flip111\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.6.5\\lib"" 2020-02-04 20:00:12.505713 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:12.505713 [ThreadId 32] - ideDispatcher: got request 3 with id: IdInt 1 2020-02-04 20:00:12.5067108 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:12.5067108 [ThreadId 32] - ideDispatcher: got request 4 with id: IdInt 2 2020-02-04 20:00:12.5067108 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:12.5067108 [ThreadId 32] - ideDispatcher: got request 4 with id: IdInt 2 2020-02-04 20:00:12.5067108 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:12.5067108 [ThreadId 32] - ideDispatcher: got request 4 with id: IdInt 2 2020-02-04 20:00:12.5067108 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:12.5067108 [ThreadId 32] - ideDispatcher: got request 4 with id: IdInt 2 2020-02-04 20:00:12.5067108 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:12.507715 [ThreadId 32] - ideDispatcher: got request 4 with id: IdInt 2 2020-02-04 20:00:12.5087105 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:12.5087105 [ThreadId 32] - ideDispatcher: got request 4 with id: IdInt 2 2020-02-04 20:00:12.5087105 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:12.5127121 [ThreadId 4] - <--2--{"result":[],"jsonrpc":"2.0","id":2} 2020-02-04 20:00:12.5147148 [ThreadId 31] - ghcDispatcher: top of loop 2020-02-04 20:00:12.5147148 [ThreadId 31] - ghcDispatcher:got request 0 with id: Nothing 2020-02-04 20:00:12.5157103 [ThreadId 31] - ghcDispatcher: top of loop 2020-02-04 20:00:12.5167116 [ThreadId 31] - ghcDispatcher:got request 2 with id: Nothing 2020-02-04 20:00:12.5167116 [ThreadId 31] - ghcDispatcher:Processing request as version matches 2020-02-04 20:00:12.5177115 [ThreadId 31] - New cradle: C:\Users\flip111\haskell\cabal\cabal-install\Distribution\Client\ProjectPlanning.hs Using hoogle db at: C:\Users\flip111\AppData\Roaming\hoogle\default-haskell-5.0.17.hoo 2020-02-04 20:00:12.5207113 [ThreadId 4] - <--2--{"jsonrpc":"2.0","params":{"type":4,"message":"Using hoogle db at: C:\\Users\\flip111\\AppData\\Roaming\\hoogle\\default-haskell-5.0.17.hoo"},"method":"window/logMessage"} 2020-02-04 20:00:12.5247158 [ThreadId 31] - Cabal-Helper found these projects: ["ProjLocV2Dir {plProjectDirV2 = \"C:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\cabal-install\"}","ProjLocV1Dir {plProjectDirV1 = \"C:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\cabal-install\"}","ProjLocV2File {plCabalProjectFile = \"C:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\cabal.project\", plProjectDirV2 = \"C:\\\\Users\\\\flip111\\\\haskell\\\\cabal\"}","ProjLocStackYaml {plStackYaml = \"C:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\stack.yaml\"}"] 2020-02-04 20:00:12.5257108 [ThreadId 31] - These projects have the build tools installed: ["ProjLocV2Dir {plProjectDirV2 = \"C:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\cabal-install\"}","ProjLocV1Dir {plProjectDirV1 = \"C:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\cabal-install\"}","ProjLocV2File {plCabalProjectFile = \"C:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\cabal.project\", plProjectDirV2 = \"C:\\\\Users\\\\flip111\\\\haskell\\\\cabal\"}","ProjLocStackYaml {plStackYaml = \"C:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\stack.yaml\"}"] 2020-02-04 20:00:12.5257108 [ThreadId 31] - Cabal-Helper decided to use: ProjLocV2File {plCabalProjectFile = "C:\\Users\\flip111\\haskell\\cabal\\cabal.project", plProjectDirV2 = "C:\\Users\\flip111\\haskell\\cabal"} 2020-02-04 20:00:12.5257108 [ThreadId 31] - Cabal-Helper dirs: ["C:\\Users\\flip111\\haskell\\cabal","C:\\Users\\flip111\\haskell\\cabal\\cabal-install\\Distribution\\Client\\ProjectPlanning.hs"] cd C:\Users\flip111\haskell\cabal; cabal v2-build --with-ghc=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc.exe --with-ghc-pkg=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc-pkg.exe --with-haddock=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\haddock.exe --project-file=C:\Users\flip111\haskell\cabal\cabal.project --builddir=C:\Users\flip111\haskell\cabal\dist-newstyle --dry-run all Build profile: -w ghc-8.6.5 -O1 In order, the following would be built (use -v for more details): - Cabal-2.4.1.0 (lib) (requires build) - Cabal-3.3.0.0 (lib) (configuration changed) - abstract-deque-0.3 (lib) (requires download & build) - abstract-par-0.3.3 (lib) (requires download & build) - base16-bytestring-0.1.1.6 (lib:base16-bytestring) (requires download & build) - base64-bytestring-1.0.0.3 (lib) (requires download & build) - cereal-0.5.8.1 (lib) (requires download & build) - cryptohash-sha256-0.11.101.0 (lib) (requires download & build) - data-default-class-0.1.2.0 (lib:data-default-class) (requires download & build) - echo-0.1.3 (lib) (requires download & build) - ed25519-0.0.5.0 (lib) (requires download & build) - edit-distance-0.2.2.1 (lib) (requires download & build) - hsc2hs-0.68.6 (exe:hsc2hs) (requires download & build) - network-uri-2.6.1.0 (lib) (requires download & build) - parallel-3.2.2.0 (lib) (requires download & build) - regex-base-0.94.0.0 (lib) (requires download & build) - tar-0.5.1.1 (lib) (requires download & build) - vector-algorithms-0.8.0.3 (lib) (requires download & build) - vector-binary-instances-0.2.5.1 (lib) (requires download & build) - vector-th-unbox-0.2.1.7 (lib) (requires download & build) - zlib-0.6.2.1 (lib) (requires download & build) - Cabal-3.3.0.0 (test:unit-tests) (configuration changed) - Cabal-3.3.0.0 (test:rpmvercmp) (configuration changed) - Cabal-3.3.0.0 (test:parser-tests) (configuration changed) - Cabal-3.3.0.0 (test:custom-setup-tests) (configuration changed) - Cabal-3.3.0.0 (test:check-tests) (configuration changed) - monad-par-extras-0.3.3 (lib) (requires download & build) - windns-0.1.0.1 (lib) (requires download & build) - network-3.1.1.1 (lib:network) (requires download & build) - lukko-0.1.1.1 (lib) (requires download & build) - regex-tdfa-1.3.1.0 (lib) (requires download & build) - math-functions-0.3.3.0 (lib) (requires download & build) - HTTP-4000.3.14 (lib) (requires download & build) - hackage-security-0.6.0.0 (lib) (requires download & build) - regex-compat-tdfa-0.95.1.4 (lib:regex-compat-tdfa) (requires download & build) - mwc-random-0.14.0.0 (lib) (requires download & build) - dense-linear-algebra-0.1.0.0 (lib) (requires download & build) - cabal-install-3.3.0.0 (exe:cabal) (first run) - cabal-testsuite-3 (lib:cabal-testsuite, exe:cabal-tests, exe:setup) (first run) - monad-par-0.3.5 (lib) (requires download & build) - statistics-0.15.2.0 (lib) (requires download & build) - solver-benchmarks-3 (lib) (first run) - solver-benchmarks-3 (test:unit-tests) (first run) - solver-benchmarks-3 (exe:hackage-benchmark) (first run) 2020-02-04 20:00:14.144842 [ThreadId 31] - Cabal-Helper cradle package: Package {pPackageName = "cabal-install", pSourceDir = "C:\\Users\\flip111\\haskell\\cabal\\cabal-install", pCabalFile = CabalFile "C:\\Users\\flip111\\haskell\\cabal\\cabal-install\\cabal-install.cabal", pFlags = [], pUnits = Unit {uUnitId = UnitId "cabal-install-3.3.0.0-inplace", uPackage = Package {pPackageName = "cabal-install", pSourceDir = "C:\\Users\\flip111\\haskell\\cabal\\cabal-install", pCabalFile = CabalFile "C:\\Users\\flip111\\haskell\\cabal\\cabal-install\\cabal-install.cabal", pFlags = [], pUnits = ()}, uDistDir = DistDirLib "C:\\Users\\flip111\\haskell\\cabal\\dist-newstyle\\build\\x86_64-windows\\ghc-8.6.5\\cabal-install-3.3.0.0", uImpl = UnitImplV2 {uiV2ComponentNames = [ChExeName "cabal",ChSetupHsName], uiV2Components = ["cabal-install:exe:cabal","cabal-install:setup"], uiV2OnlyDependencies = False}} :| []} 2020-02-04 20:00:14.1458368 [ThreadId 31] - Cabal-Helper normalisedPackageLocation: C:\Users\flip111\haskell\cabal\cabal-install 2020-02-04 20:00:14.1458368 [ThreadId 31] - Module "C:\Users\flip111\haskell\cabal\cabal-install\Distribution\Client\ProjectPlanning.hs" is loaded by Cradle: Cradle {cradleRootDir = "C:\\Users\\flip111\\haskell\\cabal\\cabal-install", cradleOptsProg = CradleAction: Other CabalV2} 2020-02-04 20:00:14.1458368 [ThreadId 31] - Found cradle: Cradle {cradleRootDir = "C:\\Users\\flip111\\haskell\\cabal\\cabal-install", cradleOptsProg = CradleAction: Other CabalV2} 2020-02-04 20:00:14.1458368 [ThreadId 51] - Relative Module FilePath: Distribution\Client\ProjectPlanning.hs 2020-02-04 20:00:14.1468345 [ThreadId 4] - <--2--{"jsonrpc":"2.0","params":{"token":0},"method":"window/workDoneProgress/create","id":0} 2020-02-04 20:00:14.1468345 [ThreadId 4] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"begin","cancellable":false,"title":"Initializing Cabal project","percentage":0},"token":0},"method":"$/progress"} cd C:\Users\flip111\haskell\cabal; cabal v2-build --with-ghc=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc.exe --with-ghc-pkg=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc-pkg.exe --with-haddock=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\haddock.exe --project-file=C:\Users\flip111\haskell\cabal\cabal.project --builddir=C:\Users\flip111\haskell\cabal\dist-newstyle --only-configure cabal-install:exe:cabal cabal-install:setup 2020-02-04 20:00:14.1528489 [ThreadId 3] - ---> {"jsonrpc":"2.0","id":0,"result":null} 2020-02-04 20:00:14.1528489 [ThreadId 3] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":0,\"result\":null}" 2020-02-04 20:00:14.1528489 [ThreadId 26] - ****** reactor: got message number:5 2020-02-04 20:00:14.1538377 [ThreadId 26] - reactor:got RspFromClient:ResponseMessage {_jsonrpc = "2.0", _id = IdRspInt 0, _result = Just Null, _error = Nothing} 2020-02-04 20:00:14.1538377 [ThreadId 26] - ****** reactor: top of loop cabal: Unknown target 'cabal-install:setup'. The package cabal-install has no component 'setup'. 2020-02-04 20:00:14.2138412 [ThreadId 51] - Catching and swallowing an IOException: callProcessStderr: cabal v2-build --with-ghc=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc.exe --with-ghc-pkg=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc-pkg.exe --with-haddock=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\haddock.exe --project-file=C:\Users\flip111\haskell\cabal\cabal.project --builddir=C:\Users\flip111\haskell\cabal\dist-newstyle --only-configure cabal-install:exe:cabal cabal-install:setup (exit 1): failed 2020-02-04 20:00:14.2148447 [ThreadId 51] - The Exception was thrown in the context of finding a component for "Distribution\Client\ProjectPlanning.hs" in the unit: Unit {uUnitId = UnitId "cabal-install-3.3.0.0-inplace", uPackage = Package {pPackageName = "cabal-install", pSourceDir = "C:\\Users\\flip111\\haskell\\cabal\\cabal-install", pCabalFile = CabalFile "C:\\Users\\flip111\\haskell\\cabal\\cabal-install\\cabal-install.cabal", pFlags = [], pUnits = ()}, uDistDir = DistDirLib "C:\\Users\\flip111\\haskell\\cabal\\dist-newstyle\\build\\x86_64-windows\\ghc-8.6.5\\cabal-install-3.3.0.0", uImpl = UnitImplV2 {uiV2ComponentNames = [ChExeName "cabal",ChSetupHsName], uiV2Components = ["cabal-install:exe:cabal","cabal-install:setup"], uiV2OnlyDependencies = False}} 2020-02-04 20:00:14.2148447 [ThreadId 51] - Fail on cradle initialisation: (ExitFailure 2)["Could not obtain flags for: \"Distribution\\Client\\ProjectPlanning.hs\".","","We could not build all components.","If one of these components exposes this Module, make sure they compile.","You can try to invoke the commands yourself.","The following commands failed:","","callProcessStderr: cabal v2-build --with-ghc=C:\\Users\\flip111\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.6.5\\bin\\ghc.exe --with-ghc-pkg=C:\\Users\\flip111\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.6.5\\bin\\ghc-pkg.exe --with-haddock=C:\\Users\\flip111\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.6.5\\bin\\haddock.exe --project-file=C:\\Users\\flip111\\haskell\\cabal\\cabal.project --builddir=C:\\Users\\flip111\\haskell\\cabal\\dist-newstyle --only-configure cabal-install:exe:cabal cabal-install:setup (exit 1): failed"] 2020-02-04 20:00:14.2148447 [ThreadId 4] - <--2--{"jsonrpc":"2.0","params":{"uri":"file:///C:/Users/flip111/haskell/cabal/cabal-install/Distribution/Client/ProjectPlanning.hs","diagnostics":[{"severity":1,"range":{"start":{"line":0,"character":0},"end":{"line":1,"character":0}},"source":"bios","message":"Fail on initialisation for \"C:\\Users\\flip111\\haskell\\cabal\\cabal-install\\Distribution\\Client\\ProjectPlanning.hs\".\nCould not obtain flags for: \"Distribution\\Client\\ProjectPlanning.hs\".\n\nWe could not build all components.\nIf one of these components exposes this Module, make sure they compile.\nYou can try to invoke the commands yourself.\nThe following commands failed:\n\ncallProcessStderr: cabal v2-build --with-ghc=C:\\Users\\flip111\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.6.5\\bin\\ghc.exe --with-ghc-pkg=C:\\Users\\flip111\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.6.5\\bin\\ghc-pkg.exe --with-haddock=C:\\Users\\flip111\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.6.5\\bin\\haddock.exe --project-file=C:\\Users\\flip111\\haskell\\cabal\\cabal.project --builddir=C:\\Users\\flip111\\haskell\\cabal\\dist-newstyle --only-configure cabal-install:exe:cabal cabal-install:setup (exit 1): failed\n"}]},"method":"textDocument/publishDiagnostics"} 2020-02-04 20:00:14.2148447 [ThreadId 31] - ghcDispatcher:Got error for a request: IdeError {ideCode = OtherError, ideMessage = "Fail on initialisation for \"C:\\Users\\flip111\\haskell\\cabal\\cabal-install\\Distribution\\Client\\ProjectPlanning.hs\". Could not obtain flags for: \"Distribution\\Client\\ProjectPlanning.hs\".", ideInfo = Null} with mid: Nothing 2020-02-04 20:00:14.2148447 [ThreadId 31] - ghcDispatcher: top of loop 2020-02-04 20:00:14.2148447 [ThreadId 31] - ghcDispatcher:got request 2 with id: Nothing 2020-02-04 20:00:14.2148447 [ThreadId 31] - ghcDispatcher:Processing request as version matches 2020-02-04 20:00:14.2158431 [ThreadId 31] - New cradle: C:\Users\flip111\haskell\cabal\cabal-install\Distribution\Client\ProjectPlanning.hs 2020-02-04 20:00:14.2208423 [ThreadId 4] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"end"},"token":0},"method":"$/progress"} 2020-02-04 20:00:14.2228414 [ThreadId 31] - Cabal-Helper found these projects: ["ProjLocV2Dir {plProjectDirV2 = \"C:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\cabal-install\"}","ProjLocV1Dir {plProjectDirV1 = \"C:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\cabal-install\"}","ProjLocV2File {plCabalProjectFile = \"C:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\cabal.project\", plProjectDirV2 = \"C:\\\\Users\\\\flip111\\\\haskell\\\\cabal\"}","ProjLocStackYaml {plStackYaml = \"C:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\stack.yaml\"}"] 2020-02-04 20:00:14.2228414 [ThreadId 4] - <--2--{"jsonrpc":"2.0","params":{"type":1,"message":"Fail on initialisation for \"C:\\Users\\flip111\\haskell\\cabal\\cabal-install\\Distribution\\Client\\ProjectPlanning.hs\". Could not obtain flags for: \"Distribution\\Client\\ProjectPlanning.hs\"."},"method":"window/showMessage"} 2020-02-04 20:00:14.2238412 [ThreadId 31] - These projects have the build tools installed: ["ProjLocV2Dir {plProjectDirV2 = \"C:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\cabal-install\"}","ProjLocV1Dir {plProjectDirV1 = \"C:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\cabal-install\"}","ProjLocV2File {plCabalProjectFile = \"C:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\cabal.project\", plProjectDirV2 = \"C:\\\\Users\\\\flip111\\\\haskell\\\\cabal\"}","ProjLocStackYaml {plStackYaml = \"C:\\\\Users\\\\flip111\\\\haskell\\\\cabal\\\\stack.yaml\"}"] 2020-02-04 20:00:14.2238412 [ThreadId 31] - Cabal-Helper decided to use: ProjLocV2File {plCabalProjectFile = "C:\\Users\\flip111\\haskell\\cabal\\cabal.project", plProjectDirV2 = "C:\\Users\\flip111\\haskell\\cabal"} 2020-02-04 20:00:14.2238412 [ThreadId 31] - Cabal-Helper dirs: ["C:\\Users\\flip111\\haskell\\cabal","C:\\Users\\flip111\\haskell\\cabal\\cabal-install\\Distribution\\Client\\ProjectPlanning.hs"] 2020-02-04 20:00:14.4848673 [ThreadId 3] - ---> {"jsonrpc":"2.0","id":3,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///c%3A/Users/flip111/haskell/cabal/cabal-install/Distribution/Client/ProjectPlanning.hs"},"range":{"start":{"line":1417,"character":25},"end":{"line":1417,"character":25}},"context":{"diagnostics":[]}}} 2020-02-04 20:00:14.4848673 [ThreadId 26] - ****** reactor: got message number:6 2020-02-04 20:00:14.4848673 [ThreadId 26] - reactor:got CodeActionRequest:RequestMessage {_jsonrpc = "2.0", _id = IdInt 3, _method = TextDocumentCodeAction, _params = CodeActionParams {_textDocument = TextDocumentIdentifier {_uri = Uri {getUri = "file:///c%3A/Users/flip111/haskell/cabal/cabal-install/Distribution/Client/ProjectPlanning.hs"}}, _range = Range {_start = Position {_line = 1417, _character = 25}, _end = Position {_line = 1417, _character = 25}}, _context = CodeActionContext {_diagnostics = List [], only = Nothing}, _workDoneToken = Nothing}} 2020-02-04 20:00:14.4848673 [ThreadId 26] - ****** reactor: top of loop 2020-02-04 20:00:14.4848673 [ThreadId 32] - ideDispatcher: got request 6 with id: IdInt 3 2020-02-04 20:00:14.4848673 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:14.4848673 [ThreadId 32] - ideDispatcher: got request 6 with id: IdInt 3 2020-02-04 20:00:14.4848673 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:14.4858628 [ThreadId 32] - ideDispatcher: got request 6 with id: IdInt 3 2020-02-04 20:00:14.4858628 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:14.4858628 [ThreadId 32] - ideDispatcher: got request 6 with id: IdInt 3 2020-02-04 20:00:14.4858628 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:14.4858628 [ThreadId 32] - ideDispatcher: got request 6 with id: IdInt 3 2020-02-04 20:00:14.4858628 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:14.4858628 [ThreadId 32] - ideDispatcher: got request 6 with id: IdInt 3 2020-02-04 20:00:14.4858628 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:14.4858628 [ThreadId 4] - <--2--{"result":[],"jsonrpc":"2.0","id":3} cd C:\Users\flip111\haskell\cabal; cabal v2-build --with-ghc=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc.exe --with-ghc-pkg=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc-pkg.exe --with-haddock=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\haddock.exe --project-file=C:\Users\flip111\haskell\cabal\cabal.project --builddir=C:\Users\flip111\haskell\cabal\dist-newstyle --dry-run all Build profile: -w ghc-8.6.5 -O1 In order, the following would be built (use -v for more details): - Cabal-2.4.1.0 (lib) (requires build) - Cabal-3.3.0.0 (lib) (configuration changed) - abstract-deque-0.3 (lib) (requires download & build) - abstract-par-0.3.3 (lib) (requires download & build) - base16-bytestring-0.1.1.6 (lib:base16-bytestring) (requires download & build) - base64-bytestring-1.0.0.3 (lib) (requires download & build) - cereal-0.5.8.1 (lib) (requires download & build) - cryptohash-sha256-0.11.101.0 (lib) (requires download & build) - data-default-class-0.1.2.0 (lib:data-default-class) (requires download & build) - echo-0.1.3 (lib) (requires download & build) - ed25519-0.0.5.0 (lib) (requires download & build) - edit-distance-0.2.2.1 (lib) (requires download & build) - hsc2hs-0.68.6 (exe:hsc2hs) (requires download & build) - network-uri-2.6.1.0 (lib) (requires download & build) - parallel-3.2.2.0 (lib) (requires download & build) - regex-base-0.94.0.0 (lib) (requires download & build) - tar-0.5.1.1 (lib) (requires download & build) - vector-algorithms-0.8.0.3 (lib) (requires download & build) - vector-binary-instances-0.2.5.1 (lib) (requires download & build) - vector-th-unbox-0.2.1.7 (lib) (requires download & build) - zlib-0.6.2.1 (lib) (requires download & build) - Cabal-3.3.0.0 (test:unit-tests) (configuration changed) - Cabal-3.3.0.0 (test:rpmvercmp) (configuration changed) - Cabal-3.3.0.0 (test:parser-tests) (configuration changed) - Cabal-3.3.0.0 (test:custom-setup-tests) (configuration changed) - Cabal-3.3.0.0 (test:check-tests) (configuration changed) - monad-par-extras-0.3.3 (lib) (requires download & build) - windns-0.1.0.1 (lib) (requires download & build) - network-3.1.1.1 (lib:network) (requires download & build) - lukko-0.1.1.1 (lib) (requires download & build) - regex-tdfa-1.3.1.0 (lib) (requires download & build) - math-functions-0.3.3.0 (lib) (requires download & build) - HTTP-4000.3.14 (lib) (requires download & build) - hackage-security-0.6.0.0 (lib) (requires download & build) - regex-compat-tdfa-0.95.1.4 (lib:regex-compat-tdfa) (requires download & build) - mwc-random-0.14.0.0 (lib) (requires download & build) - dense-linear-algebra-0.1.0.0 (lib) (requires download & build) - cabal-install-3.3.0.0 (exe:cabal) (first run) - cabal-testsuite-3 (lib:cabal-testsuite, exe:cabal-tests, exe:setup) (first run) - monad-par-0.3.5 (lib) (requires download & build) - statistics-0.15.2.0 (lib) (requires download & build) - solver-benchmarks-3 (lib) (first run) - solver-benchmarks-3 (test:unit-tests) (first run) - solver-benchmarks-3 (exe:hackage-benchmark) (first run) 2020-02-04 20:00:14.8768911 [ThreadId 31] - Cabal-Helper cradle package: Package {pPackageName = "cabal-install", pSourceDir = "C:\\Users\\flip111\\haskell\\cabal\\cabal-install", pCabalFile = CabalFile "C:\\Users\\flip111\\haskell\\cabal\\cabal-install\\cabal-install.cabal", pFlags = [], pUnits = Unit {uUnitId = UnitId "cabal-install-3.3.0.0-inplace", uPackage = Package {pPackageName = "cabal-install", pSourceDir = "C:\\Users\\flip111\\haskell\\cabal\\cabal-install", pCabalFile = CabalFile "C:\\Users\\flip111\\haskell\\cabal\\cabal-install\\cabal-install.cabal", pFlags = [], pUnits = ()}, uDistDir = DistDirLib "C:\\Users\\flip111\\haskell\\cabal\\dist-newstyle\\build\\x86_64-windows\\ghc-8.6.5\\cabal-install-3.3.0.0", uImpl = UnitImplV2 {uiV2ComponentNames = [ChExeName "cabal",ChSetupHsName], uiV2Components = ["cabal-install:exe:cabal","cabal-install:setup"], uiV2OnlyDependencies = False}} :| []} 2020-02-04 20:00:14.8768911 [ThreadId 31] - Cabal-Helper normalisedPackageLocation: C:\Users\flip111\haskell\cabal\cabal-install 2020-02-04 20:00:14.8768911 [ThreadId 31] - Module "C:\Users\flip111\haskell\cabal\cabal-install\Distribution\Client\ProjectPlanning.hs" is loaded by Cradle: Cradle {cradleRootDir = "C:\\Users\\flip111\\haskell\\cabal\\cabal-install", cradleOptsProg = CradleAction: Other CabalV2} 2020-02-04 20:00:14.8768911 [ThreadId 31] - Found cradle: Cradle {cradleRootDir = "C:\\Users\\flip111\\haskell\\cabal\\cabal-install", cradleOptsProg = CradleAction: Other CabalV2} 2020-02-04 20:00:14.8768911 [ThreadId 72] - Relative Module FilePath: Distribution\Client\ProjectPlanning.hs 2020-02-04 20:00:14.8778923 [ThreadId 4] - <--2--{"jsonrpc":"2.0","params":{"token":1},"method":"window/workDoneProgress/create","id":1} 2020-02-04 20:00:14.878899 [ThreadId 3] - ---> {"jsonrpc":"2.0","id":1,"result":null} 2020-02-04 20:00:14.878899 [ThreadId 3] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":null}" cd C:\Users\flip111\haskell\cabal; cabal v2-build --with-ghc=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc.exe --with-ghc-pkg=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc-pkg.exe --with-haddock=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\haddock.exe --project-file=C:\Users\flip111\haskell\cabal\cabal.project --builddir=C:\Users\flip111\haskell\cabal\dist-newstyle --only-configure cabal-install:exe:cabal cabal-install:setup 2020-02-04 20:00:14.8798931 [ThreadId 4] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"begin","cancellable":false,"title":"Initializing Cabal project","percentage":0},"token":1},"method":"$/progress"} 2020-02-04 20:00:14.8858908 [ThreadId 26] - ****** reactor: got message number:7 2020-02-04 20:00:14.8858908 [ThreadId 26] - reactor:got RspFromClient:ResponseMessage {_jsonrpc = "2.0", _id = IdRspInt 1, _result = Just Null, _error = Nothing} 2020-02-04 20:00:14.8858908 [ThreadId 26] - ****** reactor: top of loop cabal: Unknown target 'cabal-install:setup'. The package cabal-install has no component 'setup'. 2020-02-04 20:00:14.9519044 [ThreadId 72] - Catching and swallowing an IOException: callProcessStderr: cabal v2-build --with-ghc=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc.exe --with-ghc-pkg=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc-pkg.exe --with-haddock=C:\Users\flip111\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5\bin\haddock.exe --project-file=C:\Users\flip111\haskell\cabal\cabal.project --builddir=C:\Users\flip111\haskell\cabal\dist-newstyle --only-configure cabal-install:exe:cabal cabal-install:setup (exit 1): failed 2020-02-04 20:00:14.9519044 [ThreadId 72] - The Exception was thrown in the context of finding a component for "Distribution\Client\ProjectPlanning.hs" in the unit: Unit {uUnitId = UnitId "cabal-install-3.3.0.0-inplace", uPackage = Package {pPackageName = "cabal-install", pSourceDir = "C:\\Users\\flip111\\haskell\\cabal\\cabal-install", pCabalFile = CabalFile "C:\\Users\\flip111\\haskell\\cabal\\cabal-install\\cabal-install.cabal", pFlags = [], pUnits = ()}, uDistDir = DistDirLib "C:\\Users\\flip111\\haskell\\cabal\\dist-newstyle\\build\\x86_64-windows\\ghc-8.6.5\\cabal-install-3.3.0.0", uImpl = UnitImplV2 {uiV2ComponentNames = [ChExeName "cabal",ChSetupHsName], uiV2Components = ["cabal-install:exe:cabal","cabal-install:setup"], uiV2OnlyDependencies = False}} 2020-02-04 20:00:14.9519044 [ThreadId 72] - Fail on cradle initialisation: (ExitFailure 2)["Could not obtain flags for: \"Distribution\\Client\\ProjectPlanning.hs\".","","We could not build all components.","If one of these components exposes this Module, make sure they compile.","You can try to invoke the commands yourself.","The following commands failed:","","callProcessStderr: cabal v2-build --with-ghc=C:\\Users\\flip111\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.6.5\\bin\\ghc.exe --with-ghc-pkg=C:\\Users\\flip111\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.6.5\\bin\\ghc-pkg.exe --with-haddock=C:\\Users\\flip111\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.6.5\\bin\\haddock.exe --project-file=C:\\Users\\flip111\\haskell\\cabal\\cabal.project --builddir=C:\\Users\\flip111\\haskell\\cabal\\dist-newstyle --only-configure cabal-install:exe:cabal cabal-install:setup (exit 1): failed"] 2020-02-04 20:00:14.9529034 [ThreadId 31] - ghcDispatcher:Got error for a request: IdeError {ideCode = OtherError, ideMessage = "Fail on initialisation for \"C:\\Users\\flip111\\haskell\\cabal\\cabal-install\\Distribution\\Client\\ProjectPlanning.hs\". Could not obtain flags for: \"Distribution\\Client\\ProjectPlanning.hs\".", ideInfo = Null} with mid: Nothing 2020-02-04 20:00:14.9529034 [ThreadId 4] - <--2--{"jsonrpc":"2.0","params":{"uri":"file:///C:/Users/flip111/haskell/cabal/cabal-install/Distribution/Client/ProjectPlanning.hs","diagnostics":[{"severity":1,"range":{"start":{"line":0,"character":0},"end":{"line":1,"character":0}},"source":"bios","message":"Fail on initialisation for \"C:\\Users\\flip111\\haskell\\cabal\\cabal-install\\Distribution\\Client\\ProjectPlanning.hs\".\nCould not obtain flags for: \"Distribution\\Client\\ProjectPlanning.hs\".\n\nWe could not build all components.\nIf one of these components exposes this Module, make sure they compile.\nYou can try to invoke the commands yourself.\nThe following commands failed:\n\ncallProcessStderr: cabal v2-build --with-ghc=C:\\Users\\flip111\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.6.5\\bin\\ghc.exe --with-ghc-pkg=C:\\Users\\flip111\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.6.5\\bin\\ghc-pkg.exe --with-haddock=C:\\Users\\flip111\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.6.5\\bin\\haddock.exe --project-file=C:\\Users\\flip111\\haskell\\cabal\\cabal.project --builddir=C:\\Users\\flip111\\haskell\\cabal\\dist-newstyle --only-configure cabal-install:exe:cabal cabal-install:setup (exit 1): failed\n"}]},"method":"textDocument/publishDiagnostics"} 2020-02-04 20:00:14.9529034 [ThreadId 31] - ghcDispatcher: top of loop 2020-02-04 20:00:14.9529034 [ThreadId 4] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"end"},"token":1},"method":"$/progress"} 2020-02-04 20:00:14.9529034 [ThreadId 4] - <--2--{"jsonrpc":"2.0","params":{"type":1,"message":"Fail on initialisation for \"C:\\Users\\flip111\\haskell\\cabal\\cabal-install\\Distribution\\Client\\ProjectPlanning.hs\". Could not obtain flags for: \"Distribution\\Client\\ProjectPlanning.hs\"."},"method":"window/showMessage"} 2020-02-04 20:00:15.2339188 [ThreadId 3] - ---> {"jsonrpc":"2.0","id":4,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///c%3A/Users/flip111/haskell/cabal/cabal-install/Distribution/Client/ProjectPlanning.hs"},"range":{"start":{"line":1417,"character":25},"end":{"line":1417,"character":25}},"context":{"diagnostics":[]}}} 2020-02-04 20:00:15.2339188 [ThreadId 26] - ****** reactor: got message number:8 2020-02-04 20:00:15.2339188 [ThreadId 26] - reactor:got CodeActionRequest:RequestMessage {_jsonrpc = "2.0", _id = IdInt 4, _method = TextDocumentCodeAction, _params = CodeActionParams {_textDocument = TextDocumentIdentifier {_uri = Uri {getUri = "file:///c%3A/Users/flip111/haskell/cabal/cabal-install/Distribution/Client/ProjectPlanning.hs"}}, _range = Range {_start = Position {_line = 1417, _character = 25}, _end = Position {_line = 1417, _character = 25}}, _context = CodeActionContext {_diagnostics = List [], only = Nothing}, _workDoneToken = Nothing}} 2020-02-04 20:00:15.2339188 [ThreadId 26] - ****** reactor: top of loop 2020-02-04 20:00:15.2339188 [ThreadId 32] - ideDispatcher: got request 8 with id: IdInt 4 2020-02-04 20:00:15.2339188 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:15.2339188 [ThreadId 32] - ideDispatcher: got request 8 with id: IdInt 4 2020-02-04 20:00:15.2339188 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:15.2339188 [ThreadId 32] - ideDispatcher: got request 8 with id: IdInt 4 2020-02-04 20:00:15.2349253 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:15.2349253 [ThreadId 32] - ideDispatcher: got request 8 with id: IdInt 4 2020-02-04 20:00:15.2349253 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:15.2349253 [ThreadId 32] - ideDispatcher: got request 8 with id: IdInt 4 2020-02-04 20:00:15.2349253 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:15.2349253 [ThreadId 32] - ideDispatcher: got request 8 with id: IdInt 4 2020-02-04 20:00:15.2349253 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:15.2349253 [ThreadId 4] - <--2--{"result":[],"jsonrpc":"2.0","id":4} 2020-02-04 20:00:29.3346841 [ThreadId 3] - ---> {"jsonrpc":"2.0","id":5,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///c%3A/Users/flip111/haskell/cabal/cabal-install/Distribution/Client/ProjectPlanning.hs"},"position":{"line":1416,"character":22}}} 2020-02-04 20:00:29.3346841 [ThreadId 26] - ****** reactor: got message number:9 2020-02-04 20:00:29.3346841 [ThreadId 26] - reactor:got DocumentHighlightsRequest:RequestMessage {_jsonrpc = "2.0", _id = IdInt 5, _method = TextDocumentDocumentHighlight, _params = TextDocumentPositionParams {_textDocument = TextDocumentIdentifier {_uri = Uri {getUri = "file:///c%3A/Users/flip111/haskell/cabal/cabal-install/Distribution/Client/ProjectPlanning.hs"}}, _position = Position {_line = 1416, _character = 22}, _workDoneToken = Nothing}} 2020-02-04 20:00:29.3346841 [ThreadId 26] - ****** reactor: top of loop 2020-02-04 20:00:29.3346841 [ThreadId 32] - ideDispatcher: got request 9 with id: IdInt 5 2020-02-04 20:00:29.3356886 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:29.5647098 [ThreadId 3] - ---> {"jsonrpc":"2.0","id":6,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///c%3A/Users/flip111/haskell/cabal/cabal-install/Distribution/Client/ProjectPlanning.hs"},"range":{"start":{"line":1416,"character":22},"end":{"line":1416,"character":22}},"context":{"diagnostics":[]}}} 2020-02-04 20:00:29.5647098 [ThreadId 26] - ****** reactor: got message number:10 2020-02-04 20:00:29.5647098 [ThreadId 26] - reactor:got CodeActionRequest:RequestMessage {_jsonrpc = "2.0", _id = IdInt 6, _method = TextDocumentCodeAction, _params = CodeActionParams {_textDocument = TextDocumentIdentifier {_uri = Uri {getUri = "file:///c%3A/Users/flip111/haskell/cabal/cabal-install/Distribution/Client/ProjectPlanning.hs"}}, _range = Range {_start = Position {_line = 1416, _character = 22}, _end = Position {_line = 1416, _character = 22}}, _context = CodeActionContext {_diagnostics = List [], only = Nothing}, _workDoneToken = Nothing}} 2020-02-04 20:00:29.5647098 [ThreadId 26] - ****** reactor: top of loop 2020-02-04 20:00:29.5647098 [ThreadId 32] - ideDispatcher: got request 10 with id: IdInt 6 2020-02-04 20:00:29.5647098 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:29.5647098 [ThreadId 32] - ideDispatcher: got request 10 with id: IdInt 6 2020-02-04 20:00:29.5647098 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:29.5647098 [ThreadId 32] - ideDispatcher: got request 10 with id: IdInt 6 2020-02-04 20:00:29.5647098 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:29.5647098 [ThreadId 32] - ideDispatcher: got request 10 with id: IdInt 6 2020-02-04 20:00:29.5647098 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:29.5647098 [ThreadId 32] - ideDispatcher: got request 10 with id: IdInt 6 2020-02-04 20:00:29.5647098 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:29.5647098 [ThreadId 32] - ideDispatcher: got request 10 with id: IdInt 6 2020-02-04 20:00:29.5647098 [ThreadId 32] - ideDispatcher: top of loop 2020-02-04 20:00:29.5657086 [ThreadId 4] - <--2--{"result":[],"jsonrpc":"2.0","id":6} 2020-02-04 20:00:30.3907636 [ThreadId 3] - ---> {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":5}} 2020-02-04 20:00:30.3907636 [ThreadId 3] - ---> {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":1}} 2020-02-04 20:00:30.3907636 [ThreadId 26] - ****** reactor: got message number:11 2020-02-04 20:00:30.3907636 [ThreadId 26] - reactor:got CancelRequest:NotificationMessage {_jsonrpc = "2.0", _method = CancelRequest, _params = CancelParams {_id = IdInt 5}} 2020-02-04 20:00:30.3907636 [ThreadId 26] - ****** reactor: top of loop 2020-02-04 20:00:30.3917739 [ThreadId 26] - ****** reactor: got message number:12 2020-02-04 20:00:30.3917739 [ThreadId 26] - reactor:got CancelRequest:NotificationMessage {_jsonrpc = "2.0", _method = CancelRequest, _params = CancelParams {_id = IdInt 1}} 2020-02-04 20:00:30.3917739 [ThreadId 26] - ****** reactor: top of loop