fistful-server/Makefile

145 lines
3.5 KiB
Makefile
Raw Normal View History

2018-07-06 13:49:30 +00:00
REBAR = $(or $(shell which rebar3), $(error "`rebar3' executable missing"))
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
BASE_IMAGE_NAME := service_erlang
BASE_IMAGE_TAG := 16e2b3ef17e5fdefac8554ced9c2c74e5c6e9e11
# Build image tag to be used
2018-07-06 13:49:30 +00:00
BUILD_IMAGE_TAG := 585ec439a97bade30cfcebc36cefdb45f13f3372
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
dialyze: submodules
$(REBAR) dialyzer
release: submodules
$(REBAR) as prod release
clean:
$(REBAR) clean
2018-07-06 13:49:30 +00:00
distclean: swag_server.distclean swag_client.distclean
2018-06-13 13:43:48 +00:00
$(REBAR) clean -a
rm -rf _build
test: submodules
2018-07-06 13:49:30 +00:00
$(REBAR) eunit 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
#
# wapi
#
.PHONY: generate regenerate swag_server.generate swag_server.regenerate swag_client.generate swag_client.regenerate
generate: swag_server.generate swag_client.generate
regenerate: swag_server.regenerate swag_client.regenerate
SWAGGER_CODEGEN = $(call which, swagger-codegen)
SWAGGER_SCHEME_BASE_PATH := schemes/swag
APP_PATH := apps
SWAGGER_SCHEME_API_PATH := $(SWAGGER_SCHEME_BASE_PATH)/api
SWAG_SPEC_FILE := swagger.yaml
# Swagger server
SWAG_SERVER_PREFIX := swag_server
SWAG_SERVER_APP_TARGET := $(APP_PATH)/$(SWAG_SERVER_PREFIX)
SWAG_SERVER_APP_PATH := $(APP_PATH)/$(SWAG_SERVER_PREFIX)
SWAG_SERVER_APP_TARGET_WALLET := $(SWAG_SERVER_APP_PATH)_wallet/rebar.config
2018-07-08 16:58:55 +00:00
$(SWAG_SERVER_APP_PATH)_%/rebar.config: $(SWAGGER_SCHEME_API_PATH)/$*
2018-07-06 13:49:30 +00:00
$(SWAGGER_CODEGEN) generate \
-i $(SWAGGER_SCHEME_API_PATH)/$*/$(SWAG_SPEC_FILE) \
-l erlang-server \
-o $(SWAG_SERVER_APP_PATH)_$* \
--additional-properties \
packageName=$(SWAG_SERVER_PREFIX)_$*
swag_server.generate: $(SWAG_SERVER_APP_TARGET_WALLET)
2018-07-06 13:49:30 +00:00
swag_server.distclean: swag_server.distclean_wallet
2018-07-06 13:49:30 +00:00
swag_server.distclean_%:
rm -rf $(SWAG_SERVER_APP_PATH)_$*
swag_server.regenerate: swag_server.distclean swag_server.generate
# Swagger client
SWAG_CLIENT_PREFIX := swag_client
SWAG_CLIENT_APP_TARGET := $(APP_PATH)/$(SWAG_CLIENT_PREFIX)
SWAG_CLIENT_APP_PATH := $(APP_PATH)/$(SWAG_CLIENT_PREFIX)
SWAG_CLIENT_APP_TARGET_WALLET := $(SWAG_CLIENT_APP_PATH)_wallet/rebar.config
2018-07-08 16:58:55 +00:00
$(SWAG_CLIENT_APP_PATH)_%/rebar.config: $(SWAGGER_SCHEME_API_PATH)/$*
2018-07-06 13:49:30 +00:00
$(SWAGGER_CODEGEN) generate \
-i $(SWAGGER_SCHEME_API_PATH)/$*/$(SWAG_SPEC_FILE) \
-l erlang-client \
-o $(SWAG_CLIENT_APP_PATH)_$* \
--additional-properties \
packageName=$(SWAG_CLIENT_PREFIX)_$*
swag_client.generate: $(SWAG_CLIENT_APP_TARGET_WALLET)
2018-07-06 13:49:30 +00:00
swag_client.distclean: swag_client.distclean_wallet
2018-07-06 13:49:30 +00:00
swag_client.distclean_%:
rm -rf $(SWAG_CLIENT_APP_PATH)_$*
swag_client.regenerate: swag_client.distclean swag_client.generate