Skip to content

Commit b1f9dcf

Browse files
committed
Fiddle with the buildable field correctly
Looks like I totally outsmarted myself here working on the Cabal 2.0 migration. Please see the newly added comment in this commit.
1 parent 66a9b1e commit b1f9dcf

File tree

1 file changed

+26
-29
lines changed

1 file changed

+26
-29
lines changed

src/Stack/Package.hs

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -799,41 +799,38 @@ resolvePackageDescription packageConfig (GenericPackageDescription desc defaultF
799799
(packageConfigPlatform packageConfig)
800800
flags
801801

802-
-- Due to https://github.com/haskell/cabal/issues/1725,
803-
-- versions of Cabal before 2.0 would always require that the
804-
-- dependencies for all libraries and executables be present,
805-
-- even if they were not buildable. To ensure that Stack is
806-
-- compatible with those older Cabal libraries (which may be
807-
-- in use depending on the snapshot chosen), we set buildable
808-
-- to True for libraries and executables.
809802
updateLibDeps lib deps =
810803
lib {libBuildInfo =
811-
(libBuildInfo lib)
812-
{ targetBuildDepends = deps
813-
, buildable = True
814-
}
815-
}
804+
(libBuildInfo lib) {targetBuildDepends = deps}}
816805
updateExeDeps exe deps =
817806
exe {buildInfo =
818-
(buildInfo exe)
819-
{ targetBuildDepends = deps
820-
, buildable = True
821-
}
822-
}
807+
(buildInfo exe) {targetBuildDepends = deps}}
808+
809+
-- Note that, prior to moving to Cabal 2.0, we would set
810+
-- testEnabled/benchmarkEnabled here. These fields no longer
811+
-- exist, so we modify buildable instead here. The only
812+
-- wrinkle in the Cabal 2.0 story is
813+
-- https://github.com/haskell/cabal/issues/1725, where older
814+
-- versions of Cabal (which may be used for actually building
815+
-- code) don't properly exclude build-depends for
816+
-- non-buildable components. Testing indicates that everything
817+
-- is working fine, and that this comment can be completely
818+
-- ignored. I'm leaving the comment anyway in case something
819+
-- breaks and you, poor reader, are investigating.
823820
updateTestDeps test deps =
824-
test {testBuildInfo =
825-
(testBuildInfo test)
826-
{ targetBuildDepends = deps
827-
, buildable = packageConfigEnableTests packageConfig
828-
}
829-
}
821+
let bi = testBuildInfo test
822+
bi' = bi
823+
{ targetBuildDepends = deps
824+
, buildable = buildable bi && packageConfigEnableTests packageConfig
825+
}
826+
in test { testBuildInfo = bi' }
830827
updateBenchmarkDeps benchmark deps =
831-
benchmark {benchmarkBuildInfo =
832-
(benchmarkBuildInfo benchmark)
833-
{ targetBuildDepends = deps
834-
, buildable = packageConfigEnableBenchmarks packageConfig
835-
}
836-
}
828+
let bi = benchmarkBuildInfo benchmark
829+
bi' = bi
830+
{ targetBuildDepends = deps
831+
, buildable = buildable bi && packageConfigEnableBenchmarks packageConfig
832+
}
833+
in benchmark { benchmarkBuildInfo = bi' }
837834

838835
-- | Make a map from a list of flag specifications.
839836
--

0 commit comments

Comments
 (0)