damsel/Makefile
Andrew Mayorov 3dd66accb3
DC-66: Introduce payout terms (#283)
* DC-66: Introduce payout terms (#269)
* DC-66: Generalize cash flow constants
* DC-78: add ability to disable scheduled payouts (#284)
* DC-76: add ability to calculate fees for payout (#285)
* HG-312: add payout method condition (#294)
* HG-312: change InvalidRequest to OperationNotPermitted (#295)
* DC-80: enlarge international entities (#297)
* PAYOUT-52: Nonresidents in payout events (#298)
* CAPI-251: add varset for payment institution terms computation (#302)
2018-02-26 15:14:59 +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 := eee42f2ca018c313190bc350fe47d4dea70b6d27
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)"