damsel/Makefile
Evgeny Levenets 284cb1ad85
BA-43: Bring payment institutions on the table (#259)
DC-62: add payment institution (#254)
  * add payment institution
  * add PaymentInstitutionRealm to identify test or live one
  * bump build image for the best thrift compiler
  * add PaymentInstitutionRef to contract creation params
  * remove shop, contract and party proto entirely

DC-64: add discrete party revisioning (#258)
  * add discrete party revisioning
  * add special PartyCreated change to separate service interface and event payload

DC-64: make party revisioning in change instead of event (#261)

DC-71: add international legal entity and bank account (#270)

DC-75: add migration data to Globals (#277)

DC-75: add backwards compatibility to party events (#278)
  * add notes about party revisioning
2018-01-19 16:44:26 +03:00

144 lines
3.6 KiB
Makefile

THRIFT = $(or $(shell which thrift), $(error "`thrift' executable missing"))
THRIFT_LANGUAGES = erlang java
THRIFT_OPTIONS_erlang = scoped_typenames
THRIFT_OPTIONS_java = fullcamel
THRIFT_OPTIONS_html = standalone
UTILS_PATH := build_utils
TEMPLATES_PATH := .
# Name of the service
SERVICE_NAME := damsel
# Service image default tag
SERVICE_IMAGE_TAG ?= $(shell git rev-parse HEAD)
# The tag for service image to be pushed with
SERVICE_IMAGE_PUSH_TAG ?= $(SERVICE_IMAGE_TAG)
BUILD_IMAGE_TAG := 1dad297ae654513d8e3e946414759b979ebb27c1
PROTODIR = proto
FILES = $(wildcard $(PROTODIR)/*.thrift)
DESTDIR = _gen
RELDIR = _release
CALL_W_CONTAINER := \
all compile doc clean \
java_compile deploy_nexus deploy_epic_nexus java_install \
release-erlang
all: compile
-include $(UTILS_PATH)/make_lib/utils_container.mk
define generate
$(THRIFT) -r -strict --gen $(1):$(THRIFT_OPTIONS_$(1)) -out $(2) $(3)
endef
define targets
$(patsubst %, $(DESTDIR)/$(1)/%, $(FILES))
endef
CUTLINE = $(shell printf '=%.0s' $$(seq 1 80))
.PHONY: all compile doc clean java_compile deploy_nexus deploy_epic_nexus java_install
LANGUAGE_TARGETS = $(foreach lang, $(THRIFT_LANGUAGES), verify-$(lang))
compile: $(LANGUAGE_TARGETS)
@echo "Ok"
verify-%: $(DESTDIR)
@echo "Verifying '$*' ..."
@echo $(CUTLINE)
@$(MAKE) LANGUAGE=$* $(call targets,$*)
@echo
TARGETS = $(call targets,$(LANGUAGE))
$(TARGETS):: $(DESTDIR)/$(LANGUAGE)/%: %
mkdir -p $@
$(call generate,$(LANGUAGE),$@,$<)
clean::
rm -rf $(DESTDIR)
REPODIR = $(abspath $(RELDIR)/$*)
DOCKER_RUN_OPTS := -e BRANCH_NAME
release-%: $(RELDIR)
@echo "Making '$*' release ..."
@echo $(CUTLINE)
@rm -rf $(REPODIR)
$(MAKE) LANGUAGE=$* DESTDIR=$(REPODIR) build-release
clean::
rm -rf $(RELDIR)
$(DESTDIR):
$(RELDIR):
@mkdir -p $@
# Docs
DOCDIR = doc
DOCTARGETS = $(patsubst %.thrift, $(DOCDIR)/%.html, $(FILES))
doc: $(DOCTARGETS)
$(DOCTARGETS): $(DOCDIR)/%.html: %.thrift
mkdir -p $(dir $@)
$(call generate,html,$(dir $@),$<)
# Erlang
ERLC ?= erlc
ifeq ($(LANGUAGE), erlang)
ifneq ($(shell which $(ERLC)),)
$(TARGETS):: $(DESTDIR)/$(LANGUAGE)/%: %
$(ERLC) -v -I$@ -o$@ $(shell find $@ -name "*.erl")
build-release:
@make THRIFT="$(THRIFT)" FILES="$(abspath $(FILES))" PROTO="$(abspath $(PROTODIR))" -C build/erlang release
endif
endif
# Java
ifdef SETTINGS_XML
DOCKER_RUN_OPTS = -v $(SETTINGS_XML):$(SETTINGS_XML)
DOCKER_RUN_OPTS += -e SETTINGS_XML=$(SETTINGS_XML)
endif
ifdef LOCAL_BUILD
DOCKER_RUN_OPTS += -v $$HOME/.m2:/home/$(UNAME)/.m2:rw
endif
COMMIT_HASH = $(shell git --no-pager log -1 --pretty=format:"%h")
NUMBER_COMMITS = $(shell git rev-list --count HEAD)
java_compile:
$(if $(SETTINGS_XML),,echo "SETTINGS_XML not defined" ; exit 1)
mvn compile -s $(SETTINGS_XML)
deploy_nexus:
$(if $(SETTINGS_XML),, echo "SETTINGS_XML not defined"; exit 1)
mvn versions:set versions:commit -DnewVersion="1.$(NUMBER_COMMITS)-$(COMMIT_HASH)" -s $(SETTINGS_XML) \
&& mvn deploy -s $(SETTINGS_XML) -Dpath_to_thrift="$(THRIFT)" -Dcommit.number="$(NUMBER_COMMITS)"
deploy_epic_nexus:
$(if $(SETTINGS_XML),, echo "SETTINGS_XML not defined"; exit 1)
mvn versions:set versions:commit -DnewVersion="1.$(NUMBER_COMMITS)-$(COMMIT_HASH)-epic" -s $(SETTINGS_XML) \
&& mvn deploy -s $(SETTINGS_XML) -Dpath_to_thrift="$(THRIFT)" -Dcommit.number="$(NUMBER_COMMITS)"
java_install:
$(if $(SETTINGS_XML),, echo "SETTINGS_XML not defined"; exit 1)
mvn clean -s $(SETTINGS_XML) && \
mvn versions:set versions:commit -DnewVersion="1.$(NUMBER_COMMITS)-$(COMMIT_HASH)" -s $(SETTINGS_XML) \
&& mvn install -s $(SETTINGS_XML) -Dpath_to_thrift="$(THRIFT)" -Dcommit.number="$(NUMBER_COMMITS)"