Skip to content

Commit

Permalink
Use build-type: Simple when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
phadej committed Jul 10, 2024
1 parent e57f62d commit 43f7b1b
Show file tree
Hide file tree
Showing 16 changed files with 244 additions and 34 deletions.
31 changes: 28 additions & 3 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This GitHub workflow config has been generated by a script via
#
# haskell-ci 'github' 'postgresql-libpq.cabal'
# haskell-ci 'github' 'cabal.project'
#
# To regenerate the script (for example after adjusting tested-with) run
#
Expand All @@ -10,7 +10,7 @@
#
# version: 0.19.20240708
#
# REGENDATA ("0.19.20240708",["github","postgresql-libpq.cabal"])
# REGENDATA ("0.19.20240708",["github","cabal.project"])
#
name: Haskell-CI
on:
Expand Down Expand Up @@ -175,6 +175,8 @@ jobs:
run: |
touch cabal.project
echo "packages: $GITHUB_WORKSPACE/source/." >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/postgresql-libpq-pkgconfig" >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/postgresql-libpq-pgconfig" >> cabal.project
cat cabal.project
- name: sdist
run: |
Expand All @@ -188,15 +190,25 @@ jobs:
run: |
PKGDIR_postgresql_libpq="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/postgresql-libpq-[0-9.]*')"
echo "PKGDIR_postgresql_libpq=${PKGDIR_postgresql_libpq}" >> "$GITHUB_ENV"
PKGDIR_postgresql_libpq_pkgconfig="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/postgresql-libpq-pkgconfig-[0-9.]*')"
echo "PKGDIR_postgresql_libpq_pkgconfig=${PKGDIR_postgresql_libpq_pkgconfig}" >> "$GITHUB_ENV"
PKGDIR_postgresql_libpq_pgconfig="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/postgresql-libpq-pgconfig-[0-9.]*')"
echo "PKGDIR_postgresql_libpq_pgconfig=${PKGDIR_postgresql_libpq_pgconfig}" >> "$GITHUB_ENV"
rm -f cabal.project cabal.project.local
touch cabal.project
touch cabal.project.local
echo "packages: ${PKGDIR_postgresql_libpq}" >> cabal.project
echo "packages: ${PKGDIR_postgresql_libpq_pkgconfig}" >> cabal.project
echo "packages: ${PKGDIR_postgresql_libpq_pgconfig}" >> cabal.project
echo "package postgresql-libpq" >> cabal.project
echo " ghc-options: -Werror=missing-methods" >> cabal.project
echo "package postgresql-libpq-pkgconfig" >> cabal.project
echo " ghc-options: -Werror=missing-methods" >> cabal.project
echo "package postgresql-libpq-pgconfig" >> cabal.project
echo " ghc-options: -Werror=missing-methods" >> cabal.project
cat >> cabal.project <<EOF
EOF
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(postgresql-libpq)$/; }' >> cabal.project.local
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(postgresql-libpq|postgresql-libpq-pgconfig|postgresql-libpq-pkgconfig)$/; }' >> cabal.project.local
cat cabal.project
cat cabal.project.local
- name: dump install plan
Expand Down Expand Up @@ -226,13 +238,26 @@ jobs:
run: |
cd ${PKGDIR_postgresql_libpq} || false
${CABAL} -vnormal check
cd ${PKGDIR_postgresql_libpq_pkgconfig} || false
${CABAL} -vnormal check
cd ${PKGDIR_postgresql_libpq_pgconfig} || false
${CABAL} -vnormal check
- name: haddock
run: |
$CABAL v2-haddock --disable-documentation $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all
- name: unconstrained build
run: |
rm -f cabal.project.local
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
- name: prepare for constraint sets
run: |
rm -f cabal.project.local
- name: constraint set no-pkg-config
run: |
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='postgresql-libpq -use-pkg-config' all --dry-run
cabal-plan topo | sort
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='postgresql-libpq -use-pkg-config' --dependencies-only -j2 all
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='postgresql-libpq -use-pkg-config' all
- name: save cache
uses: actions/cache/save@v4
if: always()
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ jobs:
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ github.sha }}
restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-

- name: cabal.project.local
- name: cabal.project (win)
if: matrix.os == 'windows-latest'
run: cp cabal.project.local.win cabal.project.local
run: cp cabal.project.win cabal.project

- name: cabal.project (macos)
if: matrix.os == 'macos-latest'
run: cp cabal.project.macos cabal.project

- name: ghc-pkg dump
run: ghc-pkg list
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
0.10.2.0
--------

- Change `use-pkg-config` default to `True`.
Windows and macOS users may need to disable the flag if their
libpq installation doesn't provide pkg-config database entry.
- Split the c library dependency into separate
packages, so in `pkg-config` scenario, all packages
are `build-type: Simple`.

0.10.1.0
--------

Expand Down
3 changes: 3 additions & 0 deletions cabal.haskell-ci
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ postgresql: True
-- due build-type: Custom
test-output-direct: False
haddock-components: libs

constraint-set no-pkg-config
constraints: postgresql-libpq -use-pkg-config
2 changes: 2 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
packages: .
packages: postgresql-libpq-pkgconfig
packages: postgresql-libpq-pgconfig
4 changes: 0 additions & 4 deletions cabal.project.local.win

This file was deleted.

7 changes: 7 additions & 0 deletions cabal.project.macos
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
packages: .
packages: postgresql-libpq-pgconfig

constraints: unix installed

package postgresql-libpq
flags: -use-pkg-config
7 changes: 7 additions & 0 deletions cabal.project.win
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
packages: .
packages: postgresql-libpq-pgconfig

constraints: Win32 installed

package postgresql-libpq
flags: -use-pkg-config
4 changes: 4 additions & 0 deletions postgresql-libpq-pgconfig/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0.10
----

