Skip to content

Commit

Permalink
Factor out the common paths from generated Paths_ file and install …
Browse files Browse the repository at this point in the history
…command
  • Loading branch information
JoshMeredith committed May 22, 2019
1 parent d73b68d commit 5f55491
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 23 deletions.
11 changes: 2 additions & 9 deletions Cabal/Distribution/Simple/Build/PathsModule.hs
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,10 @@ generate pkg_descr lbi clbi =
bindir = flat_bindir,
libdir = flat_libdir,
dynlibdir = flat_dynlibdir,
datadir = flat_datadir,
libexecdir = flat_libexecdir,
sysconfdir = flat_sysconfdir
} = absoluteComponentInstallDirs pkg_descr lbi cid NoCopyDest

-- The install command uses the non-component variant of the paths
-- as the datadir path in `Distribution.Simple.Install.copyPackage`,
-- so maintaining consistency here prevents problems with configuring
-- and building component.
InstallDirs {
datadir = flat_datadir
} = absoluteInstallDirs pkg_descr lbi NoCopyDest
} = absoluteInstallCommandDirs pkg_descr lbi cid NoCopyDest

InstallDirs {
bindir = flat_bindirrel,
Expand Down
17 changes: 3 additions & 14 deletions Cabal/Distribution/Simple/Install.hs
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,10 @@ copyPackage verbosity pkg_descr lbi distPref copydest = do
-- per-component (data files and Haddock files.)
InstallDirs {
datadir = dataPref,
-- NB: The situation with Haddock is a bit delicate. On the
-- one hand, the easiest to understand Haddock documentation
-- path is pkgname-0.1, which means it's per-package (not
-- per-component). But this means that it's impossible to
-- install Haddock documentation for internal libraries. We'll
-- keep this constraint for now; this means you can't use
-- Cabal to Haddock internal libraries. This does not seem
-- like a big problem.
docdir = docPref,
htmldir = htmlPref,
haddockdir = interfacePref}
-- Notice use of 'absoluteInstallDirs' (not the
-- per-component variant). This means for non-library
-- packages we'll just pick a nondescriptive foo-0.1
= absoluteInstallDirs pkg_descr lbi copydest
haddockdir = interfacePref
} = absoluteInstallCommandDirs pkg_descr lbi (localUnitId lbi) copydest

-- Install (package-global) data files
installDataFiles verbosity pkg_descr dataPref
Expand Down Expand Up @@ -161,7 +150,7 @@ copyComponent verbosity pkg_descr lbi (CLib lib) clbi copydest = do
libdir = libPref,
dynlibdir = dynlibPref,
includedir = incPref
} = absoluteComponentInstallDirs pkg_descr lbi (componentUnitId clbi) copydest
} = absoluteInstallCommandDirs pkg_descr lbi (componentUnitId clbi) copydest
buildPref = componentBuildDir lbi clbi

case libName lib of
Expand Down
29 changes: 29 additions & 0 deletions Cabal/Distribution/Simple/LocalBuildInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ module Distribution.Simple.LocalBuildInfo (
-- * Installation directories
module Distribution.Simple.InstallDirs,
absoluteInstallDirs, prefixRelativeInstallDirs,
absoluteInstallCommandDirs,
absoluteComponentInstallDirs, prefixRelativeComponentInstallDirs,
substPathTemplate,
) where
Expand Down Expand Up @@ -302,6 +303,34 @@ absoluteComponentInstallDirs pkg lbi uid copydest =
(hostPlatform lbi)
(installDirTemplates lbi)

absoluteInstallCommandDirs :: PackageDescription -> LocalBuildInfo
-> UnitId
-> CopyDest
-> InstallDirs FilePath
absoluteInstallCommandDirs pkg lbi uid copydest =
dirs {
-- Handle files which are not
-- per-component (data files and Haddock files.)
datadir = datadir dirs',
-- NB: The situation with Haddock is a bit delicate. On the
-- one hand, the easiest to understand Haddock documentation
-- path is pkgname-0.1, which means it's per-package (not
-- per-component). But this means that it's impossible to
-- install Haddock documentation for internal libraries. We'll
-- keep this constraint for now; this means you can't use
-- Cabal to Haddock internal libraries. This does not seem
-- like a big problem.
docdir = docdir dirs',
htmldir = htmldir dirs',
haddockdir = haddockdir dirs'
}
where
dirs = absoluteComponentInstallDirs pkg lbi uid copydest
-- Notice use of 'absoluteInstallDirs' (not the
-- per-component variant). This means for non-library
-- packages we'll just pick a nondescriptive foo-0.1
dirs' = absoluteInstallDirs pkg lbi copydest

-- | Backwards compatibility function which computes the InstallDirs
-- assuming that @$libname@ points to the public library (or some fake
-- package identifier if there is no public library.) IF AT ALL
Expand Down

0 comments on commit 5f55491

Please sign in to comment.