damsel/Makefile

98 lines
1.9 KiB
Makefile
Raw Normal View History

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
THRIFT_OPTIONS_erlang = scoped_typenames
THRIFT_OPTIONS_java = fullcamel
THRIFT_OPTIONS_html = standalone
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)
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)
BASE_IMAGE ?= rbkmoney/build
all: compile
2016-07-11 10:26:45 +00:00
include utils.mk
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)
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"
verify-%: $(DESTDIR)
@echo "Verifying '$*' ..."
@echo $(CUTLINE)
@$(MAKE) LANGUAGE=$* $(call targets,$*)
@echo
$(DESTDIR):
@mkdir -p $@
2016-03-31 15:44:31 +00:00
clean::
rm -rf $(DESTDIR)
TARGETS = $(call targets,$(LANGUAGE))
$(TARGETS):: $(DESTDIR)/$(LANGUAGE)/%: %
mkdir -p $@
$(call generate,$(LANGUAGE),$@,$<)
# 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
# Erlang
ERLC ?= erlc
ifeq ($(LANGUAGE), erlang)
ifneq ($(shell which $(ERLC)),)
$(TARGETS):: $(DESTDIR)/$(LANGUAGE)/%: %
$(ERLC) -v -I$@ -o$@ $(shell find $@ -name "*.erl")
endif
endif
2016-07-06 15:55:10 +00:00
COMMIT_HASH = $(shell git --no-pager log -1 --pretty=format:"%h")
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)"