* Initial release0.10
31 changes: 31 additions & 0 deletions postgresql-libpq-pgconfig/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Copyright (c) 2010, Grant Monroe
Copyright (c) 2011, Leon P Smith

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

* Neither the name of the authors nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
File renamed without changes.
63 changes: 63 additions & 0 deletions postgresql-libpq-pgconfig/postgresql-libpq-pgconfig.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
cabal-version: 2.4
name: postgresql-libpq-pgconfig
version: 0.10
synopsis: low-level binding to libpq: pg_config based provider
description:
This is a binding to libpq: the C application
programmer's interface to PostgreSQL. libpq is a
set of library functions that allow client
programs to pass queries to the PostgreSQL
backend server and to receive the results of
these queries.

homepage: https://github.com/haskellari/postgresql-libpq
bug-reports: https://github.com/haskellari/postgresql-libpq/issues
license: BSD-3-Clause
license-file: LICENSE
author: Grant Monroe, Leon P Smith, Joey Adams
maintainer: Oleg Grenrus <[email protected]>
copyright: (c) 2024 Oleg Grenrus
category: Database
build-type: Custom
tested-with:
GHC ==8.6.5
|| ==8.8.4
|| ==8.10.7
|| ==9.0.2
|| ==9.2.8
|| ==9.4.8
|| ==9.6.5
|| ==9.8.2
|| ==9.10.1

extra-source-files: CHANGELOG.md

custom-setup
setup-depends:
, base >=4.12.0.0 && <5
, Cabal >=2.4 && <3.13

library
default-language: Haskell2010
build-depends: base <5

if os(windows)
-- Due to https://sourceware.org/bugzilla/show_bug.cgi?id=22948,
-- if we specify pq instead of libpq, then ld might link against
-- libpq.dll directly, which can lead to segfaults. As a temporary hack,
-- we force ld to link against the libpq.lib import library directly
-- by specifying libpq here.
extra-libraries: libpq

else
extra-libraries: pq

if os(openbsd)
extra-libraries:
crypto
ssl

source-repository head
type: git
location: https://github.com/haskellari/postgresql-libpq
subdir: postgresql-libpq-pgconfig
4 changes: 4 additions & 0 deletions postgresql-libpq-pkgconfig/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0.10
----

* Initial release0.10
31 changes: 31 additions & 0 deletions postgresql-libpq-pkgconfig/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Copyright (c) 2010, Grant Monroe
Copyright (c) 2011, Leon P Smith

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

* Neither the name of the authors nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 changes: 43 additions & 0 deletions postgresql-libpq-pkgconfig/postgresql-libpq-pkgconfig.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
cabal-version: 2.4
name: postgresql-libpq-pkgconfig
version: 0.10
synopsis: low-level binding to libpq: pkg-config based provider
description:
This is a binding to libpq: the C application
programmer's interface to PostgreSQL. libpq is a
set of library functions that allow client
programs to pass queries to the PostgreSQL
backend server and to receive the results of
these queries.

homepage: https://github.com/haskellari/postgresql-libpq
bug-reports: https://github.com/haskellari/postgresql-libpq/issues
license: BSD-3-Clause
license-file: LICENSE
author: Grant Monroe, Leon P Smith, Joey Adams
maintainer: Oleg Grenrus <[email protected]>
copyright: (c) 2024 Oleg Grenrus
category: Database
build-type: Simple
tested-with:
GHC ==8.6.5
|| ==8.8.4
|| ==8.10.7
|| ==9.0.2
|| ==9.2.8
|| ==9.4.8
|| ==9.6.5
|| ==9.8.2
|| ==9.10.1

extra-source-files: CHANGELOG.md

library
default-language: Haskell2010
build-depends: base <5
pkgconfig-depends: libpq >=10.22

source-repository head
type: git
location: https://github.com/haskellari/postgresql-libpq
subdir: postgresql-libpq-pkgconfig
30 changes: 5 additions & 25 deletions postgresql-libpq.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
cabal-version: 2.4
name: postgresql-libpq
version: 0.10.1.0
x-revision: 1
version: 0.10.2.0
synopsis: low-level binding to libpq
description:
This is a binding to libpq: the C application
Expand All @@ -22,7 +21,7 @@ copyright:
(c) 2011 Leon P Smith

category: Database
build-type: Custom
build-type: Simple
extra-source-files: cbits/hs-libpq.h
tested-with:
GHC ==8.6.5
Expand All @@ -37,15 +36,10 @@ tested-with:

extra-source-files: CHANGELOG.md

custom-setup
setup-depends:
, base >=4.12.0.0 && <5
, Cabal >=2.4 && <3.13

-- If true, use pkg-config, otherwise use the pg_config based build
-- configuration
flag use-pkg-config
default: False
default: True
manual: True

library
Expand Down Expand Up @@ -87,24 +81,10 @@ library
build-depends: Win32 >=2.2.0.2 && <2.15

if flag(use-pkg-config)
pkgconfig-depends: libpq >=10.22
build-depends: postgresql-libpq-pkgconfig ^>=0.10

else
if os(windows)
-- Due to https://sourceware.org/bugzilla/show_bug.cgi?id=22948,
-- if we specify pq instead of libpq, then ld might link against
-- libpq.dll directly, which can lead to segfaults. As a temporary hack,
-- we force ld to link against the libpq.lib import library directly
-- by specifying libpq here.
extra-libraries: libpq

else
extra-libraries: pq

if os(openbsd)
extra-libraries:
crypto
ssl
build-depends: postgresql-libpq-pgconfig ^>=0.10

build-tool-depends: hsc2hs:hsc2hs >=0.68.5

Expand Down

0 comments on commit 43f7b1b

Please sign in to comment.