Skip to content

Commit e76c7e1

Browse files
committed
Use build-type: Simple when possible
Split C-library linkage into auxiliary libraries, so we can have one `build-type: Simple` (`-f +use-pkg-config`), and `build-type: Configure` (`-f -use-pkg-config`).
1 parent e57f62d commit e76c7e1

23 files changed

+5945
-88
lines changed

.github/workflows/haskell-ci.yml

+28-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This GitHub workflow config has been generated by a script via
22
#
3-
# haskell-ci 'github' 'postgresql-libpq.cabal'
3+
# haskell-ci 'github' 'cabal.project'
44
#
55
# To regenerate the script (for example after adjusting tested-with) run
66
#
@@ -10,7 +10,7 @@
1010
#
1111
# version: 0.19.20240708
1212
#
13-
# REGENDATA ("0.19.20240708",["github","postgresql-libpq.cabal"])
13+
# REGENDATA ("0.19.20240708",["github","cabal.project"])
1414
#
1515
name: Haskell-CI
1616
on:
@@ -175,6 +175,8 @@ jobs:
175175
run: |
176176
touch cabal.project
177177
echo "packages: $GITHUB_WORKSPACE/source/." >> cabal.project
178+
echo "packages: $GITHUB_WORKSPACE/source/postgresql-libpq-pkgconfig" >> cabal.project
179+
echo "packages: $GITHUB_WORKSPACE/source/postgresql-libpq-configure" >> cabal.project
178180
cat cabal.project
179181
- name: sdist
180182
run: |
@@ -188,15 +190,25 @@ jobs:
188190
run: |
189191
PKGDIR_postgresql_libpq="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/postgresql-libpq-[0-9.]*')"
190192
echo "PKGDIR_postgresql_libpq=${PKGDIR_postgresql_libpq}" >> "$GITHUB_ENV"
193+
PKGDIR_postgresql_libpq_pkgconfig="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/postgresql-libpq-pkgconfig-[0-9.]*')"
194+
echo "PKGDIR_postgresql_libpq_pkgconfig=${PKGDIR_postgresql_libpq_pkgconfig}" >> "$GITHUB_ENV"
195+
PKGDIR_postgresql_libpq_configure="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/postgresql-libpq-configure-[0-9.]*')"
196+
echo "PKGDIR_postgresql_libpq_configure=${PKGDIR_postgresql_libpq_configure}" >> "$GITHUB_ENV"
191197
rm -f cabal.project cabal.project.local
192198
touch cabal.project
193199
touch cabal.project.local
194200
echo "packages: ${PKGDIR_postgresql_libpq}" >> cabal.project
201+
echo "packages: ${PKGDIR_postgresql_libpq_pkgconfig}" >> cabal.project
202+
echo "packages: ${PKGDIR_postgresql_libpq_configure}" >> cabal.project
195203
echo "package postgresql-libpq" >> cabal.project
196204
echo " ghc-options: -Werror=missing-methods" >> cabal.project
205+
echo "package postgresql-libpq-pkgconfig" >> cabal.project
206+
echo " ghc-options: -Werror=missing-methods" >> cabal.project
207+
echo "package postgresql-libpq-configure" >> cabal.project
208+
echo " ghc-options: -Werror=missing-methods" >> cabal.project
197209
cat >> cabal.project <<EOF
198210
EOF
199-
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(postgresql-libpq)$/; }' >> cabal.project.local
211+
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(postgresql-libpq|postgresql-libpq-configure|postgresql-libpq-pkgconfig)$/; }' >> cabal.project.local
200212
cat cabal.project
201213
cat cabal.project.local
202214
- name: dump install plan
@@ -226,13 +238,26 @@ jobs:
226238
run: |
227239
cd ${PKGDIR_postgresql_libpq} || false
228240
${CABAL} -vnormal check
241+
cd ${PKGDIR_postgresql_libpq_pkgconfig} || false
242+
${CABAL} -vnormal check
243+
cd ${PKGDIR_postgresql_libpq_configure} || false
244+
${CABAL} -vnormal check
229245
- name: haddock
230246
run: |
231247
$CABAL v2-haddock --disable-documentation $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all
232248
- name: unconstrained build
233249
run: |
234250
rm -f cabal.project.local
235251
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
252+
- name: prepare for constraint sets
253+
run: |
254+
rm -f cabal.project.local
255+
- name: constraint set pkg-config
256+
run: |
257+
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='postgresql-libpq +use-pkg-config' all --dry-run
258+
cabal-plan topo | sort
259+
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='postgresql-libpq +use-pkg-config' --dependencies-only -j2 all
260+
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='postgresql-libpq +use-pkg-config' all
236261
- name: save cache
237262
uses: actions/cache/save@v4
238263
if: always()

