Skip to content

Commit 3e78150

Browse files
committed
Undo backwards incompatible change to install paths.
Signed-off-by: Edward Z. Yang <[email protected]>
1 parent 2d0b9af commit 3e78150

File tree

8 files changed

+47
-29
lines changed

8 files changed

+47
-29
lines changed

Cabal/Distribution/Simple/Build/PathsModule.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,14 @@ generate pkg_descr lbi clbi =
178178
datadir = flat_datadir,
179179
libexecdir = flat_libexecdir,
180180
sysconfdir = flat_sysconfdir
181-
} = absoluteInstallDirs pkg_descr lbi cid NoCopyDest
181+
} = absoluteComponentInstallDirs pkg_descr lbi cid NoCopyDest
182182
InstallDirs {
183183
bindir = flat_bindirrel,
184184
libdir = flat_libdirrel,
185185
datadir = flat_datadirrel,
186186
libexecdir = flat_libexecdirrel,
187187
sysconfdir = flat_sysconfdirrel
188-
} = prefixRelativeInstallDirs (packageId pkg_descr) lbi cid
188+
} = prefixRelativeComponentInstallDirs (packageId pkg_descr) lbi cid
189189

190190
flat_bindirreloc = shortRelativePath flat_prefix flat_bindir
191191
flat_libdirreloc = shortRelativePath flat_prefix flat_libdir

Cabal/Distribution/Simple/Configure.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,8 @@ configure (pkg_descr0', pbi) cfg = do
649649

650650
-- TODO: This is not entirely correct, because the dirs may vary
651651
-- across libraries/executables
652-
let dirs = absoluteInstallDirs pkg_descr lbi (localUnitId lbi) NoCopyDest
653-
relative = prefixRelativeInstallDirs (packageId pkg_descr) lbi (localUnitId lbi)
652+
let dirs = absoluteInstallDirs pkg_descr lbi NoCopyDest
653+
relative = prefixRelativeInstallDirs (packageId pkg_descr) lbi
654654

655655
unless (isAbsolute (prefix dirs)) $ die $
656656
"expected an absolute directory name for --prefix: " ++ prefix dirs
@@ -2038,7 +2038,7 @@ checkRelocatable verbosity pkg lbi
20382038
-- NB: should be good enough to check this against the default
20392039
-- component ID, but if we wanted to be strictly correct we'd
20402040
-- check for each ComponentId.
2041-
installDirs = absoluteInstallDirs pkg lbi (localUnitId lbi) NoCopyDest
2041+
installDirs = absoluteInstallDirs pkg lbi NoCopyDest
20422042
p = prefix installDirs
20432043
relativeInstallDirs (InstallDirs {..}) =
20442044
all isJust
@@ -2062,7 +2062,7 @@ checkRelocatable verbosity pkg lbi
20622062
-- NB: should be good enough to check this against the default
20632063
-- component ID, but if we wanted to be strictly correct we'd
20642064
-- check for each ComponentId.
2065-
installDirs = absoluteInstallDirs pkg lbi (localUnitId lbi) NoCopyDest
2065+
installDirs = absoluteInstallDirs pkg lbi NoCopyDest
20662066
p = prefix installDirs
20672067
ipkgs = PackageIndex.allPackages (installedPkgs lbi)
20682068
msg l = "Library directory of a dependency: " ++ show l ++

Cabal/Distribution/Simple/GHC.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
651651
profileLibFilePath = libTargetDir </> mkProfLibName uid
652652
sharedLibFilePath = libTargetDir </> mkSharedLibName compiler_id uid
653653
ghciLibFilePath = libTargetDir </> Internal.mkGHCiLibName uid
654-
libInstallPath = libdir $ absoluteInstallDirs pkg_descr lbi uid NoCopyDest
654+
libInstallPath = libdir $ absoluteComponentInstallDirs pkg_descr lbi uid NoCopyDest
655655
sharedLibInstallPath = libInstallPath </> mkSharedLibName compiler_id uid
656656

657657
stubObjs <- catMaybes <$> sequence

Cabal/Distribution/Simple/Install.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ install pkg_descr lbi flags = do
7474
docdir = docPref,
7575
htmldir = htmlPref,
7676
haddockdir = interfacePref}
77-
-- Notice use of localComponentId. This means for
78-
-- non-library packages we'll just pick a nondescriptive foo-0.1
79-
= absoluteInstallDirs pkg_descr lbi (localUnitId lbi) copydest
77+
-- Notice use of 'absoluteInstallDirs' (not the
78+
-- per-component variant). This means for non-library
79+
-- packages we'll just pick a nondescriptive foo-0.1
80+
= absoluteInstallDirs pkg_descr lbi copydest
8081

