Skip to content

Commit c17d3fe

Browse files
angermanandreabedini
authored andcommitted
feat: allow build-type Configure to work with Components
When components were introduced, cabal had support for build-type: Configure, which allows to run a `configure` script prior to building the package. Upon the introduction of components, it became obvious that we can't just configure each and every component, as this easily runs into the situation where the `configure` script is run potentially concurrently for all components. However, build-type is a global option for cabal files, and is usually used to produce a <pkg>.buildinfo file. This file is then used to augment the Main Library and Executables only. This change now tracks whether or not we are building a main library or executable component, and if we do, retains only for these components the build-type: Configure from the package description. For all other components, we will fall back to the default build-type: Simple. For end users who want to depend on package configured values, they will need to set their sub libraries, testsuites and benchmark components to depend on the main library, and import any configured values from there. For lib:Cabal, which doesn't know about components when configure is invoked, we will continue to execute configure. There is no impact on lib:Cabal in this change.
1 parent 698837a commit c17d3fe

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

cabal-install/src/Distribution/Client/ProjectPlanning.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,10 +1729,11 @@ elaborateInstallPlan
17291729
why_not_per_component g =
17301730
cuz_buildtype ++ cuz_spec ++ cuz_length ++ cuz_flag
17311731
where
1732-
-- Custom and Hooks are not implemented. Implementing
1733-
-- per-component builds with Custom would require us to create a
1734-
-- new 'ElabSetup' type, and teach all of the code paths how to
1735-
-- handle it.
1732+
-- We have to disable per-component at this point in time, only
1733+
-- Simple and Configure build types are supported. Custom and
1734+
-- Hooks are not implemented. Implementing per-component builds
1735+
-- with Custom would require us to create a new 'ElabSetup'
1736+
-- type, and teach all of the code paths how to handle it.
17361737
-- Once you've implemented this, swap it for the code below.
17371738
cuz_buildtype =
17381739
case bt of

changelog.d/pr-10966.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
synopsis: Allow build-type: Configure
2+
packages: cabal-install
3+
prs: #10966
4+
issues: #4548
5+
significance: significant
6+
7+
description: {
8+
9+
This change allows the `build-type: Configure` field to be used in
10+
Cabal packages in conjunction with components. (E.g. public sublibraries).
11+
This is a significant change as it enables the use of the `Configure` build
12+
type, which cabal bailed on previously.
13+
14+
This does change the behaviour of cabal-install for packages that contain
15+
`build-type: Configure`. We now always build them as components with
16+
cabal-install. Previously we would turn packages with main libraries, and
17+
executables/benchmarks/tests-suites into a single package to be built in a
18+
compatibility mode. This is no longer the case.
19+
20+
}

0 commit comments

Comments
 (0)