2017-08-15 13:18:09 +00:00
|
|
|
THRIFT = $(or $(shell which thrift), $(error "`thrift' executable missing"))
|
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-09-09 22:24:38 +00:00
|
|
|
UTILS_PATH := build_utils
|
|
|
|
TEMPLATES_PATH := .
|
2016-07-21 22:15:27 +00:00
|
|
|
|
2016-09-09 22:24:38 +00:00
|
|
|
|
|
|
|
# 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)
|
|
|
|
|
|
|
|
|
2017-08-15 13:18:09 +00:00
|
|
|
BUILD_IMAGE_TAG := fbef66759ab9c7b620fc73785ba1840d2f48bd68
|
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
|
2017-08-15 13:18:09 +00:00
|
|
|
RELDIR = _release
|
2016-03-29 11:42:47 +00:00
|
|
|
|
2017-08-15 13:18:09 +00:00
|
|
|
CALL_W_CONTAINER := \
|
|
|
|
all compile doc clean \
|
|
|
|
java_compile deploy_nexus deploy_epic_nexus java_install \
|
|
|
|
release-erlang
|
2016-08-10 12:06:59 +00:00
|
|
|
|
|
|
|
all: compile
|
|
|
|
|
2016-09-09 22:24:38 +00:00
|
|
|
-include $(UTILS_PATH)/make_lib/utils_container.mk
|
2016-07-11 10:26:45 +00:00
|
|
|
|
2016-03-29 11:42:47 +00:00
|
|
|
define generate
|
2017-08-15 13:18:09 +00:00
|
|
|
$(THRIFT) -r -strict --gen $(1):$(THRIFT_OPTIONS_$(1)) -out $(2) $(3)
|
2016-03-29 11:42:47 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
define targets
|
|
|
|
$(patsubst %, $(DESTDIR)/$(1)/%, $(FILES))
|
|
|
|
endef
|
|
|
|
|
|
|
|
CUTLINE = $(shell printf '=%.0s' $$(seq 1 80))
|
|
|
|
|
2017-08-15 13:18:09 +00:00
|
|
|
.PHONY: all compile doc clean java_compile deploy_nexus deploy_epic_nexus java_install
|
2016-03-29 11:42:47 +00:00
|
|
|
|
|
|
|
LANGUAGE_TARGETS = $(foreach lang, $(THRIFT_LANGUAGES), verify-$(lang))
|
|
|
|
|
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
|
|
|
|
|
|
|
|
TARGETS = $(call targets,$(LANGUAGE))
|
|
|
|
|
|
|
|
$(TARGETS):: $(DESTDIR)/$(LANGUAGE)/%: %
|
|
|
|
mkdir -p $@
|
|
|
|
$(call generate,$(LANGUAGE),$@,$<)
|
|
|
|
|
2017-08-15 13:18:09 +00:00
|
|
|
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 $@
|
|
|
|
|
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-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")
|
|
|
|
|
2017-08-15 13:18:09 +00:00
|
|
|
build-release:
|
|
|
|
@make THRIFT="$(THRIFT)" FILES="$(abspath $(FILES))" -C build/erlang release
|
|
|
|
|
2016-03-31 15:38:04 +00:00
|
|
|
endif
|
2016-03-29 11:42:47 +00:00
|
|
|
endif
|
2016-06-23 12:11:01 +00:00
|
|
|
|
2017-08-15 13:18:09 +00:00
|
|
|
# Java
|
|
|
|
|
2016-09-09 22:24:38 +00:00
|
|
|
ifdef SETTINGS_XML
|
|
|
|
DOCKER_RUN_OPTS = -v $(SETTINGS_XML):$(SETTINGS_XML)
|
|
|
|
DOCKER_RUN_OPTS += -e SETTINGS_XML=$(SETTINGS_XML)
|
|
|
|
endif
|
2016-06-23 12:11:01 +00:00
|
|
|
|
2017-02-01 11:46:01 +00:00
|
|
|
ifdef LOCAL_BUILD
|
|
|
|
DOCKER_RUN_OPTS += -v $$HOME/.m2:/home/$(UNAME)/.m2:rw
|
|
|
|
endif
|
|
|
|
|
2016-07-06 15:55:10 +00:00
|
|
|
COMMIT_HASH = $(shell git --no-pager log -1 --pretty=format:"%h")
|
2016-08-22 12:13:50 +00:00
|
|
|
NUMBER_COMMITS = $(shell git rev-list --count HEAD)
|
2016-06-23 12:11:01 +00:00
|
|
|
|
2016-07-11 10:26:45 +00:00
|
|
|
java_compile:
|
2016-09-09 22:24:38 +00:00
|
|
|
$(if $(SETTINGS_XML),,echo "SETTINGS_XML not defined" ; exit 1)
|
|
|
|
mvn compile -s $(SETTINGS_XML)
|
2016-07-11 10:26:45 +00:00
|
|
|
|
2016-07-06 15:55:10 +00:00
|
|
|
deploy_nexus:
|
2016-09-09 22:24:38 +00:00
|
|
|
$(if $(SETTINGS_XML),, echo "SETTINGS_XML not defined"; exit 1)
|
|
|
|
mvn versions:set versions:commit -DnewVersion="1.$(NUMBER_COMMITS)-$(COMMIT_HASH)" -s $(SETTINGS_XML) \
|
2017-08-15 13:18:09 +00:00
|
|
|
&& mvn deploy -s $(SETTINGS_XML) -Dpath_to_thrift="$(THRIFT)" -Dcommit.number="$(NUMBER_COMMITS)"
|
2017-02-01 11:46:01 +00:00
|
|
|
|
2017-07-17 10:21:41 +00:00
|
|
|
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) \
|
2017-08-15 13:18:09 +00:00
|
|
|
&& mvn deploy -s $(SETTINGS_XML) -Dpath_to_thrift="$(THRIFT)" -Dcommit.number="$(NUMBER_COMMITS)"
|
2017-07-17 10:21:41 +00:00
|
|
|
|
|
|
|
|
2017-02-01 11:46:01 +00:00
|
|
|
java_install:
|
|
|
|
$(if $(SETTINGS_XML),, echo "SETTINGS_XML not defined"; exit 1)
|
2017-07-06 16:37:03 +00:00
|
|
|
mvn clean -s $(SETTINGS_XML) && \
|
2017-02-01 11:46:01 +00:00
|
|
|
mvn versions:set versions:commit -DnewVersion="1.$(NUMBER_COMMITS)-$(COMMIT_HASH)" -s $(SETTINGS_XML) \
|
2017-08-15 13:18:09 +00:00
|
|
|
&& mvn install -s $(SETTINGS_XML) -Dpath_to_thrift="$(THRIFT)" -Dcommit.number="$(NUMBER_COMMITS)"
|