refacto: add build and cleanup file structure

This commit is contained in:
2026-02-20 01:32:08 +01:00
parent 6adc62f9ec
commit d80b9f387b
31 changed files with 2234 additions and 2235 deletions
+20 -11
View File
@@ -6,7 +6,8 @@ EXTENSION = morbac_pg
# Read version from control file
EXTVERSION = $(shell grep default_version $(EXTENSION).control | sed "s/default_version = '\(.*\)'/\1/")
# For development, work on unversioned file
# For development, work on source files in src/
SRC_DIR = src
DEV_SQL = $(EXTENSION).sql
DATA = $(EXTENSION)--$(EXTVERSION).sql
DOCS = README.md
@@ -18,9 +19,15 @@ include $(PGXS)
# Custom targets
# Build development SQL from source files
.PHONY: build
build:
@echo "Building $(DEV_SQL) from source files..."
@./tools/build.sh
# Create versioned release file from development file
.PHONY: release
release:
release: build
@echo "Preparing release $(EXTVERSION)..."
@if [ ! -f $(DEV_SQL) ]; then \
echo "Error: $(DEV_SQL) not found"; \
@@ -38,11 +45,11 @@ install: release
# Run tests with development file in temporary database
.PHONY: test
test:
test: build
@echo "Testing with development file..."
-dropdb morbac_test 2>/dev/null || true
createdb morbac_test
@./tests/run_tests.sh morbac_test
@./tools/test.sh morbac_test
dropdb morbac_test
@echo "Test completed."
@@ -58,18 +65,20 @@ help:
@echo "morbac_pg Makefile targets:"
@echo ""
@echo "Development:"
@echo " Edit morbac_pg.sql (unversioned) for daily development"
@echo " Edit source files in src/ directory"
@echo ""
@echo " make test - Test with development file"
@echo " make release - Create versioned file from morbac_pg.sql"
@echo " make install - Create release and install extension"
@echo " make build - Build morbac_pg.sql from src/ files"
@echo " make test - Build and test in temporary database"
@echo " make release - Build and create versioned file"
@echo " make install - Build, release, and install extension"
@echo " make uninstall - Uninstall extension from PostgreSQL"
@echo " make help - Show this help"
@echo ""
@echo "Workflow:"
@echo " 1. Edit morbac_pg.sql (version-free development)"
@echo " 2. make test (test your changes)"
@echo " 1. Edit source files in src/ directory"
@echo " 2. make test (build and test your changes)"
@echo " 3. Update version in morbac_pg.control"
@echo " 4. make release (creates morbac_pg--X.Y.Z.sql)"
@echo " 4. make release (builds and creates morbac_pg--X.Y.Z.sql)"
@echo " 5. git tag vX.Y.Z && git push --tags"
@echo ""
@echo ""