Skip to content

Commit 2586550

Browse files
committed
Makefile added
1 parent 790d2e1 commit 2586550

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

Makefile

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
PG_CONFIG ?= $(shell which pg_config)
2+
DISTNAME = $(shell perl -nE '/^name\s*=\s*"([^"]+)/ && do { say $$1; exit }' Cargo.toml)
3+
DISTVERSION = $(shell perl -nE '/^version\s*=\s*"([^"]+)/ && do { say $$1; exit }' Cargo.toml)
4+
PGRXV = $(shell perl -nE '/^pgrx\s+=\s"=?([^"]+)/ && do { say $$1; exit }' Cargo.toml)
5+
PGV = $(shell perl -E 'shift =~ /(\d+)/ && say $$1' "$(shell $(PG_CONFIG) --version)")
6+
EXTRA_CLEAN = META.json $(DISTNAME)-$(DISTVERSION).zip target
7+
TESTS = $(wildcard test/sql/*.sql)
8+
REGRESS = $(patsubst test/sql/%.sql,%,$(TESTS))
9+
REGRESS_OPTS = --inputdir=test --load-extension=$(DISTNAME) --outputdir=target/installcheck
10+
11+
PGXS := $(shell $(PG_CONFIG) --pgxs)
12+
include $(PGXS)
13+
14+
all: package
15+
16+
.DEFAULT_GOAL: package # Build jsonschema for the PostgreSQL cluster identified by pg_config.
17+
package:
18+
@cargo pgrx package --pg-config "$(PG_CONFIG)"
19+
20+
.PHONY: install # Install jsonschema into the PostgreSQL cluster identified by pg_config.
21+
install:
22+
@cargo pgrx install --release --pg-config "$(PG_CONFIG)"
23+
24+
.PHONY: test # Run the full test suite against the PostgreSQL version identified by pg_config.
25+
test:
26+
@cargo test --all --no-default-features --features "pg$(PGV) pg_test" -- --nocapture
27+
28+
.PHONY: cover # Run cover tests and generate & open a report.
29+
cover:
30+
@./.ci/test-cover "$(PGV)" "$(PGRXV)"
31+
32+
.PHONY: pg-version # Print the current PGRX version from Cargo.toml
33+
pgrx-version:
34+
@echo $(PGRXV)
35+
36+
.PHONY: pg-version # Print the current Postgres version reported by pg_config.
37+
pg-version: Cargo.toml
38+
@echo $(PGV)
39+
40+
.PHONY: install-pgrx # Install the version of PGRX specified in Cargo.toml.
41+
install-pgrx: Cargo.toml
42+
@cargo install --locked cargo-pgrx --version "$(PGRXV)"
43+
44+
.PHONY: pgrx-init # Initialize pgrx for the PostgreSQL version identified by pg_config.
45+
pgrx-init: Cargo.toml
46+
@cargo pgrx init "--pg$(PGV)"="$(PG_CONFIG)"
47+
48+
.PHONY: lint # Format and lint.
49+
lint:
50+
@cargo fmt --all --check
51+
@cargo clippy --features "pg$(PGV)" --no-default-features
52+
53+
# Create the PGXN META.json file.
54+
META.json: META.json.in Cargo.toml
55+
@sed "s/@CARGO_VERSION@/$(DISTVERSION)/g" $< > $@
56+
57+
# Expected test output regeneration
58+
target/installcheck/results/%.out: installcheck
59+
test/expected/%.out: target/installcheck/results/%.out
60+
@cp $^ $@
61+
62+
# Create a PGXN-compatible zip file.
63+
$(DISTNAME)-$(DISTVERSION).zip: META.json
64+
git archive --format zip --prefix $(DISTNAME)-$(DISTVERSION)/ --add-file $< -o $(DISTNAME)-$(DISTVERSION).zip HEAD
65+
66+
## pgxn-zip: Create a PGXN-compatible zip file.
67+
pgxn-zip: $(DISTNAME)-$(DISTVERSION).zip
68+
69+
target/release-notes.md: CHANGELOG.md .ci/mknotes
70+
@./.ci/mknotes -v $(DISTVERSION) -f $< -r https://github.com/$(or $(GITHUB_REPOSITORY),tembo-io/pg-jsonschema-boon) -o $@
71+
72+
## vendor: Vendor all crates.io and git dependencies.
73+
vendor:
74+
@cargo vendor

0 commit comments

Comments
 (0)