Introduce new make targets for downgrade scripts

Here are the updated make targets:
- install: install everything except downgrade scripts.
- install-downgrades: build and install only the downgrade migration scripts.
- install-all: install everything along with the downgrade migration scripts.

Conflicts:
  src/backend/distributed/Makefile
  src/backend/distributed/sql/downgrades/citus--9.5-1--9.4-1.sql
    - file does not exist on release branch yet, only on master

(cherry picked from commit 315b323d47)
pull/4206/head
Hanefi Önaldı 2020-07-08 13:01:44 +03:00
parent 77b4534c72
commit 3de2d2868d
No known key found for this signature in database
GPG Key ID: 45A2ACB84E394FBA
5 changed files with 31 additions and 2 deletions

View File

@ -24,6 +24,7 @@ install-headers: extension
$(INSTALL_DATA) $(citus_top_builddir)/src/include/citus_version.h '$(DESTDIR)$(includedir_server)/'
# the rest in the source tree
$(INSTALL_DATA) $(citus_abs_srcdir)/src/include/distributed/*.h '$(DESTDIR)$(includedir_server)/distributed/'
clean-extension:
$(MAKE) -C src/backend/distributed/ clean
clean-full:
@ -31,6 +32,11 @@ clean-full:
.PHONY: extension install-extension clean-extension clean-full
# Add to generic targets
install: install-extension install-headers
install-downgrades:
$(MAKE) -C src/backend/distributed/ install-downgrades
install-all: install-headers
$(MAKE) -C src/backend/distributed/ install-all
clean: clean-extension
# apply or check style
@ -44,4 +50,4 @@ check-style:
check: all install
$(MAKE) -C src/test/regress check-full
.PHONY: all check install clean
.PHONY: all check clean install install-downgrades install-all

View File

@ -11,7 +11,9 @@ MODULE_big = citus
EXTENSION = citus
template_sql_files = $(patsubst $(citus_abs_srcdir)/%,%,$(wildcard $(citus_abs_srcdir)/sql/*.sql))
template_downgrade_sql_files = $(patsubst $(citus_abs_srcdir)/sql/downgrades/%,%,$(wildcard $(citus_abs_srcdir)/sql/downgrades/*.sql))
generated_sql_files = $(patsubst %,$(citus_abs_srcdir)/build/%,$(template_sql_files))
generated_downgrade_sql_files += $(patsubst %,$(citus_abs_srcdir)/build/sql/%,$(template_downgrade_sql_files))
# All citus--*.sql files that are used to upgrade between versions
DATA_built = $(generated_sql_files)
@ -54,6 +56,20 @@ SQL_BUILDDIR=build/sql
$(generated_sql_files): $(citus_abs_srcdir)/build/%: %
@mkdir -p $(citus_abs_srcdir)/$(SQL_DEPDIR) $(citus_abs_srcdir)/$(SQL_BUILDDIR)
@# -MF is used to store dependency files(.Po) in another directory for separation
@# -MT is used to change the target of the rule emitted by dependency generation.
@# -P is used to inhibit generation of linemarkers in the output from the preprocessor.
@# -undef is used to not predefine any system-specific or GCC-specific macros.
@# `man cpp` for further information
cd $(citus_abs_srcdir) && cpp -undef -w -P -MMD -MP -MF$(SQL_DEPDIR)/$(*F).Po -MT$@ $< > $@
$(generated_downgrade_sql_files): $(citus_abs_srcdir)/build/sql/%: sql/downgrades/%
@mkdir -p $(citus_abs_srcdir)/$(SQL_DEPDIR) $(citus_abs_srcdir)/$(SQL_BUILDDIR)
@# -MF is used to store dependency files(.Po) in another directory for separation
@# -MT is used to change the target of the rule emitted by dependency generation.
@# -P is used to inhibit generation of linemarkers in the output from the preprocessor.
@# -undef is used to not predefine any system-specific or GCC-specific macros.
@# `man cpp` for further information
cd $(citus_abs_srcdir) && cpp -undef -w -P -MMD -MP -MF$(SQL_DEPDIR)/$(*F).Po -MT$@ $< > $@
SQL_Po_files := $(wildcard $(SQL_DEPDIR)/*.Po)
@ -61,7 +77,7 @@ ifneq (,$(SQL_Po_files))
include $(SQL_Po_files)
endif
.PHONY: check-sql-snapshots clean-full
.PHONY: check-sql-snapshots clean-full install install-downgrades install-all
check-sql-snapshots:
bash -c '\
@ -76,6 +92,13 @@ cleanup-before-install:
install: cleanup-before-install
# install and install-downgrades should be run sequentially
install-all: install
make install-downgrades
install-downgrades: $(generated_downgrade_sql_files)
$(INSTALL_DATA) $(generated_downgrade_sql_files) '$(DESTDIR)$(datadir)/$(datamoduledir)/'
clean-full:
make clean
rm -rf $(safestringlib_builddir)