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)
|
|
|
|
|
|
|
|
|
2021-09-28 11:09:26 +00:00
|
|
|
BUILD_IMAGE_TAG := 25c031edd46040a8745334570940a0f0b2154c5c
|
2016-07-06 15:55:10 +00:00
|
|
|
|
2017-09-04 15:40:55 +00:00
|
|
|
PROTODIR = proto
|
|
|
|
FILES = $(wildcard $(PROTODIR)/*.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 := \
|
2020-07-08 15:49:53 +00:00
|
|
|
all compile doc clean 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))
|
|
|
|
|
2020-07-08 15:49:53 +00:00
|
|
|
.PHONY: all compile doc clean
|
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:
|
2017-09-04 15:40:55 +00:00
|
|
|
@make THRIFT="$(THRIFT)" FILES="$(abspath $(FILES))" PROTO="$(abspath $(PROTODIR))" -C build/erlang release
|
2017-08-15 13:18:09 +00:00
|
|
|
|
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
|
|
|
|
2020-07-08 15:49:53 +00:00
|
|
|
include $(UTILS_PATH)/make_lib/java_proto.mk
|