Skip to content

Commit

Permalink
Fiddle with the buildable field correctly
Browse files Browse the repository at this point in the history
Looks like I totally outsmarted myself here working on the Cabal 2.0
migration. Please see the newly added comment in this commit.
  • Loading branch information
snoyberg committed Aug 17, 2017
1 parent 66a9b1e commit b1f9dcf
Showing 1 changed file with 26 additions and 29 deletions.
55 changes: 26 additions & 29 deletions src/Stack/Package.hs
Original file line number Diff line number Diff line change
Expand Up @@ -799,41 +799,38 @@ resolvePackageDescription packageConfig (GenericPackageDescription desc defaultF
(packageConfigPlatform packageConfig)
flags

-- Due to https://github.com/haskell/cabal/issues/1725,
-- versions of Cabal before 2.0 would always require that the
-- dependencies for all libraries and executables be present,
-- even if they were not buildable. To ensure that Stack is
-- compatible with those older Cabal libraries (which may be
-- in use depending on the snapshot chosen), we set buildable
-- to True for libraries and executables.
updateLibDeps lib deps =
lib {libBuildInfo =
(libBuildInfo lib)
{ targetBuildDepends = deps
, buildable = True
}
}
(libBuildInfo lib) {targetBuildDepends = deps}}
updateExeDeps exe deps =
exe {buildInfo =
(buildInfo exe)
{ targetBuildDepends = deps
, buildable = True
}
}
(buildInfo exe) {targetBuildDepends = deps}}

-- Note that, prior to moving to Cabal 2.0, we would set
-- testEnabled/benchmarkEnabled here. These fields no longer
-- exist, so we modify buildable instead here. The only
-- wrinkle in the Cabal 2.0 story is
-- https://github.com/haskell/cabal/issues/1725, where older
-- versions of Cabal (which may be used for actually building
-- code) don't properly exclude build-depends for
-- non-buildable components. Testing indicates that everything
-- is working fine, and that this comment can be completely
-- ignored. I'm leaving the comment anyway in case something
-- breaks and you, poor reader, are investigating.
updateTestDeps test deps =
test {testBuildInfo =
(testBuildInfo test)
{ targetBuildDepends = deps
, buildable = packageConfigEnableTests packageConfig
}
}
let bi = testBuildInfo test
bi' = bi
{ targetBuildDepends = deps
, buildable = buildable bi && packageConfigEnableTests packageConfig
}
in test { testBuildInfo = bi' }
updateBenchmarkDeps benchmark deps =
benchmark {benchmarkBuildInfo =
(benchmarkBuildInfo benchmark)
{ targetBuildDepends = deps
, buildable = packageConfigEnableBenchmarks packageConfig
}
}
let bi = benchmarkBuildInfo benchmark
bi' = bi
{ targetBuildDepends = deps
, buildable = buildable bi && packageConfigEnableBenchmarks packageConfig
}
in benchmark { benchmarkBuildInfo = bi' }

-- | Make a map from a list of flag specifications.
--
Expand Down

0 comments on commit b1f9dcf

Please sign in to comment.