.github/workflows/simple.yml

+9-2
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,20 @@ jobs:
5050
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ github.sha }}
5151
restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-
5252

53-
- name: cabal.project.local
53+
- name: cabal.project (win)
5454
if: matrix.os == 'windows-latest'
55-
run: cp cabal.project.local.win cabal.project.local
55+
run: cp cabal.project.win cabal.project
56+
57+
- name: cabal.project (macos)
58+
if: matrix.os == 'macos-latest'
59+
run: cp cabal.project.macos cabal.project
5660

5761
- name: ghc-pkg dump
5862
run: ghc-pkg list
5963

64+
- name: Dependencies
65+
run: cabal build all --enable-tests --only-dependencies
66+
6067
- name: Build
6168
run: cabal build all --enable-tests
6269

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
0.10.2.0
2+
--------
3+
4+
- Split the c library dependency into separate packages.
5+
Now the dependencies are either all `build-type: Simple` (`-f +use-pkg-config`)
6+
or `build-type: Configure` (`-f -use-pkg-config`).
7+
18
0.10.1.0
29
--------
310

Setup.hs

-55
This file was deleted.

cabal.haskell-ci

+3
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ postgresql: True
44
-- due build-type: Custom
55
test-output-direct: False
66
haddock-components: libs
7+
8+
constraint-set pkg-config
9+
constraints: postgresql-libpq +use-pkg-config

cabal.project

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
packages: .
2+
packages: postgresql-libpq-pkgconfig
3+
packages: postgresql-libpq-configure

cabal.project.local.win

-4
This file was deleted.

cabal.project.macos

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
packages: .
2+
packages: postgresql-libpq-configure
3+
4+
constraints: unix installed
5+
6+
package postgresql-libpq
7+
flags: -use-pkg-config

cabal.project.win

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
packages: .
2+
packages: postgresql-libpq-configure
3+
4+
constraints: Win32 installed
5+
6+
package postgresql-libpq
7+
flags: -use-pkg-config

postgresql-libpq-configure/.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
postgresql-libpq-configure.buildinfo
2+
config.log
3+
config.status
4+
aclocal.m4
5+
autom4te.cache/
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
0.10
2+
----
3+
4+
* Initial release0.10

postgresql-libpq-configure/LICENSE

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Copyright (c) 2010, Grant Monroe
2+
Copyright (c) 2011, Leon P Smith
3+
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright
10+
notice, this list of conditions and the following disclaimer.
11+
12+
* Redistributions in binary form must reproduce the above
13+
copyright notice, this list of conditions and the following
14+
disclaimer in the documentation and/or other materials provided
15+
with the distribution.
16+
17+
* Neither the name of the authors nor the names of other
18+
contributors may be used to endorse or promote products derived
19+
from this software without specific prior written permission.
20+
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

postgresql-libpq-configure/Setup.hs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Main (main) where
2+
3+
import Distribution.Simple (defaultMainWithHooks, autoconfUserHooks)
4+
5+
main :: IO ()
6+
main = defaultMainWithHooks autoconfUserHooks

0 commit comments

Comments
 (0)