-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
43 lines (32 loc) · 1.47 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
DISTNAME = $(shell grep -m 1 '^name' Trunk.toml | sed -e 's/[^"]*"\([^"]*\)",\{0,1\}/\1/')
DISTVERSION = $(shell grep -m 1 '^version' Cargo.toml | sed -e 's/[^"]*"\([^"]*\)",\{0,1\}/\1/')
PG_VERSION:=17
PGRX_PG_CONFIG =$(shell cargo pgrx info pg-config pg${PG_VERSION})
PGLATER_SOCKET_URL:='postgresql:///postgres?host=${HOME}/.pgrx&user=${USER}&dbname=postgres&port=288${PG_VERSION}'
DATABASE_URL:=postgres://${USER}:${USER}@localhost:288${PG_VERSION}/postgres
.PHONY: format run setup
format:
cargo fmt --all
cargo clippy
# run in pgrx locally
run:
SQLX_OFFLINE=true PGLATER_SOCKET_URL=${PGLATER_SOCKET_URL} cargo pgrx run pg${PG_VERSION} postgres
META.json: META.json.in Trunk.toml
@sed "s/@CARGO_VERSION@/$(DISTVERSION)/g" $< > $@
$(DISTNAME)-$(DISTVERSION).zip: META.json
git archive --format zip --prefix $(DISTNAME)-$(DISTVERSION)/ --add-file $< -o $(DISTNAME)-$(DISTVERSION).zip HEAD
pgxn-zip: $(DISTNAME)-$(DISTVERSION).zip
clean:
@rm -rf META.json $(DISTNAME)-$(DISTVERSION).zip
install-pgmq:
git clone https://github.com/tembo-io/pgmq.git && \
cd pgmq/pgmq-extension && \
PG_CONFIG=${PGRX_PG_CONFIG} make clean && \
PG_CONFIG=${PGRX_PG_CONFIG} make && \
PG_CONFIG=${PGRX_PG_CONFIG} make install && \
cd ../.. && rm -rf pgmq
setup.shared_preload_libraries:
echo "shared_preload_libraries = 'pg_later'" >> ~/.pgrx/data-${PG_VERSION}/postgresql.conf
setup: install-pgmq setup.shared_preload_libraries
test:
SQLX_OFFLINE=true DATABASE_URL=${DATABASE_URL} cargo pgrx test