url-shortener/Makefile

103 lines
2.3 KiB
Makefile
Raw Normal View History

2017-11-28 15:01:11 +00:00
REBAR := $(shell which rebar3 2>/dev/null || which ./rebar3)
2017-11-29 14:41:52 +00:00
SUBMODULES = schemes/swag-url-shortener build_utils
2017-11-28 15:01:11 +00:00
SUBTARGETS = $(patsubst %,%/.git,$(SUBMODULES))
UTILS_PATH := build_utils
TEMPLATES_PATH := .
# Name of the service
SERVICE_NAME := url-shortener
# 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
2017-11-29 14:41:52 +00:00
BUILD_IMAGE_TAG := eee42f2ca018c313190bc350fe47d4dea70b6d27
2017-11-28 15:01:11 +00:00
2017-12-18 14:49:39 +00:00
CALL_ANYWHERE := all submodules rebar-update compile xref lint dialyze start devrel release clean distclean
2017-11-28 15:01:11 +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)
# CALL_ANYWHERE
$(SUBTARGETS): %/.git: %
git submodule update --init $<
touch $@
submodules: $(SUBTARGETS)
rebar-update:
$(REBAR) update
2017-12-01 11:44:25 +00:00
compile: submodules rebar-update generate
2017-11-28 15:01:11 +00:00
$(REBAR) compile
xref: submodules
$(REBAR) xref
lint:
elvis rock
dialyze:
$(REBAR) dialyzer
start: submodules
$(REBAR) run
devrel: submodules
$(REBAR) release
2017-12-01 11:44:25 +00:00
release: submodules generate
2017-11-28 15:01:11 +00:00
$(REBAR) as prod release
2017-12-18 14:49:39 +00:00
clean::
2017-11-28 15:01:11 +00:00
$(REBAR) clean
2017-12-18 14:49:39 +00:00
distclean::
2017-11-28 15:01:11 +00:00
$(REBAR) clean -a
rm -rf _build
# CALL_W_CONTAINER
2017-11-29 14:41:52 +00:00
test: submodules generate
2017-11-28 15:01:11 +00:00
$(REBAR) ct
2017-11-29 14:41:52 +00:00
# Swagger stuff
SWAGGER_CODEGEN = $(call which, swagger-codegen)
SWAGGER_SCHEME_PATH = schemes/swag-url-shortener
SWAGGER_SCHEME = $(SWAGGER_SCHEME_PATH)/swagger.yaml
$(SWAGGER_SCHEME): $(SWAGGER_SCHEME_PATH)/.git
2017-12-18 14:49:39 +00:00
SWAGGER_SERVER_PATH = apps/swag_server
SWAGGER_CLIENT_PATH = apps/swag_client
generate:: swag.server.generate swag.client.generate
2017-11-29 14:41:52 +00:00
2017-12-18 14:49:39 +00:00
swag.server.generate: $(SWAGGER_SERVER_PATH)
swag.client.generate: $(SWAGGER_CLIENT_PATH)
2017-11-29 14:41:52 +00:00
2017-12-18 14:49:39 +00:00
distclean:: swag.server.distclean swag.client.distclean
2017-11-29 14:41:52 +00:00
2017-12-18 14:49:39 +00:00
swag.server.distclean:
rm -rf $(SWAGGER_SERVER_PATH)
swag.client.distclean:
rm -rf $(SWAGGER_CLIENT_PATH)
2017-11-29 14:41:52 +00:00
2017-12-18 14:49:39 +00:00
$(SWAGGER_SERVER_PATH) $(SWAGGER_CLIENT_PATH): $(SWAGGER_SCHEME)
2017-11-29 14:41:52 +00:00
$(SWAGGER_CODEGEN) generate \
2017-12-18 14:49:39 +00:00
-i $^ \
-l $(if $(findstring server,$@),erlang-server,erlang-client) \
-o $@ \
--additional-properties packageName=$(notdir $(basename $@))