Skip to content

Extend packages in plan.json with pkg-src field #5487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 2, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 56 additions & 3 deletions cabal-install/Distribution/Client/ProjectPlanOutput.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module Distribution.Client.ProjectPlanOutput (
import Distribution.Client.ProjectPlanning.Types
import Distribution.Client.ProjectBuilding.Types
import Distribution.Client.DistDirLayout
import Distribution.Client.Types (confInstId)
import Distribution.Client.Types (Repo(..), RemoteRepo(..), PackageLocation(..), confInstId)
import Distribution.Client.PackageHash (showHashValue)

import qualified Distribution.Client.InstallPlan as InstallPlan
Expand Down Expand Up @@ -139,6 +139,7 @@ encodePlanAsJson distDirLayout elaboratedInstallPlan elaboratedSharedConfig =
, "flags" J..= J.object [ PD.unFlagName fn J..= v
| (fn,v) <- PD.unFlagAssignment (elabFlagAssignment elab) ]
, "style" J..= J.String (style2str (elabLocalToProject elab) (elabBuildStyle elab))
, "pkg-src" J..= packageLocationToJ (elabPkgSourceLocation elab)
] ++
[ "pkg-src-sha256" J..= J.String (showHashValue hash)
| Just hash <- [elabPkgSourceHash elab] ] ++
Expand Down Expand Up @@ -168,6 +169,59 @@ encodePlanAsJson distDirLayout elaboratedInstallPlan elaboratedSharedConfig =
] ++
bin_file (compSolverName comp)
where
packageLocationToJ :: PackageLocation (Maybe FilePath) -> J.Value
packageLocationToJ pkgloc =
case pkgloc of
LocalUnpackedPackage local ->
J.object [ "type" J..= J.String "local"
, "path" J..= J.String local
]
LocalTarballPackage local ->
J.object [ "type" J..= J.String "local-tarball"
, "path" J..= J.String local
]
RemoteTarballPackage uri _ ->
J.object [ "type" J..= J.String "remote-tarball"
, "uri" J..= J.String (show uri)
]
RepoTarballPackage repo _ _ ->
J.object [ "type" J..= J.String "repo-tarball"
, "repo" J..= repoToJ repo
]
RemoteSourceRepoPackage srcRepo _ ->
J.object [ "type" J..= J.String "source-repo"
, "source-repo" J..= sourceRepoToJ srcRepo
]

repoToJ :: Repo -> J.Value
repoToJ repo =
case repo of
RepoLocal{..} ->
J.object [ "type" J..= J.String "local-repo"
, "path" J..= J.String repoLocalDir
]
RepoRemote{..} ->
J.object [ "type" J..= J.String "remote-repo"
, "path" J..= J.String repoLocalDir
, "remote" J..= J.String (remoteRepoName repoRemote)
]
RepoSecure{..} ->
J.object [ "type" J..= J.String "secure-repo"
, "path" J..= J.String repoLocalDir
Copy link
Member

@hvr hvr Aug 1, 2018

Choose a reason for hiding this comment

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

do we really need the "path"? I don't feel like that's a relevant information; we already know the "remote" label; also the local repo cache path is to be considered an implementation detail; its on-disk format may easily change at some point to account for situations we can't currently represent properly yet.

And most importantly, nor is it even guaranteed that the package is currently cached there! It's called "cache" for a reason :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, let's remove that one.

, "remote" J..= J.String (remoteRepoName repoRemote)
]

sourceRepoToJ :: PD.SourceRepo -> J.Value
sourceRepoToJ PD.SourceRepo{..} =
J.object [ "kind" J..= jdisplay repoKind
, "type" J..= fmap jdisplay repoType
, "location" J..= fmap J.String repoLocation
, "module" J..= fmap J.String repoModule
, "branch" J..= fmap J.String repoBranch
, "tag" J..= fmap J.String repoTag
, "subdir" J..= fmap J.String repoSubdir
]

dist_dir = distBuildDirectory distDirLayout
(elabDistDirParams elaboratedSharedConfig elab)

Expand Down Expand Up @@ -510,7 +564,7 @@ postBuildProjectStatus plan previousPackagesUpToDate
Graph.revClosure packagesLibDepGraph
( Map.keys
. Map.filter (uncurry buildAttempted)
$ Map.intersectionWith (,) pkgBuildStatus buildOutcomes
$ Map.intersectionWith (,) pkgBuildStatus buildOutcomes
)

-- The plan graph but only counting dependency-on-library edges
Expand Down Expand Up @@ -881,4 +935,3 @@ relativePackageDBPath relroot pkgdb =
UserPackageDB -> UserPackageDB
SpecificPackageDB path -> SpecificPackageDB relpath
where relpath = makeRelative relroot path