Skip to content

Commit 590f505

Browse files
committed
Undo backwards incompatible change to install paths.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
1 parent f3b1a03 commit 590f505

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
@@ -637,8 +637,8 @@ configure (pkg_descr0, pbi) cfg = do
637637

638638
-- TODO: This is not entirely correct, because the dirs may vary
639639
-- across libraries/executables
640-
let dirs = absoluteInstallDirs pkg_descr lbi (localComponentId lbi) NoCopyDest
641-
relative = prefixRelativeInstallDirs (packageId pkg_descr) lbi (localComponentId lbi)
640+
let dirs = absoluteInstallDirs pkg_descr lbi NoCopyDest
641+
relative = prefixRelativeInstallDirs (packageId pkg_descr) lbi
642642

643643
unless (isAbsolute (prefix dirs)) $ die $
644644
"expected an absolute directory name for --prefix: " ++ prefix dirs
@@ -2061,7 +2061,7 @@ checkRelocatable verbosity pkg lbi
20612061
-- NB: should be good enough to check this against the default
20622062
-- component ID, but if we wanted to be strictly correct we'd
20632063
-- check for each ComponentId.
2064-
installDirs = absoluteInstallDirs pkg lbi (localComponentId lbi) NoCopyDest
2064+
installDirs = absoluteInstallDirs pkg lbi NoCopyDest
20652065
p = prefix installDirs
20662066
relativeInstallDirs (InstallDirs {..}) =
20672067
all isJust
@@ -2085,7 +2085,7 @@ checkRelocatable verbosity pkg lbi
20852085
-- NB: should be good enough to check this against the default
20862086
-- component ID, but if we wanted to be strictly correct we'd
20872087
-- check for each ComponentId.
2088-
installDirs = absoluteInstallDirs pkg lbi (localComponentId lbi) NoCopyDest
2088+
installDirs = absoluteInstallDirs pkg lbi NoCopyDest
20892089
p = prefix installDirs
20902090
ipkgs = PackageIndex.allPackages (installedPkgs lbi)
20912091
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
@@ -647,7 +647,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
647647
profileLibFilePath = libTargetDir </> mkProfLibName cid
648648
sharedLibFilePath = libTargetDir </> mkSharedLibName compiler_id cid
649649
ghciLibFilePath = libTargetDir </> Internal.mkGHCiLibName cid
650-
libInstallPath = libdir $ absoluteInstallDirs pkg_descr lbi cid NoCopyDest
650+
libInstallPath = libdir $ absoluteComponentInstallDirs pkg_descr lbi cid NoCopyDest
651651
sharedLibInstallPath = libInstallPath </> mkSharedLibName compiler_id cid
652652

653653
stubObjs <- fmap 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 (localComponentId 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 (componentId clbi) copydest
124+
} = absoluteComponentInstallDirs pkg_descr lbi (componentId 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 (componentId clbi) copydest
155+
} = absoluteComponentInstallDirs pkg_descr lbi (componentId 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
@@ -60,6 +60,7 @@ module Distribution.Simple.LocalBuildInfo (
6060
-- * Installation directories
6161
module Distribution.Simple.InstallDirs,
6262
absoluteInstallDirs, prefixRelativeInstallDirs,
63+
absoluteComponentInstallDirs, prefixRelativeComponentInstallDirs,
6364
substPathTemplate
6465
) where
6566

@@ -499,7 +500,7 @@ depLibraryPaths :: Bool -- ^ Building for inplace?
499500
-> IO [FilePath]
500501
depLibraryPaths inplace relative lbi clbi = do
501502
let pkgDescr = localPkgDescr lbi
502-
installDirs = absoluteInstallDirs pkgDescr lbi (componentId clbi) NoCopyDest
503+
installDirs = absoluteComponentInstallDirs pkgDescr lbi (componentId clbi) NoCopyDest
503504
executable = case clbi of
504505
ExeComponentLocalBuildInfo {} -> True
505506
_ -> False
@@ -517,7 +518,7 @@ depLibraryPaths inplace relative lbi clbi = do
517518
lbi internalDeps ]
518519
getLibDir sub_clbi
519520
| inplace = libBuildDir lbi sub_clbi
520-
| otherwise = libdir (absoluteInstallDirs pkgDescr lbi (componentId sub_clbi) NoCopyDest)
521+
| otherwise = libdir (absoluteComponentInstallDirs pkgDescr lbi (componentId sub_clbi) NoCopyDest)
521522

522523
let ipkgs = allPackages (installedPkgs lbi)
523524
allDepLibDirs = concatMap Installed.libraryDirs ipkgs
@@ -550,12 +551,22 @@ depLibraryPaths inplace relative lbi clbi = do
550551
-- -----------------------------------------------------------------------------
551552
-- Wrappers for a couple functions from InstallDirs
552553

