Skip to content

Commit

Permalink
Refactor ProjectBuilding into Package Phases
Browse files Browse the repository at this point in the history
This refactor of Distribution.Client.ProjectBuilding does the following:

* Moves package file monitoring logic to
  Distribution.Client.ProjectBuilding.PackageFileMonitor

* Moves the `buildInplaceUnpackedPackage` and
  `buildAndInstallUnpackedPackage` with auxiliary functions to
  Distribution.Client.ProjectBuilding.UnpackedPackage

* Refactors the common bits of `buildInplaceUnpackedPackage` and
  `buildAndInstallUnpackedPackage` to remove considerable code
  duplication while simplifying and making both functions more
  structured.

Namely, to better structure build inplace vs build and install, I've
introduced:

* `PackageBuildingPhase` describes the various phases of processing the
  unpacked package both inplace and on install
    * Configure
    * Build
    * Install (copy + register)
    * Test
    * Bench
    * Repl
    * Haddock

* Then, `buildAndRegisterUnpackedPackage` implements the common logic
  between the two functions (such as calls to ./Setup and the order of
  the phases) but delegates the logic specific to each phase to an
  argument function which maps `PackageBuildingPhase` to `IO` actions.

* Now, build inplace and build and install functions are comprised as:
    * A wrapper around `buildAndRegisterUnpackedPackage` which does
      things specific to each before and after the main phases are
      processed
    * A delegate function which maps an action to each package
      processing phase

Fixes #9499
  • Loading branch information
alt-romes committed Jan 6, 2024
1 parent ef8ab97 commit d6506db
Show file tree
Hide file tree
Showing 4 changed files with 1,224 additions and 1,061 deletions.
2 changes: 2 additions & 0 deletions cabal-install/cabal-install.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ library
Distribution.Client.PackageHash
Distribution.Client.ParseUtils
Distribution.Client.ProjectBuilding
Distribution.Client.ProjectBuilding.UnpackedPackage
Distribution.Client.ProjectBuilding.PackageFileMonitor
Distribution.Client.ProjectBuilding.Types
Distribution.Client.ProjectConfig
Distribution.Client.ProjectConfig.Legacy
Expand Down
Loading

0 comments on commit d6506db

Please sign in to comment.