-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
54 lines (41 loc) · 2 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
44
45
46
47
48
49
50
51
52
53
54
PG_CONFIG ?= $(shell which pg_config)
PGRXV = $(shell perl -nE '/^pgrx\s+=\s"=?([^"]+)/ && do { say $$1; exit }' Cargo.toml)
PGV = $(shell perl -E 'shift =~ /(\d+)/ && say $$1' "$(shell $(PG_CONFIG) --version)")
DISTNAME = $(shell grep -m 1 '^name' Trunk.toml | sed -e 's/[^"]*"\([^"]*\)",\{0,1\}/\1/')
DISTVERSION = $(shell grep -m 1 '^version' Trunk.toml | sed -e 's/[^"]*"\([^"]*\)",\{0,1\}/\1/')
all: package
.DEFAULT_GOAL: package # Build for the PostgreSQL cluster identified by pg_config.
package:
@cargo pgrx package --pg-config "$(PG_CONFIG)"
.PHONY: install # Install jsonschema into the PostgreSQL cluster identified by pg_config.
install:
@cargo pgrx install --release --pg-config "$(PG_CONFIG)"
.PHONY: test # Run the full test suite against the PostgreSQL version identified by pg_config.
test:
@cargo test --all --no-default-features --features "pg$(PGV) pg_test" -- --nocapture
clean:
@rm -rf META.json $(DISTNAME)-$(DISTVERSION).zip
.PHONY: pg-version # Print the current PGRX version from Cargo.toml
pgrx-version:
@echo $(PGRXV)
.PHONY: pg-version # Print the current Postgres version reported by pg_config.
pg-version: Cargo.toml
@echo $(PGV)
.PHONY: install-pgrx # Install the version of PGRX specified in Cargo.toml.
install-pgrx: Cargo.toml
@cargo install --locked cargo-pgrx --version "$(PGRXV)"
.PHONY: pgrx-init # Initialize pgrx for the PostgreSQL version identified by pg_config.
pgrx-init: Cargo.toml
@cargo pgrx init "--pg$(PGV)"="$(PG_CONFIG)"
.PHONY: lint # Format and lint.
lint:
@cargo fmt --all --check
@cargo clippy --features "pg$(PGV)" --no-default-features
# Create the PGXN META.json file.
META.json: META.json.in Cargo.toml
@sed "s/@CARGO_VERSION@/$(DISTVERSION)/g" $< > $@
# Create a PGXN-compatible zip file.
$(DISTNAME)-$(DISTVERSION).zip: META.json
git archive --format zip --prefix $(DISTNAME)-$(DISTVERSION)/ --add-file $< -o $(DISTNAME)-$(DISTVERSION).zip HEAD
## pgxn-zip: Create a PGXN-compatible zip file.
pgxn-zip: $(DISTNAME)-$(DISTVERSION).zip