553-
-- |See 'InstallDirs.absoluteInstallDirs'
554+
-- | Backwards compatibility function which computes the InstallDirs
555+
-- assuming that @$libname@ points to the public library (or some fake
556+
-- package identifier if there is no public library.) IF AT ALL
557+
-- POSSIBLE, please use 'absoluteComponentInstallDirs' instead.
554558
absoluteInstallDirs :: PackageDescription -> LocalBuildInfo
555-
-> ComponentId
556559
-> CopyDest
557560
-> InstallDirs FilePath
558-
absoluteInstallDirs pkg lbi cid copydest =
561+
absoluteInstallDirs pkg lbi copydest =
562+
absoluteComponentInstallDirs pkg lbi (localComponentId lbi) copydest
563+
564+
-- | See 'InstallDirs.absoluteInstallDirs'.
565+
absoluteComponentInstallDirs :: PackageDescription -> LocalBuildInfo
566+
-> ComponentId
567+
-> CopyDest
568+
-> InstallDirs FilePath
569+
absoluteComponentInstallDirs pkg lbi cid copydest =
559570
InstallDirs.absoluteInstallDirs
560571
(packageId pkg)
561572
cid
@@ -564,11 +575,20 @@ absoluteInstallDirs pkg lbi cid copydest =
564575
(hostPlatform lbi)
565576
(installDirTemplates lbi)
566577

567-
-- |See 'InstallDirs.prefixRelativeInstallDirs'
578+
-- | Backwards compatibility function which computes the InstallDirs
579+
-- assuming that @$libname@ points to the public library (or some fake
580+
-- package identifier if there is no public library.) IF AT ALL
581+
-- POSSIBLE, please use 'prefixRelativeComponentInstallDirs' instead.
568582
prefixRelativeInstallDirs :: PackageId -> LocalBuildInfo
569-
-> ComponentId
570583
-> InstallDirs (Maybe FilePath)
571-
prefixRelativeInstallDirs pkg_descr lbi cid =
584+
prefixRelativeInstallDirs pkg_descr lbi =
585+
prefixRelativeComponentInstallDirs pkg_descr lbi (localComponentId lbi)
586+
587+
-- |See 'InstallDirs.prefixRelativeInstallDirs'
588+
prefixRelativeComponentInstallDirs :: PackageId -> LocalBuildInfo
589+
-> ComponentId
590+
-> InstallDirs (Maybe FilePath)
591+
prefixRelativeComponentInstallDirs pkg_descr lbi cid =
572592
InstallDirs.prefixRelativeInstallDirs
573593
(packageId pkg_descr)
574594
cid

Cabal/Distribution/Simple/Register.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ inplaceInstalledPackageInfo inplaceDir distPref pkg abi_hash lib lbi clbi =
388388
adjustRelativeIncludeDirs = map (inplaceDir </>)
389389
libTargetDir = libBuildDir lbi clbi
390390
installDirs =
391-
(absoluteInstallDirs pkg lbi (componentId clbi) NoCopyDest) {
391+
(absoluteComponentInstallDirs pkg lbi (componentId clbi) NoCopyDest) {
392392
libdir = inplaceDir </> libTargetDir,
393393
datadir = inplaceDir </> dataDir pkg,
394394
docdir = inplaceDocdir,
@@ -420,7 +420,7 @@ absoluteInstalledPackageInfo pkg abi_hash lib lbi clbi =
420420
| null (installIncludes bi) = []
421421
| otherwise = [includedir installDirs]
422422
bi = libBuildInfo lib
423-
installDirs = absoluteInstallDirs pkg lbi (componentId clbi) NoCopyDest
423+
installDirs = absoluteComponentInstallDirs pkg lbi (componentId clbi) NoCopyDest
424424

425425

426426
relocatableInstalledPackageInfo :: PackageDescription
@@ -442,7 +442,7 @@ relocatableInstalledPackageInfo pkg abi_hash lib lbi clbi pkgroot =
442442
bi = libBuildInfo lib
443443

444444
installDirs = fmap (("${pkgroot}" </>) . shortRelativePath pkgroot)
445-
$ absoluteInstallDirs pkg lbi (componentId clbi) NoCopyDest
445+
$ absoluteComponentInstallDirs pkg lbi (componentId clbi) NoCopyDest
446446

447447
-- -----------------------------------------------------------------------------
448448
-- 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(componentId), ComponentName(CLibName))
10+
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(localPkgDescr, compiler), absoluteComponentInstallDirs, InstallDirs(libdir), maybeGetComponentLocalBuildInfo, ComponentLocalBuildInfo(componentId), ComponentName(CLibName))
1111
import Distribution.Simple.InstallDirs (CopyDest(NoCopyDest))
1212
import Distribution.Simple.BuildPaths (mkLibName, mkSharedLibName)
1313
import Distribution.Simple.Compiler (compilerId)
@@ -285,7 +285,7 @@ tests config =
285285
cname = (CLibName "foo-internal")
286286
Just clbi = maybeGetComponentLocalBuildInfo lbi cname
287287
cid = componentId clbi
288-
dir = libdir (absoluteInstallDirs pkg_descr lbi cid NoCopyDest)
288+
dir = libdir (absoluteComponentInstallDirs pkg_descr lbi cid NoCopyDest)
289289
assertBool "interface files should NOT be installed" . not
290290
=<< liftIO (doesFileExist (dir </> "Foo.hi"))
291291
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-
, localComponentId
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 component ID
54-
-- (it shouldn't make a difference)
55-
let destDir = mandir (absoluteInstallDirs pkg lbi (localComponentId 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)