This repository has been archived by the owner on Aug 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
47 lines (37 loc) · 1.52 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
DOCS=./header.apib ./main.apib
DOCFINAL=./build/final.apib
APPNAME=rebblestore-api
LIBNAME:=${APPNAME}.a
TESTNAME=rebblestore-api-tests
SOURCES=$(wildcard *.go) $(wildcard */*.go)
SWAGGER_VERSION=v2.2.8
SWAGGER_UI=https://github.com/swagger-api/swagger-ui/archive/${SWAGGER_VERSION}.tar.gz
SWAGGER_FOLDER=./build/swagger
SWAGGER_TAR=${SWAGGER_FOLDER}/${SWAGGER_VERSION}.tar.gz
.PHONY: all deploy test build doc
all: build doc
${APPNAME}: ${SOURCES}
go get -v .
go install -v github.com/mattn/go-sqlite3
go build -o ${APPNAME} -ldflags "-X main.Buildhost=$(shell hostname -f) -X main.Buildstamp=$(shell date -u '+%Y-%m-%d_%I:%M:%S%p') -X main.Buildgithash=$(shell git rev-parse HEAD)" .
${TESTNAME}: ${SOURCES}
go get -v github.com/adams-sarah/test2doc/test
go test -o ${TESTNAME} .
${SWAGGER_TAR}:
mkdir -p ${SWAGGER_FOLDER}
wget -r --content-disposition ${SWAGGER_UI} -O ${SWAGGER_TAR}
tar xvf ${SWAGGER_TAR} -C ${SWAGGER_FOLDER} --strip-components=2 swagger-ui-2.2.8/dist/
sed 's#http://petstore.swagger.io/v2/swagger.json#http://docs.rebble.io/swagger.json#' -i ${SWAGGER_FOLDER}/index.html
${DOCFINAL}: test ${DOCS} ${APPNAME} ${SWAGGER_TAR}
mkdir -p ./build/
cat ${DOCS} > ${DOCFINAL}
apib2swagger -i ${DOCFINAL} -o ${SWAGGER_FOLDER}/swagger.json
#docprint -p ${DOCFINAL} -d './build/docs' #-h './build/files/header.html' -c './build/files/custom.css'
deploy:
sup production deploy
clean:
rm -v ${LIBNAME} ${APPNAME} ${TESTNAME} || true
rm -r ${SWAGGER_FOLDER} || true
build: ${APPNAME}
test: ${TESTNAME}
doc: ${DOCFINAL}