fistful-server/Makefile

118 lines
2.8 KiB
Makefile
Raw Normal View History

2018-07-30 14:30:57 +00:00
REBAR := $(shell which rebar3 2>/dev/null || which ./rebar3)
2018-06-13 13:43:48 +00:00
SUBMODULES = build-utils
2018-07-06 13:49:30 +00:00
# wapi
SUBMODULES += schemes/swag
2018-06-13 13:43:48 +00:00
SUBTARGETS = $(patsubst %,%/.git,$(SUBMODULES))
UTILS_PATH := build-utils
TEMPLATES_PATH := .
# Name of the service
SERVICE_NAME := fistful-server
# 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)
# Base image for the service
2019-07-17 14:12:35 +00:00
BASE_IMAGE_NAME := service-erlang
2019-11-07 15:21:11 +00:00
BASE_IMAGE_TAG := da0ab769f01b650b389d18fc85e7418e727cbe96
2018-06-13 13:43:48 +00:00
# Build image tag to be used
BUILD_IMAGE_TAG := 442c2c274c1d8e484e5213089906a4271641d95e
2018-06-13 13:43:48 +00:00
2019-06-27 15:58:45 +00:00
REGISTRY := dr2.rbkmoney.com
2019-05-28 13:32:59 +00:00
2018-06-13 13:43:48 +00:00
CALL_ANYWHERE := all submodules compile xref lint dialyze release clean distclean
2018-07-06 13:49:30 +00:00
CALL_ANYWHERE += generate regenerate
2018-06-13 13:43:48 +00:00
CALL_W_CONTAINER := $(CALL_ANYWHERE) test
all: compile
-include $(UTILS_PATH)/make_lib/utils_container.mk
-include $(UTILS_PATH)/make_lib/utils_image.mk
.PHONY: $(CALL_W_CONTAINER)
$(SUBTARGETS): %/.git: %
git submodule update --init $<
touch $@
submodules: $(SUBTARGETS)
2018-07-06 13:49:30 +00:00
compile: submodules generate
2018-06-13 13:43:48 +00:00
$(REBAR) compile
xref: submodules
$(REBAR) xref
lint:
elvis rock
2018-07-30 14:44:35 +00:00
dialyze: submodules generate
2018-06-13 13:43:48 +00:00
$(REBAR) dialyzer
2018-07-30 14:44:35 +00:00
release: submodules generate
2018-06-13 13:43:48 +00:00
$(REBAR) as prod release
clean:
$(REBAR) clean
distclean: swagger.distclean.server.wallet swagger.distclean.client.wallet swagger.distclean.client.payres
2018-06-13 13:43:48 +00:00
$(REBAR) clean -a
rm -rf _build
test: submodules
2018-08-27 12:08:06 +00:00
$(REBAR) eunit
$(REBAR) ct
TESTSUITES = $(wildcard apps/*/test/*_SUITE.erl)
define testsuite
test.$(patsubst ff_%_SUITE.erl,%,$(notdir $(1))): $(1) submodules
$(REBAR) ct --suite=$$<
endef
$(foreach suite,$(TESTSUITES),$(eval $(call testsuite,$(suite))))
2018-07-06 13:49:30 +00:00
2018-07-26 12:02:05 +00:00
# Swagger
2018-07-06 13:49:30 +00:00
2018-07-26 12:02:05 +00:00
.PHONY: generate
generate: swagger.generate.server.wallet swagger.generate.client.wallet swagger.generate.client.payres
2018-07-06 13:49:30 +00:00
2018-07-26 12:02:05 +00:00
.PHONY: regenerate
regenerate: swagger.regenerate.server.wallet swagger.regenerate.client.wallet swagger.generate.client.payres
2018-07-06 13:49:30 +00:00
2018-07-26 12:02:05 +00:00
#
2018-07-06 13:49:30 +00:00
2018-07-26 12:02:05 +00:00
SWAGGER_CODEGEN = $(call which, swagger-codegen)
SWAGGER_SPEC_BASE_PATH = schemes/swag/api
2018-07-06 13:49:30 +00:00
2018-07-26 12:02:05 +00:00
swagger-spec-path = $(SWAGGER_SPEC_BASE_PATH)/$(1)/swagger.yaml
swagger-app-target = apps/swag_$(1)_$(2)
2018-07-06 13:49:30 +00:00
2018-07-26 12:02:05 +00:00
__swagger_role = $(word 1,$(subst ., ,$*))
__swagger_spec = $(word 2,$(subst ., ,$*))
2018-07-06 13:49:30 +00:00
2018-07-26 12:02:05 +00:00
swagger.generate.%:
@$(MAKE) \
SWAGGER_APP_ROLE=$(__swagger_role) \
SWAGGER_APP_SPEC=$(__swagger_spec) \
$(call swagger-app-target,$(__swagger_role),$(__swagger_spec))
2018-07-06 13:49:30 +00:00
2018-07-26 12:02:05 +00:00
swagger.distclean.%:
rm -rf $(call swagger-app-target,$(__swagger_role),$(__swagger_spec))
2018-07-06 13:49:30 +00:00
2018-07-26 12:02:05 +00:00
swagger.regenerate.%:
@$(MAKE) swagger.distclean.$* swagger.generate.$*
2018-07-06 13:49:30 +00:00
2018-07-26 12:02:05 +00:00
apps/swag_$(SWAGGER_APP_ROLE)_%: $(call swagger-spec-path,%)
2018-07-06 13:49:30 +00:00
$(SWAGGER_CODEGEN) generate \
2018-07-26 12:02:05 +00:00
-i $< -l erlang-$(SWAGGER_APP_ROLE) -o $@ \
--additional-properties packageName=swag_$(SWAGGER_APP_ROLE)_$(SWAGGER_APP_SPEC)
touch $@