8182
unless (hasLibs pkg_descr || hasExes pkg_descr) $
8283
die "No executables and no library found. Nothing to do."
@@ -120,7 +121,7 @@ install pkg_descr lbi flags = do
120121
let InstallDirs{
121122
libdir = libPref,
122123
includedir = incPref
123-
} = absoluteInstallDirs pkg_descr lbi (componentUnitId clbi) copydest
124+
} = absoluteComponentInstallDirs pkg_descr lbi (componentUnitId clbi) copydest
124125
buildPref = libBuildDir lbi clbi
125126
-- TODO: decide if we need the user to be able to control the libdir
126127
-- for shared libs independently of the one for static libs. If so
@@ -151,7 +152,7 @@ install pkg_descr lbi flags = do
151152
withExeLBI pkg_descr lbi $ \exe clbi -> do
152153
let installDirs@InstallDirs {
153154
bindir = binPref
154-
} = absoluteInstallDirs pkg_descr lbi (componentUnitId clbi) copydest
155+
} = absoluteComponentInstallDirs pkg_descr lbi (componentUnitId clbi) copydest
155156
-- the installers know how to find the actual location of the
156157
-- binaries
157158
buildPref = buildDir lbi

Cabal/Distribution/Simple/LocalBuildInfo.hs

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ module Distribution.Simple.LocalBuildInfo (
6262
-- * Installation directories
6363
module Distribution.Simple.InstallDirs,
6464
absoluteInstallDirs, prefixRelativeInstallDirs,
65+
absoluteComponentInstallDirs, prefixRelativeComponentInstallDirs,
6566
substPathTemplate
6667
) where
6768

@@ -511,7 +512,7 @@ depLibraryPaths :: Bool -- ^ Building for inplace?
511512
-> IO [FilePath]
512513
depLibraryPaths inplace relative lbi clbi = do
513514
let pkgDescr = localPkgDescr lbi
514-
installDirs = absoluteInstallDirs pkgDescr lbi (componentUnitId clbi) NoCopyDest
515+
installDirs = absoluteComponentInstallDirs pkgDescr lbi (componentUnitId clbi) NoCopyDest
515516
executable = case clbi of
516517
ExeComponentLocalBuildInfo {} -> True
517518
_ -> False
@@ -529,7 +530,7 @@ depLibraryPaths inplace relative lbi clbi = do
529530
lbi internalDeps ]
530531
getLibDir sub_clbi
531532
| inplace = libBuildDir lbi sub_clbi
532-
| otherwise = libdir (absoluteInstallDirs pkgDescr lbi (componentUnitId sub_clbi) NoCopyDest)
533+
| otherwise = libdir (absoluteComponentInstallDirs pkgDescr lbi (componentUnitId sub_clbi) NoCopyDest)
533534

534535
let ipkgs = allPackages (installedPkgs lbi)
535536
allDepLibDirs = concatMap Installed.libraryDirs ipkgs
@@ -562,12 +563,22 @@ depLibraryPaths inplace relative lbi clbi = do
562563
-- -----------------------------------------------------------------------------
563564
-- Wrappers for a couple functions from InstallDirs
564565

565-
-- |See 'InstallDirs.absoluteInstallDirs'
566+
-- | Backwards compatibility function which computes the InstallDirs
567+
-- assuming that @$libname@ points to the public library (or some fake
568+
-- package identifier if there is no public library.) IF AT ALL
569+
-- POSSIBLE, please use 'absoluteComponentInstallDirs' instead.
566570
absoluteInstallDirs :: PackageDescription -> LocalBuildInfo
567-
-> UnitId
568571
-> CopyDest
569572
-> InstallDirs FilePath
570-
absoluteInstallDirs pkg lbi uid copydest =
573+
absoluteInstallDirs pkg lbi copydest =
574+
absoluteComponentInstallDirs pkg lbi (localUnitId lbi) copydest
575+
576+
-- | See 'InstallDirs.absoluteInstallDirs'.
577+
absoluteComponentInstallDirs :: PackageDescription -> LocalBuildInfo
578+
-> UnitId
579+
-> CopyDest
580+
-> InstallDirs FilePath
581+
absoluteComponentInstallDirs pkg lbi uid copydest =
571582
InstallDirs.absoluteInstallDirs
572583
(packageId pkg)
573584
uid
@@ -576,11 +587,20 @@ absoluteInstallDirs pkg lbi uid copydest =
576587
(hostPlatform lbi)
577588
(installDirTemplates lbi)
578589

579-
-- |See 'InstallDirs.prefixRelativeInstallDirs'
590+
-- | Backwards compatibility function which computes the InstallDirs
591+
-- assuming that @$libname@ points to the public library (or some fake
592+
-- package identifier if there is no public library.) IF AT ALL
593+
-- POSSIBLE, please use 'prefixRelativeComponentInstallDirs' instead.
580594
prefixRelativeInstallDirs :: PackageId -> LocalBuildInfo
581-
-> UnitId
582595
-> InstallDirs (Maybe FilePath)
583-
prefixRelativeInstallDirs pkg_descr lbi uid =
596+
prefixRelativeInstallDirs pkg_descr lbi =
597+
prefixRelativeComponentInstallDirs pkg_descr lbi (localUnitId lbi)
598+
599+
-- |See 'InstallDirs.prefixRelativeInstallDirs'
600+
prefixRelativeComponentInstallDirs :: PackageId -> LocalBuildInfo
601+
-> UnitId
602+
-> InstallDirs (Maybe FilePath)
603+
prefixRelativeComponentInstallDirs pkg_descr lbi uid =
584604
InstallDirs.prefixRelativeInstallDirs
585605
(packageId pkg_descr)
586606
uid

