forked from zsh-users/antigen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
172 lines (145 loc) · 4.83 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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
######################################################################
# This file was autogenerated by 'configure'. Do not edit it directly!
# Invocation was: ./configure
######################################################################
WITH_LOCK=yes
WITH_DEFER=yes
WITH_CACHE=yes
WITH_DEBUG=yes
WITH_PARALLEL=yes
WITH_EXTENSIONS=yes
WITH_COMPLETION=yes
######################################################################
SHELL ?= sh
PREFIX ?= /usr/local
CRAM_OPTS ?= -v
PROJECT ?= $(CURDIR)
BIN ?= ${PROJECT}/bin
SRC ?= ${PROJECT}/src
TESTS ?= ${PROJECT}/tests
TOOLS ?= ${PROJECT}/tools
TEST ?= ${PROJECT}/tests
ZSH_VERSION ?= zsh-5.3
CONTAINER_ROOT ?= /antigen
USE_CONTAINER ?= docker
CONTAINER_IMAGE ?= desyncr/zsh-docker-
TARGET ?= ${BIN}/antigen.zsh
SRC ?= ${SRC}
EXTENSIONS ?=
GLOB ?=
WITH_DEBUG ?= yes
WITH_EXTENSIONS ?= yes
WITH_DEFER ?= yes
WITH_LOCK ?= yes
WITH_PARALLEL ?= yes
WITH_CACHE ?= yes
WITH_COMPLETION ?= yes
ifeq (${WITH_EXTENSIONS}, yes)
EXTENSIONS += ${SRC}/ext/ext.zsh
endif
ifeq (${WITH_DEFER}, yes)
EXTENSIONS += ${SRC}/ext/defer.zsh
endif
ifeq (${WITH_LOCK}, yes)
EXTENSIONS += ${SRC}/ext/lock.zsh
endif
ifeq (${WITH_PARALLEL}, yes)
EXTENSIONS += ${SRC}/ext/parallel.zsh
endif
ifeq (${WITH_CACHE}, yes)
GLOB += ${SRC}/boot.zsh
EXTENSIONS += ${SRC}/ext/cache.zsh
endif
LIB = $(filter-out ${SRC}/lib/log.zsh,$(sort $(wildcard ${PWD}/src/lib/*.zsh)))
HELPERS = $(sort $(wildcard ${PWD}/src/helpers/*.zsh))
COMMANDS= $(sort $(wildcard ${PWD}/src/commands/*.zsh))
GLOB += ${SRC}/antigen.zsh ${HELPERS} ${LIB} ${COMMANDS} ${EXTENSIONS}
ifeq (${WITH_COMPLETION}, yes)
GLOB += ${SRC}/_antigen
endif
# If debug is enabled then load debug functions
ifeq (${WITH_DEBUG}, yes)
GLOB += ${SRC}/lib/log.zsh
endif
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 =\# Antigen: A simple plugin manager for zsh\n\
\# Authors: Shrikant Sharat Kandula\n\
\# and Contributors <https://github.com/zsh-users/antigen/contributors>\n\
\# Homepage: http://antigen.sharats.me\n\
\# License: MIT License <mitl.sharats.me>\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: itests tests install all
build:
@echo Building Antigen...
@printf "${BANNER}" > ${BIN}/antigen.zsh
@printf "${HEADER_TEXT}" >> ${BIN}/antigen.zsh
@for src in ${GLOB}; do echo "----> $$src"; cat "$$src" >> ${TARGET}; done
@echo "-antigen-env-setup" >> ${TARGET}
@echo "${VERSION}" > ${VERSION_FILE}
@$(call ised,"s/{{ANTIGEN_VERSION}}/$$(cat ${VERSION_FILE})/",${TARGET})
@$(call ised,"s/{{ANTIGEN_REVISION}}/$$(git log -n1 --format=%h -- src)/",${TARGET})
@$(call ised,"s/{{ANTIGEN_REVISION_DATE}}/$$(git log -n1 --format='%ai' -- src)/",${TARGET})
ifeq (${WITH_DEBUG}, no)
@$(call isede,"s/ (WARN|LOG|ERR|TRACE) .*&//",${TARGET})
@$(call isede,"/ (WARN|LOG|ERR|TRACE) .*/d",${TARGET})
endif
@echo Done.
@ls -sh ${TARGET}
release:
# Move to release branch
git checkout develop
git checkout -b release/${VERSION}
# Run build and tests
${MAKE} build tests
# Update changelog
${EDITOR} CHANGELOG.md
# Build release commit
git add CHANGELOG.md README.mkd ${VERSION_FILE}
git commit -S -m "Update changelog for ${VERSION}"
# Update binary artifact
git add ${TARGET}
git commit -S -m "Build release ${VERSION}"
publish:
git push origin release/${VERSION}
# Merge release branch into develop before deploying
deploy:
git checkout develop
git tag -m "Build release ${VERSION}" -s ${VERSION}
git archive --output=${VERSION}.tar.gz --prefix=antigen-$$(echo ${VERSION}|sed s/v//)/ ${VERSION}
zcat ${VERSION}.tar.gz | gpg --armor --detach-sign >${VERSION}.tar.gz.sign
# Verify signature
zcat ${VERSION}.tar.gz | gpg --verify ${VERSION}.tar.gz.sign -
# Push upstream
git push upstream ${VERSION}
.container:
ifeq (${USE_CONTAINER}, docker)
@docker run --rm --privileged=true -it -v ${PROJECT}:/antigen ${CONTAINER_IMAGE}${ZSH_VERSION} $(shell echo "${COMMAND}" | sed "s|${PROJECT}|${CONTAINER_ROOT}|g")
else ifeq (${USE_CONTAINER}, no)
${COMMAND}
endif
info:
@${MAKE} .container COMMAND="sh -c 'cat ${PROJECT}/VERSION; zsh --version; git --version; env'"
itests:
@${MAKE} tests CRAM_OPTS=-i
tests:
@${MAKE} .container COMMAND="sh -c 'ZDOTDIR=${TESTS} ANTIGEN=${PROJECT} cram ${CRAM_OPTS} --shell=zsh ${TEST}'"
stats:
@${MAKE} .container COMMAND="${TOOLS}/stats --zsh zsh --antigen ${PROJECT}"
install:
mkdir -p ${PREFIX}/share && cp ${TARGET} ${PREFIX}/share/antigen.zsh
clean:
rm -f ${PREFIX}/share/antigen.zsh
install-deps:
sudo pip install cram=='0.6.*'
all: clean build install