Refactor the Makefile
Separate concerns properly for each subdirectory's Makefile
This commit is contained in:
parent
d13f167d47
commit
dea6e2f1a7
45
Makefile
45
Makefile
@ -1,3 +1,5 @@
|
|||||||
|
include ./Makefile.global
|
||||||
|
|
||||||
EXT_DIR = src/pg
|
EXT_DIR = src/pg
|
||||||
PYP_DIR = src/py
|
PYP_DIR = src/py
|
||||||
|
|
||||||
@ -6,30 +8,63 @@ PYP_DIR = src/py
|
|||||||
.PHONY: release
|
.PHONY: release
|
||||||
.PHONY: deploy
|
.PHONY: deploy
|
||||||
|
|
||||||
|
|
||||||
# Generate and install developmet versions of the extension
|
# Generate and install developmet versions of the extension
|
||||||
# and python package.
|
# and python package.
|
||||||
# The extension is named 'dev' with a 'current' alias for easily upgrading.
|
# The extension is named 'dev' with a 'current' alias for easily upgrading.
|
||||||
# The Python package is installed in a virtual environment envs/dev/
|
# The Python package is installed in a virtual environment envs/dev/
|
||||||
# Requires sudo.
|
# Requires sudo.
|
||||||
install:
|
install: ## Generate and install development version of the extension; requires sudo.
|
||||||
$(MAKE) -C $(PYP_DIR) install
|
$(MAKE) -C $(PYP_DIR) install
|
||||||
$(MAKE) -C $(EXT_DIR) install
|
$(MAKE) -C $(EXT_DIR) install
|
||||||
|
|
||||||
# Run the tests for the installed development extension and
|
# Run the tests for the installed development extension and
|
||||||
# python package
|
# python package
|
||||||
test:
|
test: ## Run the tests for the development version of the extension
|
||||||
$(MAKE) -C $(PYP_DIR) test
|
$(MAKE) -C $(PYP_DIR) test
|
||||||
$(MAKE) -C $(EXT_DIR) test
|
$(MAKE) -C $(EXT_DIR) test
|
||||||
|
|
||||||
# Generate a new release into release
|
# Generate a new release into release
|
||||||
release:
|
release: ## Generate a new release of the extension. Only for telease manager
|
||||||
$(MAKE) -C $(EXT_DIR) release
|
$(MAKE) -C $(EXT_DIR) release
|
||||||
|
$(MAKE) -C $(PYP_DIR) release
|
||||||
|
|
||||||
# Install the current release.
|
# Install the current release.
|
||||||
# The Python package is installed in a virtual environment envs/X.Y.Z/
|
# The Python package is installed in a virtual environment envs/X.Y.Z/
|
||||||
# Requires sudo.
|
# Requires sudo.
|
||||||
# Use the RELEASE_VERSION environment variable to deploy a specific version:
|
# Use the RELEASE_VERSION environment variable to deploy a specific version:
|
||||||
# sudo make deploy RELEASE_VERSION=1.0.0
|
# sudo make deploy RELEASE_VERSION=1.0.0
|
||||||
deploy:
|
deploy: ## Deploy a released extension. Only for release manager. Requires sudo.
|
||||||
$(MAKE) -C $(EXT_DIR) deploy
|
$(MAKE) -C $(EXT_DIR) deploy
|
||||||
|
$(MAKE) -C $(PYP_DIR) deploy
|
||||||
|
|
||||||
|
# Cleanup development extension script files
|
||||||
|
clean-dev: ## clean up development extension script files
|
||||||
|
rm -f src/pg/$(EXTENSION)--*.sql
|
||||||
|
|
||||||
|
# # Cleanup all releases
|
||||||
|
# clean-releases:
|
||||||
|
# rm -rf release/python/*
|
||||||
|
# rm -f release/$(EXTENSION)--*.sql
|
||||||
|
# rm -f release/$(EXTENSION).control
|
||||||
|
|
||||||
|
# Cleanup current/specific version
|
||||||
|
clean-release: ## clean up current release
|
||||||
|
rm -rf release/python/$(RELEASE_VERSION)
|
||||||
|
rm -f release/$(RELEASE_VERSION)--*.sql
|
||||||
|
|
||||||
|
# Cleanup all virtual environments
|
||||||
|
clean-environments: ## clean up all virtual environments
|
||||||
|
rm -rf envs/*
|
||||||
|
|
||||||
|
clean-all: clean-dev clean-release clean-environments
|
||||||
|
|
||||||
|
help:
|
||||||
|
@IFS=$$'\n' ; \
|
||||||
|
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//'`); \
|
||||||
|
for help_line in $${help_lines[@]}; do \
|
||||||
|
IFS=$$'#' ; \
|
||||||
|
help_split=($$help_line) ; \
|
||||||
|
help_command=`echo $${help_split[0]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
|
||||||
|
help_info=`echo $${help_split[2]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
|
||||||
|
printf "%-30s %s\n" $$help_command $$help_info ; \
|
||||||
|
done
|
||||||
|
6
Makefile.global
Normal file
6
Makefile.global
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||||
|
EXTENSION = crankshaft
|
||||||
|
PACKAGE = crankshaft
|
||||||
|
EXTVERSION = $(shell grep default_version $(SELF_DIR)/src/pg/$(EXTENSION).control | sed -e "s/default_version[[:space:]]*=[[:space:]]*'\([^']*\)'/\1/")
|
||||||
|
RELEASE_VERSION ?= $(EXTVERSION)
|
||||||
|
SED = sed
|
@ -1,3 +1,5 @@
|
|||||||
|
include ../../Makefile.global
|
||||||
|
|
||||||
# Development tasks:
|
# Development tasks:
|
||||||
#
|
#
|
||||||
# * install generates the control & script files into src/pg/
|
# * install generates the control & script files into src/pg/
|
||||||
@ -9,10 +11,6 @@
|
|||||||
# * test runs the tests for the currently generated Development
|
# * test runs the tests for the currently generated Development
|
||||||
# extension.
|
# extension.
|
||||||
|
|
||||||
SED = sed
|
|
||||||
|
|
||||||
EXTENSION = crankshaft
|
|
||||||
|
|
||||||
DATA = $(EXTENSION)--dev.sql \
|
DATA = $(EXTENSION)--dev.sql \
|
||||||
$(EXTENSION)--current--dev.sql \
|
$(EXTENSION)--current--dev.sql \
|
||||||
$(EXTENSION)--dev--current.sql
|
$(EXTENSION)--dev--current.sql
|
||||||
@ -45,9 +43,6 @@ test: installcheck
|
|||||||
|
|
||||||
# Release tasks
|
# Release tasks
|
||||||
|
|
||||||
PACKAGE = crankshaft
|
|
||||||
EXTVERSION = $(shell grep default_version $(EXTENSION).control | sed -e "s/default_version[[:space:]]*=[[:space:]]*'\([^']*\)'/\1/")
|
|
||||||
|
|
||||||
../../release/$(EXTENSION).control: $(EXTENSION).control
|
../../release/$(EXTENSION).control: $(EXTENSION).control
|
||||||
cp $< $@
|
cp $< $@
|
||||||
|
|
||||||
@ -57,31 +52,9 @@ EXTVERSION = $(shell grep default_version $(EXTENSION).control | sed -e "s/def
|
|||||||
# and the python package in releases/python/X.Y.Z/crankshaft/
|
# and the python package in releases/python/X.Y.Z/crankshaft/
|
||||||
release: ../../release/$(EXTENSION).control $(SOURCES_DATA)
|
release: ../../release/$(EXTENSION).control $(SOURCES_DATA)
|
||||||
$(SED) $(REPLACEMENTS) $(SOURCES_DATA_DIR)/*.sql > ../../release/$(EXTENSION)--$(EXTVERSION).sql
|
$(SED) $(REPLACEMENTS) $(SOURCES_DATA_DIR)/*.sql > ../../release/$(EXTENSION)--$(EXTVERSION).sql
|
||||||
mkdir -p ../../release/python/$(EXTVERSION)
|
|
||||||
cp -r ../py/$(PACKAGE) ../../release/python/$(EXTVERSION)/
|
|
||||||
$(SED) -i -r 's/version='"'"'[0-9]+\.[0-9]+\.[0-9]+'"'"'/version='"'"'$(EXTVERSION)'"'"'/g' ../../release/python/$(EXTVERSION)/$(PACKAGE)/setup.py
|
|
||||||
|
|
||||||
RELEASE_VERSION ?= $(EXTVERSION)
|
|
||||||
|
|
||||||
# Install the current relese into the PostgreSQL extensions directory
|
# Install the current relese into the PostgreSQL extensions directory
|
||||||
# and the Python package in a virtual environment envs/X.Y.Z
|
# and the Python package in a virtual environment envs/X.Y.Z
|
||||||
deploy:
|
deploy:
|
||||||
$(INSTALL_DATA) ../../release/$(EXTENSION).control '$(DESTDIR)$(datadir)/extension/'
|
$(INSTALL_DATA) ../../release/$(EXTENSION).control '$(DESTDIR)$(datadir)/extension/'
|
||||||
$(INSTALL_DATA) ../../release/*.sql '$(DESTDIR)$(datadir)/extension/'
|
$(INSTALL_DATA) ../../release/*.sql '$(DESTDIR)$(datadir)/extension/'
|
||||||
# TODO: install also upgrade/downgrade files (manually generated)
|
|
||||||
virtualenv --system-site-packages $(VIRTUALENV_PATH)/$(RELEASE_VERSION)
|
|
||||||
$(VIRTUALENV_PATH)/$(RELEASE_VERSION)/bin/pip install -I -U ../../release/python/$(RELEASE_VERSION)/$(PACKAGE)
|
|
||||||
$(VIRTUALENV_PATH)/$(RELEASE_VERSION)/bin/pip install -I nose
|
|
||||||
|
|
||||||
clean-dev:
|
|
||||||
rm -f $(EXTENSION)--*.sql
|
|
||||||
|
|
||||||
clean-releases:
|
|
||||||
rm -rf ../../release/python/*
|
|
||||||
rm -f ../../release/$(EXTNAME)--*.sql
|
|
||||||
rm -f ../../release/$(EXTNAME).control
|
|
||||||
|
|
||||||
clean-environments:
|
|
||||||
rm -rf ../../envs/*
|
|
||||||
|
|
||||||
clean-all: clean-dev clean-releases clean-environments
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
include ../../Makefile.global
|
||||||
|
|
||||||
# Install the package locally for development
|
# Install the package locally for development
|
||||||
install:
|
install:
|
||||||
virtualenv --system-site-packages ../../envs/dev
|
virtualenv --system-site-packages ../../envs/dev
|
||||||
@ -8,3 +10,13 @@ install:
|
|||||||
# Test develpment install
|
# Test develpment install
|
||||||
test:
|
test:
|
||||||
../../envs/dev/bin/nosetests crankshaft/test/
|
../../envs/dev/bin/nosetests crankshaft/test/
|
||||||
|
|
||||||
|
release: ../../release/$(EXTENSION).control $(SOURCES_DATA)
|
||||||
|
mkdir -p ../../release/python/$(EXTVERSION)
|
||||||
|
cp -r ./$(PACKAGE) ../../release/python/$(EXTVERSION)/
|
||||||
|
$(SED) -i -r 's/version='"'"'[0-9]+\.[0-9]+\.[0-9]+'"'"'/version='"'"'$(EXTVERSION)'"'"'/g' ../../release/python/$(EXTVERSION)/$(PACKAGE)/setup.py
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
virtualenv --system-site-packages $(VIRTUALENV_PATH)/$(RELEASE_VERSION)
|
||||||
|
$(VIRTUALENV_PATH)/$(RELEASE_VERSION)/bin/pip install -I -U ../../release/python/$(RELEASE_VERSION)/$(PACKAGE)
|
||||||
|
$(VIRTUALENV_PATH)/$(RELEASE_VERSION)/bin/pip install -I nose
|
||||||
|
Loading…
Reference in New Issue
Block a user