-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
75 lines (58 loc) · 2.8 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
PG_CONFIG ?= $(shell which pg_config)
DISTNAME = $(shell perl -nE '/^name\s*=\s*"([^"]+)/ && do { say $$1; exit }' Cargo.toml)
DISTVERSION = $(shell perl -nE '/^version\s*=\s*"([^"]+)/ && do { say $$1; exit }' Cargo.toml)
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)")
EXTRA_CLEAN = META.json $(DISTNAME)-$(DISTVERSION).zip target
TESTS = $(wildcard test/sql/*.sql)
REGRESS = $(patsubst test/sql/%.sql,%,$(TESTS))
REGRESS_OPTS = --inputdir=test --load-extension=$(DISTNAME) --outputdir=target/installcheck
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
all: package
.DEFAULT_GOAL: package # Build jsonschema 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
.PHONY: cover # Run cover tests and generate & open a report.
cover:
@./.ci/test-cover "$(PGV)" "$(PGRXV)"
.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" $< > $@
# Expected test output regeneration
target/installcheck/results/%.out: installcheck
test/expected/%.out: target/installcheck/results/%.out
@cp $^ $@
# 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
.PHONY: release-notes # Show release notes for current version (must have `mknotes` in PATH).
release-notes: CHANGELOG.md
mknotes -v v$(DISTVERSION) -f $< -r https://github.com/$(or $(GITHUB_REPOSITORY),tembo-io/pg-jsonschema-boon)
## vendor: Vendor all crates.io and git dependencies.
vendor:
@cargo vendor