damsel/Makefile

109 lines
2.2 KiB
Makefile
Raw Normal View History

THRIFT = $(or $(shell which thrift), $(error "`thrift' executable missing"))
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-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
PROTODIR = proto
FILES = $(wildcard $(PROTODIR)/*.thrift)
DESTDIR = _gen
RELDIR = _release
CALL_W_CONTAINER := \
all compile doc clean release-erlang
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
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
LANGUAGE_TARGETS = $(foreach lang, $(THRIFT_LANGUAGES), verify-$(lang))
2016-07-06 15:55:10 +00:00
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
include $(UTILS_PATH)/make_lib/java_proto.mk