forked from zunit-zsh/zunit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.in
114 lines (88 loc) · 3.1 KB
/
Makefile.in
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# vim: ft=make sw=4 ts=4 noet!
PREFIX ?= /usr/local
SHELL ?= sh
CRAM_OPTS ?= -v
PROJECT ?= $(CURDIR)
BIN ?= ${PROJECT}/bin
DOCS ?= ${PROJECT}/docs
SRC ?= ${PROJECT}/src
TESTS ?= ${PROJECT}/tests
ZSH_VERSION ?= zsh-5.8
CONTAINER_ROOT ?= /zunit
USE_CONTAINER ?= docker
CONTAINER_IMAGE ?= desyncr/zsh-docker-
PROG ?= ${BIN}/zunit
SRC ?= ${SRC}
GLOB ?=
LIB = $(filter-out ${SRC}/zunit.zsh,$(wildcard ${SRC}/*.zsh))
COMMANDS = $(sort $(wildcard ${SRC}/commands/*.zsh))
REPORTS = $(sort $(wildcard ${SRC}/reports/*.zsh))
GLOB += ${LIB} ${REPORTS} ${COMMANDS} ${SRC}/zunit.zsh
VERSION ?= develop
VERSION_FILE = ${PROJECT}/VERSION
BANNER_SEP = $(shell printf '%*s' 70 | tr ' ' '\#')
BANNER_TEXT = This file was autogenerated by \`make\`. Do not edit it directly!
BANNER = ${BANNER_SEP}\n\# ${BANNER_TEXT}\n${BANNER_SEP}\n
HEADER_TEXT =\
\#!/usr/bin/env zsh\n\
\# Zunit: A unit test framework for zsh\n\
\# License: MIT License\n
define ised
sed $(1) $(2) > "$(2).1"
mv "$(2).1" "$(2)"
endef
define isede
sed -E $(1) $(2) > "$(2).1"
mv "$(2).1" "$(2)"
endef
.PHONY: all build clean install itests tests uninstall
all: build
release:
git checkout develop
git checkout -b release/${VERSION}
${MAKE} build tests
${EDITOR} CHANGELOG.md
git add CHANGELOG.md README.mkd ${VERSION_FILE}
git commit -S -m "Update changelog for ${VERSION}"
git add ${PROG}
git commit -S -m "Build release ${VERSION}"
publish:
git push origin release/${VERSION}
deploy:
git checkout develop
git tag -m "Build release ${VERSION}" -s ${VERSION}
git archive --output=${VERSION}.tar.gz --prefix=zunit-$$(echo ${VERSION}|sed s/v//)/ ${VERSION}
zcat ${VERSION}.tar.gz | gpg --armor --detach-sign >${VERSION}.tar.gz.sign
zcat ${VERSION}.tar.gz | gpg --verify ${VERSION}.tar.gz.sign -
git push upstream ${VERSION}
.container:
ifeq (${USE_CONTAINER}, docker)
@docker run --rm --privileged=true -it -v ${PROJECT}:/zunit ${CONTAINER_IMAGE}${ZSH_VERSION} $(shell echo "${COMMAND}" | sed "s|${PROJECT}|${CONTAINER_ROOT}|g")
else ifeq (${USE_CONTAINER}, no)
${COMMAND}
endif
docs:
mkdir ${DOCS}; cd ${DOCS}; zsh -dfilc "zsd -v --scomm --cignore '(\#*FUNCTION:[[:space:]][\:\∞\.\+\@\-a-zA-Z0-9]*[\[]*|}[[:space:]]\#[[:space:]][\]]*)' ${GLOB}"
info:
@${MAKE} .container COMMAND="sh -c 'cat ${PROJECT}/VERSION; zsh --version; git --version; env'"
tests:
@${make} .container command="sh -c 'zdotdir=${tests} zunit=${project} cram ${cram_opts} --shell=zsh ${test}'"
tests:
${PROG} run
install:
install -cv -m755 ${PROG} ${PREFIX}/bin/zunit
uninstall:
rm -f ${PREFIX}/bin/zunit
clean:
rm -rf ${BIN} Makefile
install-deps:
sudo pip install cram=='0.6.*'
build:
@echo Building Zunit...
@mkdir -p ${BIN}
@printf "${HEADER_TEXT}" > ${PROG}
@echo "${BANNER}" >> ${PROG}
@for src in ${GLOB}; do echo "----> $$src"; cat "$$src" | grep -v -e '#\svim.*' -e '^(\s*#.*|\s*)\$$' >> ${PROG}; done
@$(call ised,"s/{{ZUNIT_REVISION}}/$$(git log -n1 --format=%h -- src)/",${PROG})
@$(call ised,"s/{{ZUNIT_REVISION_DATE}}/$$(git log -n1 --format='%ai' -- src)/",${PROG})
@$(call ised,"s/{{ZUNIT_VERSION}}/$$(cat ${VERSION_FILE})/",${PROG})