Skip to content

Commit

Permalink
Fix install of packages bundling generated source in dist/ (#4012)
Browse files Browse the repository at this point in the history
Packages like `alex` include pre-generated lexer/parser source
in their source tarball as e.g.

    dist/build/alex/alex-tmp/Scan.hs
    dist/build/alex/alex-tmp/Parser.hs

to avoid having to have `alex` already installed before building
`alex`...

Unfortunately, 8dc39db broke
packages relying on this accidental feature by changing where the
distdir points to. This patch partly reverts that commit and
therefore addresses the regression aspect of #4009.

This fix was suggested by @dcoutts
  • Loading branch information
hvr committed Oct 21, 2016
1 parent c56e35a commit a7fb9b9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions cabal-install/Distribution/Client/ProjectBuilding.hs
Expand Up @@ -744,16 +744,21 @@ withTarballLocalDirectory verbosity distDirLayout@DistDirLayout{..}
tarball pkgid dparams buildstyle pkgTextOverride
buildPkg =
case buildstyle of
-- In this case we make a couple temp dirs, unpack the tarball to one
-- and build and install it from the other. We avoid nesting the
-- builddir under the tarball src dir to keep path name lengths down.
-- In this case we make a temp dir (e.g. tmp/src2345/), unpack
-- the tarball to it (e.g. tmp/src2345/foo-1.0/), and for
-- compatibility we put the dist dir within it
-- (i.e. tmp/src2345/foo-1.0/dist/).
--
-- Unfortunately, a few custom Setup.hs scripts do not respect
-- the --builddir flag and always look for it at ./dist/ so
-- this way we avoid breaking those packages
BuildAndInstall ->
let tmpdir = distTempDirectory in
withTempDirectory verbosity tmpdir "src" $ \unpackdir ->
withTempDirectory verbosity tmpdir "build" $ \builddir -> do
withTempDirectory verbosity tmpdir "src" $ \unpackdir -> do
unpackPackageTarball verbosity tarball unpackdir
pkgid pkgTextOverride
let srcdir = unpackdir </> display pkgid
builddir = srcdir </> "dist"
buildPkg srcdir builddir

-- In this case we make sure the tarball has been unpacked to the
Expand Down

0 comments on commit a7fb9b9

Please sign in to comment.