Skip to content

Commit 11b1108

Browse files
committed
chore: add meson support to build extension
Since meson is the PostgreSQL standard now to build, we add support for meson and make it the tool required to build. Closes #8 Signed-off-by: Jonathan Gonzalez V. <[email protected]>
1 parent 0c78b5f commit 11b1108

File tree

4 files changed

+42
-15
lines changed

4 files changed

+42
-15
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,17 @@ The validator will request permission `<resource_name>#<scope>` (e.g., `appdb#ap
116116

117117
## Build Instructions
118118

119+
### Local
120+
121+
To compile the extension is required [meson](https://mesonbuild.com/) tool.
122+
123+
```bash
124+
meson setup build
125+
meson compile -C build
126+
```
127+
The extension will be located inside the `build/` directory, that was
128+
created during the setup process.
129+
119130
### Docker
120131

121132
```bash

docker/Dockerfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
55
set -eux; \
66
apt-get update; \
77
apt-get install -y --no-install-recommends \
8-
build-essential libcurl4-openssl-dev postgresql-server-dev-18; \
9-
apt-get clean; \
10-
rm -rf /var/lib/apt/lists/*
8+
build-essential \
9+
meson \
10+
libcurl4-openssl-dev \
11+
postgresql-server-dev-18; \
1112
WORKDIR /work
12-
COPY src/ ./src/
13-
RUN make -C src
13+
COPY . .
14+
RUN meson setup build && meson build -C build/
1415

1516
FROM ghcr.io/cloudnative-pg/postgresql:18-standard-trixie
1617
ARG DEBIAN_FRONTEND=noninteractive
@@ -25,4 +26,4 @@ COPY --chmod=0644 docker/certs/server.crt /usr/local/share/ca-certificates/kc-ro
2526
RUN update-ca-certificates
2627
ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
2728
USER postgres
28-
COPY --from=builder /work/src/kc_validator.so /usr/lib/postgresql/18/lib/
29+
COPY --from=builder /work/build/kc_validator.so /usr/lib/postgresql/18/lib/

meson.build

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
project(
2+
'postgres-keycloak-oauth-validator', 'c',
3+
license: 'Apache-2.0',
4+
license_files: 'LICENSE',
5+
version: '0.0.1')
6+
7+
# pg_config command is required to get the include directory for
8+
# the headers
9+
pg_config = find_program('pg_config')
10+
includedir_server = run_command(pg_config, '--includedir-server', check: true).stdout().strip()
11+
12+
# PostgreSQL required for standard build (this may not be needed)
13+
postgres = dependency('libpq')
14+
# libcurl is required for the oauth calls
15+
libcurl = dependency('libcurl')
16+
17+
# The library is built as a shared object since it's going to be
18+
# loaded into PostgreSQL later as an extension.
19+
# Setting the prefix to '' helps to not habe a `lib` prefix on the
20+
# final file created
21+
shared_module('kc_validator', 'src/kc_validator.c',
22+
dependencies: [postgres, libcurl],
23+
include_directories: [includedir_server],
24+
name_prefix: '')

src/Makefile

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)