mirror of
https://github.com/valitydev/damsel.git
synced 2024-11-06 09:45:21 +00:00
69 lines
1.2 KiB
Makefile
69 lines
1.2 KiB
Makefile
THRIFT_EXEC = thrift
|
|
THRIFT_LANGUAGES = erlang go java
|
|
THRIFT_OPTIONS_html = standalone
|
|
|
|
FILES = $(wildcard proto/*.thrift)
|
|
DESTDIR = _gen
|
|
|
|
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))
|
|
|
|
.PHONY: all clean doc
|
|
|
|
LANGUAGE_TARGETS = $(foreach lang, $(THRIFT_LANGUAGES), verify-$(lang))
|
|
|
|
all: $(LANGUAGE_TARGETS)
|
|
@echo "Ok"
|
|
|
|
verify-%: $(DESTDIR)
|
|
@echo "Verifying '$*' ..."
|
|
@echo $(CUTLINE)
|
|
@$(MAKE) LANGUAGE=$* $(call targets,$*)
|
|
@echo
|
|
|
|
$(DESTDIR):
|
|
@mkdir -p $@
|
|
|
|
clean::
|
|
@rm -rfv $(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 $@),$<)
|
|
|
|
clean::
|
|
@rm -rfv $(DOCDIR)
|
|
|
|
# Erlang
|
|
|
|
ERLC ?= erlc
|
|
|
|
ifeq ($(LANGUAGE), erlang)
|
|
ifneq ($(shell which $(ERLC)),)
|
|
|
|
$(TARGETS):: $(DESTDIR)/$(LANGUAGE)/%: %
|
|
$(ERLC) -v -I$@ -o$@ $(shell find $@ -name "*.erl")
|
|
|
|
endif
|
|
endif
|