From 15d5c013a81ffefa4f406c175344bee8ac40bf5a Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Mon, 7 Oct 2019 09:06:03 -0400 Subject: [PATCH 1/4] Restructure Includes3 tests so that I can also test Hackage case. Signed-off-by: Edward Z. Yang --- .../PackageTests/Backpack/Includes3/Includes3.cabal | 6 +++--- .../Backpack/Includes3/cabal.external.project | 2 +- .../Includes3/{exe => repo/exe-0.1.0.0}/Main.hs | 0 .../Includes3/{exe => repo/exe-0.1.0.0}/exe.cabal | 0 .../Includes3/{indef => repo/indef-0.1.0.0}/Foo.hs | 0 .../{indef => repo/indef-0.1.0.0}/indef.cabal | 0 .../{sigs => repo/sigs-0.1.0.0}/Data/Map.hsig | 0 .../Includes3/{sigs => repo/sigs-0.1.0.0}/sigs.cabal | 0 .../Backpack/Includes3/setup-external-explicit.out | 4 ++-- .../Backpack/Includes3/setup-external-explicit.test.hs | 4 ++-- .../Backpack/Includes3/setup-external-fail.test.hs | 6 +++--- .../Backpack/Includes3/setup-external-ok.cabal.out | 8 ++++---- .../Backpack/Includes3/setup-external-ok.out | 8 ++++---- .../Backpack/Includes3/setup-external-ok.test.hs | 10 +++++----- 14 files changed, 24 insertions(+), 24 deletions(-) rename cabal-testsuite/PackageTests/Backpack/Includes3/{exe => repo/exe-0.1.0.0}/Main.hs (100%) rename cabal-testsuite/PackageTests/Backpack/Includes3/{exe => repo/exe-0.1.0.0}/exe.cabal (100%) rename cabal-testsuite/PackageTests/Backpack/Includes3/{indef => repo/indef-0.1.0.0}/Foo.hs (100%) rename cabal-testsuite/PackageTests/Backpack/Includes3/{indef => repo/indef-0.1.0.0}/indef.cabal (100%) rename cabal-testsuite/PackageTests/Backpack/Includes3/{sigs => repo/sigs-0.1.0.0}/Data/Map.hsig (100%) rename cabal-testsuite/PackageTests/Backpack/Includes3/{sigs => repo/sigs-0.1.0.0}/sigs.cabal (100%) diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/Includes3.cabal b/cabal-testsuite/PackageTests/Backpack/Includes3/Includes3.cabal index 483f21ad6d6..9bd96154738 100644 --- a/cabal-testsuite/PackageTests/Backpack/Includes3/Includes3.cabal +++ b/cabal-testsuite/PackageTests/Backpack/Includes3/Includes3.cabal @@ -9,17 +9,17 @@ cabal-version: 1.25 library sigs build-depends: base signatures: Data.Map - hs-source-dirs: sigs + hs-source-dirs: repo/sigs-0.1.0.0 default-language: Haskell2010 library indef build-depends: base, sigs exposed-modules: Foo - hs-source-dirs: indef + hs-source-dirs: repo/indef-0.1.0.0 default-language: Haskell2010 executable exe build-depends: base, containers, indef main-is: Main.hs - hs-source-dirs: exe + hs-source-dirs: repo/exe-0.1.0.0 default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/cabal.external.project b/cabal-testsuite/PackageTests/Backpack/Includes3/cabal.external.project index 4c9d75fb7f7..58c0e9be8e0 100644 --- a/cabal-testsuite/PackageTests/Backpack/Includes3/cabal.external.project +++ b/cabal-testsuite/PackageTests/Backpack/Includes3/cabal.external.project @@ -1 +1 @@ -packages: exe indef sigs +packages: repo/exe-0.1.0.0 repo/indef-0.1.0.0 repo/sigs-0.1.0.0 diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/exe/Main.hs b/cabal-testsuite/PackageTests/Backpack/Includes3/repo/exe-0.1.0.0/Main.hs similarity index 100% rename from cabal-testsuite/PackageTests/Backpack/Includes3/exe/Main.hs rename to cabal-testsuite/PackageTests/Backpack/Includes3/repo/exe-0.1.0.0/Main.hs diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/exe/exe.cabal b/cabal-testsuite/PackageTests/Backpack/Includes3/repo/exe-0.1.0.0/exe.cabal similarity index 100% rename from cabal-testsuite/PackageTests/Backpack/Includes3/exe/exe.cabal rename to cabal-testsuite/PackageTests/Backpack/Includes3/repo/exe-0.1.0.0/exe.cabal diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/indef/Foo.hs b/cabal-testsuite/PackageTests/Backpack/Includes3/repo/indef-0.1.0.0/Foo.hs similarity index 100% rename from cabal-testsuite/PackageTests/Backpack/Includes3/indef/Foo.hs rename to cabal-testsuite/PackageTests/Backpack/Includes3/repo/indef-0.1.0.0/Foo.hs diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/indef/indef.cabal b/cabal-testsuite/PackageTests/Backpack/Includes3/repo/indef-0.1.0.0/indef.cabal similarity index 100% rename from cabal-testsuite/PackageTests/Backpack/Includes3/indef/indef.cabal rename to cabal-testsuite/PackageTests/Backpack/Includes3/repo/indef-0.1.0.0/indef.cabal diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/sigs/Data/Map.hsig b/cabal-testsuite/PackageTests/Backpack/Includes3/repo/sigs-0.1.0.0/Data/Map.hsig similarity index 100% rename from cabal-testsuite/PackageTests/Backpack/Includes3/sigs/Data/Map.hsig rename to cabal-testsuite/PackageTests/Backpack/Includes3/repo/sigs-0.1.0.0/Data/Map.hsig diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/sigs/sigs.cabal b/cabal-testsuite/PackageTests/Backpack/Includes3/repo/sigs-0.1.0.0/sigs.cabal similarity index 100% rename from cabal-testsuite/PackageTests/Backpack/Includes3/sigs/sigs.cabal rename to cabal-testsuite/PackageTests/Backpack/Includes3/repo/sigs-0.1.0.0/sigs.cabal diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-explicit.out b/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-explicit.out index 67ed89e84de..da91bf8ad36 100644 --- a/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-explicit.out +++ b/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-explicit.out @@ -8,7 +8,7 @@ for sigs-0.1.0.0.. Preprocessing library for sigs-0.1.0.0.. Running Haddock on library instantiated with Data.Map = for sigs-0.1.0.0.. -Documentation created: ../setup-external-explicit.dist/work/sigs/dist/doc/html/sigs/index.html +Documentation created: ../../setup-external-explicit.dist/work/repo/sigs-0.1.0.0/dist/doc/html/sigs/index.html # Setup copy Installing library in # Setup register @@ -24,7 +24,7 @@ for indef-0.1.0.0.. Preprocessing library for indef-0.1.0.0.. Running Haddock on library instantiated with Data.Map = for indef-0.1.0.0.. -Documentation created: ../setup-external-explicit.dist/work/indef/dist/doc/html/indef/index.html +Documentation created: ../../setup-external-explicit.dist/work/repo/indef-0.1.0.0/dist/doc/html/indef/index.html # Setup copy Installing library in # Setup register diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-explicit.test.hs b/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-explicit.test.hs index 42752775d3b..50e158f6a41 100644 --- a/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-explicit.test.hs +++ b/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-explicit.test.hs @@ -3,5 +3,5 @@ import Test.Cabal.Prelude main = setupTest $ do skipUnless =<< ghcVersionIs (>= mkVersion [8,1]) withPackageDb $ do - withDirectory "sigs" $ setup_install_with_docs ["--cid", "sigs-0.1.0.0", "lib:sigs"] - withDirectory "indef" $ setup_install_with_docs ["--cid", "indef-0.1.0.0", "--dependency=sigs=sigs-0.1.0.0", "lib:indef"] + withDirectory "repo/sigs-0.1.0.0" $ setup_install_with_docs ["--cid", "sigs-0.1.0.0", "lib:sigs"] + withDirectory "repo/indef-0.1.0.0" $ setup_install_with_docs ["--cid", "indef-0.1.0.0", "--dependency=sigs=sigs-0.1.0.0", "lib:indef"] diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-fail.test.hs b/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-fail.test.hs index 2b9a0758de4..fcdcc9c1294 100644 --- a/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-fail.test.hs +++ b/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-fail.test.hs @@ -2,10 +2,10 @@ import Test.Cabal.Prelude main = setupAndCabalTest $ do skipUnless =<< ghcVersionIs (>= mkVersion [8,1]) withPackageDb $ do - withDirectory "sigs" $ setup_install [] - withDirectory "indef" $ setup_install [] + withDirectory "repo/sigs-0.1.0.0" $ setup_install [] + withDirectory "repo/indef-0.1.0.0" $ setup_install [] -- Forgot to build the instantiated versions! - withDirectory "exe" $ do + withDirectory "repo/exe-0.1.0.0" $ do -- Missing package message includes a unit identifier, -- which wobbles when version numbers change r <- recordMode DoNotRecord . fails $ setup' "configure" [] diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.cabal.out b/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.cabal.out index eb5625f8716..3df24d73430 100644 --- a/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.cabal.out +++ b/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.cabal.out @@ -9,7 +9,7 @@ for sigs-0.1.0.0.. Preprocessing library for sigs-0.1.0.0.. Running Haddock on library instantiated with Data.Map = for sigs-0.1.0.0.. -Documentation created: ../setup-external-ok.cabal.dist/work/sigs/dist/doc/html/sigs/index.html +Documentation created: ../../setup-external-ok.cabal.dist/work/repo/sigs-0.1.0.0/dist/doc/html/sigs/index.html # Setup copy Installing library in # Setup register @@ -26,7 +26,7 @@ for indef-0.1.0.0.. Preprocessing library for indef-0.1.0.0.. Running Haddock on library instantiated with Data.Map = for indef-0.1.0.0.. -Documentation created: ../setup-external-ok.cabal.dist/work/indef/dist/doc/html/indef/index.html +Documentation created: ../../setup-external-ok.cabal.dist/work/repo/indef-0.1.0.0/dist/doc/html/indef/index.html # Setup copy Installing library in # Setup register @@ -44,7 +44,7 @@ Preprocessing library for sigs-0.1.0.0.. Running Haddock on library instantiated with Data.Map = containers-:Data.Map for sigs-0.1.0.0.. -Documentation created: ../setup-external-ok.cabal.dist/work/sigs/dist/doc/html/sigs/index.html +Documentation created: ../../setup-external-ok.cabal.dist/work/repo/sigs-0.1.0.0/dist/doc/html/sigs/index.html # Setup copy Installing library in # Setup register @@ -62,7 +62,7 @@ Preprocessing library for indef-0.1.0.0.. Running Haddock on library instantiated with Data.Map = containers-:Data.Map for indef-0.1.0.0.. -Documentation created: ../setup-external-ok.cabal.dist/work/indef/dist/doc/html/indef/index.html +Documentation created: ../../setup-external-ok.cabal.dist/work/repo/indef-0.1.0.0/dist/doc/html/indef/index.html # Setup copy Installing library in # Setup register diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.out b/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.out index 31d49ef36f1..474250807c8 100644 --- a/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.out +++ b/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.out @@ -8,7 +8,7 @@ for sigs-0.1.0.0.. Preprocessing library for sigs-0.1.0.0.. Running Haddock on library instantiated with Data.Map = for sigs-0.1.0.0.. -Documentation created: ../setup-external-ok.dist/work/sigs/dist/doc/html/sigs/index.html +Documentation created: ../../setup-external-ok.dist/work/repo/sigs-0.1.0.0/dist/doc/html/sigs/index.html # Setup copy Installing library in # Setup register @@ -24,7 +24,7 @@ for indef-0.1.0.0.. Preprocessing library for indef-0.1.0.0.. Running Haddock on library instantiated with Data.Map = for indef-0.1.0.0.. -Documentation created: ../setup-external-ok.dist/work/indef/dist/doc/html/indef/index.html +Documentation created: ../../setup-external-ok.dist/work/repo/indef-0.1.0.0/dist/doc/html/indef/index.html # Setup copy Installing library in # Setup register @@ -41,7 +41,7 @@ Preprocessing library for sigs-0.1.0.0.. Running Haddock on library instantiated with Data.Map = containers-:Data.Map for sigs-0.1.0.0.. -Documentation created: ../setup-external-ok.dist/work/sigs/dist/doc/html/sigs/index.html +Documentation created: ../../setup-external-ok.dist/work/repo/sigs-0.1.0.0/dist/doc/html/sigs/index.html # Setup copy Installing library in # Setup register @@ -58,7 +58,7 @@ Preprocessing library for indef-0.1.0.0.. Running Haddock on library instantiated with Data.Map = containers-:Data.Map for indef-0.1.0.0.. -Documentation created: ../setup-external-ok.dist/work/indef/dist/doc/html/indef/index.html +Documentation created: ../../setup-external-ok.dist/work/repo/indef-0.1.0.0/dist/doc/html/indef/index.html # Setup copy Installing library in # Setup register diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.test.hs b/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.test.hs index e89541fc101..0563be2277d 100644 --- a/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.test.hs +++ b/cabal-testsuite/PackageTests/Backpack/Includes3/setup-external-ok.test.hs @@ -5,18 +5,18 @@ main = setupAndCabalTest $ do skipUnless =<< ghcVersionIs (>= mkVersion [8,1]) withPackageDb $ do containers_id <- getIPID "containers" - withDirectory "sigs" $ setup_install_with_docs ["--ipid", "sigs-0.1.0.0"] - withDirectory "indef" $ setup_install_with_docs ["--ipid", "indef-0.1.0.0"] - withDirectory "sigs" $ do + withDirectory "repo/sigs-0.1.0.0" $ setup_install_with_docs ["--ipid", "sigs-0.1.0.0"] + withDirectory "repo/indef-0.1.0.0" $ setup_install_with_docs ["--ipid", "indef-0.1.0.0"] + withDirectory "repo/sigs-0.1.0.0" $ do -- NB: this REUSES the dist directory that we typechecked -- indefinitely, but it's OK; the recompile checker should get it. setup_install_with_docs ["--ipid", "sigs-0.1.0.0", "--instantiate-with", "Data.Map=" ++ containers_id ++ ":Data.Map"] - withDirectory "indef" $ do + withDirectory "repo/indef-0.1.0.0" $ do -- Ditto. setup_install_with_docs ["--ipid", "indef-0.1.0.0", "--instantiate-with", "Data.Map=" ++ containers_id ++ ":Data.Map"] - withDirectory "exe" $ do + withDirectory "repo/exe-0.1.0.0" $ do setup_install [] runExe' "exe" [] >>= assertOutputContains "fromList [(0,2),(2,4)]" From fa9fa1c41d325c6214b9446c966f04a37ac67d5c Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sun, 27 Oct 2019 20:44:55 -0400 Subject: [PATCH 2/4] Compute correct install directories for instantiated Backpack components Previously, we would compute elabInstallDirs once when configuring a component, and then reuse the exactly same install directories for every instantiation of the package. But this is wrong, since we're installing the header/object files for each instantiation to a different directory. We refactor install directory computation into a helper function and then call it again at instantiation time to refresh the install directories. For some reason, this bug ONLY manifests for packages installed from Hackage; it seems install dirs are not respected for inplace packages. Fixes #6005 Signed-off-by: Edward Z. Yang --- .../Distribution/Client/ProjectPlanning.hs | 128 +++++++++--------- .../Backpack/Includes3/cabal-repo.out | 29 ++++ .../Backpack/Includes3/cabal-repo.test.hs | 6 + .../Backpack/Includes3/cabal.repo.project | 1 + 4 files changed, 103 insertions(+), 61 deletions(-) create mode 100644 cabal-testsuite/PackageTests/Backpack/Includes3/cabal-repo.out create mode 100644 cabal-testsuite/PackageTests/Backpack/Includes3/cabal-repo.test.hs create mode 100644 cabal-testsuite/PackageTests/Backpack/Includes3/cabal.repo.project diff --git a/cabal-install/Distribution/Client/ProjectPlanning.hs b/cabal-install/Distribution/Client/ProjectPlanning.hs index 1c50d893ed3..13b6fc781bc 100644 --- a/cabal-install/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/Distribution/Client/ProjectPlanning.hs @@ -649,7 +649,12 @@ rebuildInstallPlan verbosity projectConfigAllPackages projectConfigLocalPackages (getMapMappend projectConfigSpecificPackage) - let instantiatedPlan = instantiateInstallPlan elaboratedPlan + let instantiatedPlan + = instantiateInstallPlan + cabalStoreDirLayout + defaultInstallDirs + elaboratedShared + elaboratedPlan liftIO $ debugNoWrap verbosity (InstallPlan.showInstallPlan instantiatedPlan) return (instantiatedPlan, elaboratedShared) where @@ -1478,7 +1483,7 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB -- 5. Construct the final ElaboratedConfiguredPackage let - elab = elab1 { + elab2 = elab1 { elabModuleShape = lc_shape lc, elabUnitId = abstractUnitId (lc_uid lc), elabComponentId = lc_cid lc, @@ -1488,8 +1493,14 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB compOrderLibDependencies = ordNub (map (abstractUnitId . ci_id) (lc_includes lc ++ lc_sig_includes lc)) - }, - elabInstallDirs = install_dirs cid + } + } + elab = elab2 { + elabInstallDirs = computeInstallDirs + storeDirLayout + defaultInstallDirs + elaboratedSharedConfig + elab2 } -- 6. Construct the updated local maps @@ -1545,31 +1556,6 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB | PkgconfigDependency pn _ <- PD.pkgconfigDepends (Cabal.componentBuildInfo comp) ] - install_dirs cid - | shouldBuildInplaceOnly spkg - -- use the ordinary default install dirs - = (InstallDirs.absoluteInstallDirs - pkgid - (newSimpleUnitId cid) - (compilerInfo compiler) - InstallDirs.NoCopyDest - platform - defaultInstallDirs) { - - -- absoluteInstallDirs sets these as 'undefined' but we have - -- to use them as "Setup.hs configure" args - InstallDirs.libsubdir = "", - InstallDirs.libexecsubdir = "", - InstallDirs.datasubdir = "" - } - - | otherwise - -- use special simplified install dirs - = storePackageInstallDirs - storeDirLayout - (compilerId compiler) - cid - inplace_bin_dir elab = binDirectoryFor distDirLayout @@ -1631,14 +1617,20 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB elab where elab0@ElaboratedConfiguredPackage{..} = elaborateSolverToCommon pkg - elab = elab0 { + elab1 = elab0 { elabUnitId = newSimpleUnitId pkgInstalledId, elabComponentId = pkgInstalledId, elabLinkedInstantiatedWith = Map.empty, - elabInstallDirs = install_dirs, elabPkgOrComp = ElabPackage $ ElaboratedPackage {..}, elabModuleShape = modShape } + elab = elab1 { + elabInstallDirs = + computeInstallDirs storeDirLayout + defaultInstallDirs + elaboratedSharedConfig + elab1 + } modShape = case find (matchElabPkg (== (CLibName LMainLibName))) comps of Nothing -> emptyModuleShape @@ -1701,31 +1693,6 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB -- pkgStanzasEnabled is a superset of elabStanzasRequested pkgStanzasEnabled = Map.keysSet (Map.filter (id :: Bool -> Bool) elabStanzasRequested) - install_dirs - | shouldBuildInplaceOnly pkg - -- use the ordinary default install dirs - = (InstallDirs.absoluteInstallDirs - pkgid - (newSimpleUnitId pkgInstalledId) - (compilerInfo compiler) - InstallDirs.NoCopyDest - platform - defaultInstallDirs) { - - -- absoluteInstallDirs sets these as 'undefined' but we have to - -- use them as "Setup.hs configure" args - InstallDirs.libsubdir = "", - InstallDirs.libexecsubdir = "", - InstallDirs.datasubdir = "" - } - - | otherwise - -- use special simplified install dirs - = storePackageInstallDirs - storeDirLayout - (compilerId compiler) - pkgInstalledId - elaborateSolverToCommon :: SolverPackage UnresolvedPkgLoc -> ElaboratedConfiguredPackage elaborateSolverToCommon @@ -2152,8 +2119,8 @@ getComponentId (InstallPlan.PreExisting dipkg) = IPI.installedComponentId dipkg getComponentId (InstallPlan.Configured elab) = elabComponentId elab getComponentId (InstallPlan.Installed elab) = elabComponentId elab -instantiateInstallPlan :: ElaboratedInstallPlan -> ElaboratedInstallPlan -instantiateInstallPlan plan = +instantiateInstallPlan :: StoreDirLayout -> InstallDirs.InstallDirTemplates -> ElaboratedSharedConfig -> ElaboratedInstallPlan -> ElaboratedInstallPlan +instantiateInstallPlan storeDirLayout defaultInstallDirs elaboratedShared plan = InstallPlan.new (IndependentGoals False) (Graph.fromDistinctList (Map.elems ready_map)) where @@ -2181,12 +2148,12 @@ instantiateInstallPlan plan = instantiateComponent uid cid insts | Just planpkg <- Map.lookup cid cmap = case planpkg of - InstallPlan.Configured (elab@ElaboratedConfiguredPackage + InstallPlan.Configured (elab0@ElaboratedConfiguredPackage { elabPkgOrComp = ElabComponent comp }) -> do deps <- mapM (substUnitId insts) (compLinkedLibDependencies comp) let getDep (Module dep_uid _) = [dep_uid] - return $ InstallPlan.Configured elab { + elab1 = elab0 { elabUnitId = uid, elabComponentId = cid, elabInstantiatedWith = insts, @@ -2197,7 +2164,14 @@ instantiateInstallPlan plan = ordNub (map unDefUnitId (deps ++ concatMap getDep (Map.elems insts))) } - } + } + elab = elab1 { + elabInstallDirs = computeInstallDirs storeDirLayout + defaultInstallDirs + elaboratedShared + elab1 + } + return $ InstallPlan.Configured elab _ -> return planpkg | otherwise = error ("instantiateComponent: " ++ display cid) @@ -3255,6 +3229,38 @@ storePackageInstallDirs' StoreDirLayout{ storePackageDirectory sysconfdir = prefix "etc" + +computeInstallDirs :: StoreDirLayout + -> InstallDirs.InstallDirTemplates + -> ElaboratedSharedConfig + -> ElaboratedConfiguredPackage + -> InstallDirs.InstallDirs FilePath +computeInstallDirs storeDirLayout defaultInstallDirs elaboratedShared elab + | elabBuildStyle elab == BuildInplaceOnly + -- use the ordinary default install dirs + = (InstallDirs.absoluteInstallDirs + (elabPkgSourceId elab) + (elabUnitId elab) + (compilerInfo (pkgConfigCompiler elaboratedShared)) + InstallDirs.NoCopyDest + (pkgConfigPlatform elaboratedShared) + defaultInstallDirs) { + + -- absoluteInstallDirs sets these as 'undefined' but we have + -- to use them as "Setup.hs configure" args + InstallDirs.libsubdir = "", + InstallDirs.libexecsubdir = "", + InstallDirs.datasubdir = "" + } + + | otherwise + -- use special simplified install dirs + = storePackageInstallDirs' + storeDirLayout + (compilerId (pkgConfigCompiler elaboratedShared)) + (elabUnitId elab) + + --TODO: [code cleanup] perhaps reorder this code -- based on the ElaboratedInstallPlan + ElaboratedSharedConfig, -- make the various Setup.hs {configure,build,copy} flags diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/cabal-repo.out b/cabal-testsuite/PackageTests/Backpack/Includes3/cabal-repo.out new file mode 100644 index 00000000000..ac44d97fda6 --- /dev/null +++ b/cabal-testsuite/PackageTests/Backpack/Includes3/cabal-repo.out @@ -0,0 +1,29 @@ +# cabal v1-update +Downloading the latest package list from test-local-repo +# cabal v2-build +Resolving dependencies... +Build profile: -w ghc- -O1 +In order, the following will be built: + - sigs-0.1.0.0 (lib) (requires download & build) + - indef-0.1.0.0 (lib) (requires download & build) + - indef-0.1.0.0 (lib with Data.Map=containers-:Data.Map) (requires download & build) + - exe-0.1.0.0 (exe:exe) (first run) +Configuring library for sigs-0.1.0.0.. +Preprocessing library for sigs-0.1.0.0.. +Building library instantiated with Data.Map = +for sigs-0.1.0.0.. +Installing library in +Configuring library for indef-0.1.0.0.. +Preprocessing library for indef-0.1.0.0.. +Building library instantiated with Data.Map = +for indef-0.1.0.0.. +Installing library in +Configuring library instantiated with Data.Map = containers-:Data.Map +for indef-0.1.0.0.. +Preprocessing library for indef-0.1.0.0.. +Building library instantiated with Data.Map = containers-:Data.Map +for indef-0.1.0.0.. +Installing library in +Configuring executable 'exe' for exe-0.1.0.0.. +Preprocessing executable 'exe' for exe-0.1.0.0.. +Building executable 'exe' for exe-0.1.0.0.. diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/cabal-repo.test.hs b/cabal-testsuite/PackageTests/Backpack/Includes3/cabal-repo.test.hs new file mode 100644 index 00000000000..1ab71ff2f62 --- /dev/null +++ b/cabal-testsuite/PackageTests/Backpack/Includes3/cabal-repo.test.hs @@ -0,0 +1,6 @@ +import Test.Cabal.Prelude +main = withShorterPathForNewBuildStore $ \storeDir -> + cabalTest $ do + withProjectFile "cabal.repo.project" $ do + withRepo "repo" $ do + cabalG ["--store-dir=" ++ storeDir] "v2-build" ["exe"] diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/cabal.repo.project b/cabal-testsuite/PackageTests/Backpack/Includes3/cabal.repo.project new file mode 100644 index 00000000000..b1df7889fe7 --- /dev/null +++ b/cabal-testsuite/PackageTests/Backpack/Includes3/cabal.repo.project @@ -0,0 +1 @@ +packages: repo/exe-0.1.0.0 From c132666e496f3000f201735bb94bff81d88bef4d Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sun, 27 Oct 2019 23:20:03 -0400 Subject: [PATCH 3/4] Test fix Signed-off-by: Edward Z. Yang --- .../PackageTests/Backpack/Includes3/setup-internal.test.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/setup-internal.test.hs b/cabal-testsuite/PackageTests/Backpack/Includes3/setup-internal.test.hs index ef240fc426b..b75823a5b23 100644 --- a/cabal-testsuite/PackageTests/Backpack/Includes3/setup-internal.test.hs +++ b/cabal-testsuite/PackageTests/Backpack/Includes3/setup-internal.test.hs @@ -3,7 +3,7 @@ main = setupAndCabalTest $ do skipUnless =<< ghcVersionIs (>= mkVersion [8,1]) withPackageDb $ do setup_install [] - _ <- runM "touch" ["indef/Foo.hs"] + _ <- runM "touch" ["repo/indef-0.1.0.0/Foo.hs"] setup "build" [] runExe' "exe" [] >>= assertOutputContains "fromList [(0,2),(2,4)]" From ff7f5df2477fbd1356c6dc955ad8c6ab45cd966c Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Sat, 2 Nov 2019 11:01:53 +0100 Subject: [PATCH 4/4] Copy backpack version-guard from other backpack testcases --- .../PackageTests/Backpack/Includes3/cabal-repo.test.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cabal-testsuite/PackageTests/Backpack/Includes3/cabal-repo.test.hs b/cabal-testsuite/PackageTests/Backpack/Includes3/cabal-repo.test.hs index 1ab71ff2f62..713fcbc9020 100644 --- a/cabal-testsuite/PackageTests/Backpack/Includes3/cabal-repo.test.hs +++ b/cabal-testsuite/PackageTests/Backpack/Includes3/cabal-repo.test.hs @@ -1,6 +1,8 @@ import Test.Cabal.Prelude main = withShorterPathForNewBuildStore $ \storeDir -> cabalTest $ do + skipUnless =<< ghcVersionIs (>= mkVersion [8,1]) + skipIf =<< isWindows -- TODO: https://github.com/haskell/cabal/issues/6271 withProjectFile "cabal.repo.project" $ do withRepo "repo" $ do cabalG ["--store-dir=" ++ storeDir] "v2-build" ["exe"]