2016-07-06 15:55:10 +00:00
|
|
|
THRIFT_EXEC = $(shell which thrift)
|
2016-07-21 22:15:27 +00:00
|
|
|
THRIFT_LANGUAGES = erlang java
|
2016-06-17 16:41:05 +00:00
|
|
|
THRIFT_OPTIONS_erlang = scoped_typenames
|
2016-06-23 12:11:01 +00:00
|
|
|
THRIFT_OPTIONS_java = fullcamel
|
2016-03-31 15:38:04 +00:00
|
|
|
THRIFT_OPTIONS_html = standalone
|
2016-03-29 11:42:47 +00:00
|
|
|
|
2016-07-21 22:15:27 +00:00
|
|
|
REGISTRY := dr.rbkmoney.com
|
|
|
|
ORG_NAME := rbkmoney
|
|
|
|
BASE_IMAGE := "$(REGISTRY)/$(ORG_NAME)/build:latest"
|
|
|
|
|
|
|
|
RELNAME := damsel
|
2016-07-06 15:55:10 +00:00
|
|
|
|
2016-03-29 11:52:23 +00:00
|
|
|
FILES = $(wildcard proto/*.thrift)
|
2016-03-29 11:42:47 +00:00
|
|
|
DESTDIR = _gen
|
|
|
|
|
2016-07-21 22:15:27 +00:00
|
|
|
CALL_ANYWHERE := clean all create java_compile compile doc deploy_nexus
|
2016-07-06 15:55:10 +00:00
|
|
|
CALL_W_CONTAINER := $(CALL_ANYWHERE)
|
|
|
|
|
2016-08-10 12:06:59 +00:00
|
|
|
BASE_IMAGE ?= rbkmoney/build
|
|
|
|
|
|
|
|
all: compile
|
|
|
|
|
2016-07-11 10:26:45 +00:00
|
|
|
include utils.mk
|
|
|
|
|
2016-03-29 11:42:47 +00:00
|
|
|
define generate
|
|
|
|
$(THRIFT_EXEC) -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))
|
|
|
|
|
2016-07-21 22:15:27 +00:00
|
|
|
.PHONY: $(CALL_W_CONTAINER) create $(UTIL_TARGETS)
|
2016-03-29 11:42:47 +00:00
|
|
|
|
|
|
|
LANGUAGE_TARGETS = $(foreach lang, $(THRIFT_LANGUAGES), verify-$(lang))
|
|
|
|
|
2016-07-21 22:15:27 +00:00
|
|
|
# Build failed without this file: _build/test/logs/index.html (Hi, jenkins_pipeline_lib)
|
|
|
|
create:
|
|
|
|
mkdir -p _build/test/logs && touch _build/test/logs/index.html
|
|
|
|
|
2016-07-06 15:55:10 +00:00
|
|
|
compile: $(LANGUAGE_TARGETS)
|
|
|
|
@echo "Ok"
|
|
|
|
|
2016-03-29 11:42:47 +00:00
|
|
|
verify-%: $(DESTDIR)
|
|
|
|
@echo "Verifying '$*' ..."
|
|
|
|
@echo $(CUTLINE)
|
|
|
|
@$(MAKE) LANGUAGE=$* $(call targets,$*)
|
|
|
|
@echo
|
|
|
|
|
|
|
|
$(DESTDIR):
|
|
|
|
@mkdir -p $@
|
|
|
|
|
2016-03-31 15:44:31 +00:00
|
|
|
clean::
|
2016-04-01 11:58:26 +00:00
|
|
|
rm -rf $(DESTDIR)
|
2016-03-29 11:42:47 +00:00
|
|
|
|
|
|
|
TARGETS = $(call targets,$(LANGUAGE))
|
|
|
|
|
|
|
|
$(TARGETS):: $(DESTDIR)/$(LANGUAGE)/%: %
|
|
|
|
mkdir -p $@
|
|
|
|
$(call generate,$(LANGUAGE),$@,$<)
|
|
|
|
|
2016-03-31 15:38:04 +00:00
|
|
|
# Docs
|
|
|
|
|
|
|
|
DOCDIR = doc
|
|
|
|
DOCTARGETS = $(patsubst %.thrift, $(DOCDIR)/%.html, $(FILES))
|
|
|
|
|
|
|
|
doc: $(DOCTARGETS)
|
|
|
|
|
|
|
|
$(DOCTARGETS): $(DOCDIR)/%.html: %.thrift
|
|
|
|
mkdir -p $(dir $@)
|
|
|
|
$(call generate,html,$(dir $@),$<)
|
|
|
|
|
2016-03-31 15:44:31 +00:00
|
|
|
|
2016-03-29 11:42:47 +00:00
|
|
|
# Erlang
|
|
|
|
|
2016-03-31 15:38:04 +00:00
|
|
|
ERLC ?= erlc
|
|
|
|
|
2016-03-29 11:42:47 +00:00
|
|
|
ifeq ($(LANGUAGE), erlang)
|
2016-03-31 15:38:04 +00:00
|
|
|
ifneq ($(shell which $(ERLC)),)
|
|
|
|
|
2016-03-29 11:42:47 +00:00
|
|
|
$(TARGETS):: $(DESTDIR)/$(LANGUAGE)/%: %
|
2016-03-31 15:38:04 +00:00
|
|
|
$(ERLC) -v -I$@ -o$@ $(shell find $@ -name "*.erl")
|
|
|
|
|
|
|
|
endif
|
2016-03-29 11:42:47 +00:00
|
|
|
endif
|
2016-06-23 12:11:01 +00:00
|
|
|
|
|
|
|
|
2016-07-06 15:55:10 +00:00
|
|
|
COMMIT_HASH = $(shell git --no-pager log -1 --pretty=format:"%h")
|
2016-06-23 12:11:01 +00:00
|
|
|
|
2016-07-11 10:26:45 +00:00
|
|
|
java_compile:
|
2016-07-21 22:15:27 +00:00
|
|
|
mvn compile
|
2016-07-11 10:26:45 +00:00
|
|
|
|
2016-07-06 15:55:10 +00:00
|
|
|
deploy_nexus:
|
2016-07-21 22:15:27 +00:00
|
|
|
mvn versions:set versions:commit -DnewVersion="$(COMMIT_HASH)" \
|
|
|
|
&& mvn deploy -Dpath_to_thrift="$(THRIFT_EXEC)"
|