Cabal/Distribution/Simple/Register.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ inplaceInstalledPackageInfo inplaceDir distPref pkg abi_hash lib lbi clbi =
385385
adjustRelativeIncludeDirs = map (inplaceDir </>)
386386
libTargetDir = libBuildDir lbi clbi
387387
installDirs =
388-
(absoluteInstallDirs pkg lbi (componentUnitId clbi) NoCopyDest) {
388+
(absoluteComponentInstallDirs pkg lbi (componentUnitId clbi) NoCopyDest) {
389389
libdir = inplaceDir </> libTargetDir,
390390
datadir = inplaceDir </> dataDir pkg,
391391
docdir = inplaceDocdir,
@@ -417,7 +417,7 @@ absoluteInstalledPackageInfo pkg abi_hash lib lbi clbi =
417417
| null (installIncludes bi) = []
418418
| otherwise = [includedir installDirs]
419419
bi = libBuildInfo lib
420-
installDirs = absoluteInstallDirs pkg lbi (componentUnitId clbi) NoCopyDest
420+
installDirs = absoluteComponentInstallDirs pkg lbi (componentUnitId clbi) NoCopyDest
421421

422422

423423
relocatableInstalledPackageInfo :: PackageDescription
@@ -439,7 +439,7 @@ relocatableInstalledPackageInfo pkg abi_hash lib lbi clbi pkgroot =
439439
bi = libBuildInfo lib
440440

441441
installDirs = fmap (("${pkgroot}" </>) . shortRelativePath pkgroot)
442-
$ absoluteInstallDirs pkg lbi (componentUnitId clbi) NoCopyDest
442+
$ absoluteComponentInstallDirs pkg lbi (componentUnitId clbi) NoCopyDest
443443

444444
-- -----------------------------------------------------------------------------
445445
-- Unregistration

Cabal/tests/PackageTests/Tests.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import qualified PackageTests.TestStanza.Check
77
import qualified PackageTests.DeterministicAr.Check
88
import qualified PackageTests.TestSuiteTests.ExeV10.Check
99

10-
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(localPkgDescr, compiler), absoluteInstallDirs, InstallDirs(libdir), maybeGetComponentLocalBuildInfo, ComponentLocalBuildInfo(componentUnitId), ComponentName(CLibName))
10+
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(localPkgDescr, compiler), absoluteComponentInstallDirs, InstallDirs(libdir), maybeGetComponentLocalBuildInfo, ComponentLocalBuildInfo(componentUnitId), ComponentName(CLibName))
1111
import Distribution.Simple.InstallDirs (CopyDest(NoCopyDest))
1212
import Distribution.Simple.BuildPaths (mkLibName, mkSharedLibName)
1313
import Distribution.Simple.Compiler (compilerId)
@@ -340,7 +340,7 @@ tests config = do
340340
cname = (CLibName "foo-internal")
341341
Just clbi = maybeGetComponentLocalBuildInfo lbi cname
342342
uid = componentUnitId clbi
343-
dir = libdir (absoluteInstallDirs pkg_descr lbi uid NoCopyDest)
343+
dir = libdir (absoluteComponentInstallDirs pkg_descr lbi uid NoCopyDest)
344344
assertBool "interface files should NOT be installed" . not
345345
=<< liftIO (doesFileExist (dir </> "Foo.hi"))
346346
assertBool "static library should NOT be installed" . not

cabal-install/Setup.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import Distribution.Simple.InstallDirs ( mandir
1010
)
1111
import Distribution.Simple.LocalBuildInfo ( LocalBuildInfo(..)
1212
, absoluteInstallDirs
13-
, localUnitId
1413
)
1514
import Distribution.Simple.Utils ( copyFiles
1615
, notice )
@@ -50,7 +49,5 @@ buildManpage lbi verbosity = do
5049

5150
installManpage :: PackageDescription -> LocalBuildInfo -> Verbosity -> CopyDest -> IO ()
5251
installManpage pkg lbi verbosity copy = do
53-
-- NB: no library here, let's just use the default unit ID
54-
-- (it shouldn't make a difference)
55-
let destDir = mandir (absoluteInstallDirs pkg lbi (localUnitId lbi) copy) </> "man1"
52+
let destDir = mandir (absoluteInstallDirs pkg lbi copy) </> "man1"
5653
copyFiles verbosity destDir [(buildDir lbi </> "cabal", "cabal.1")]

0 commit comments

Comments
 (0)