-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·299 lines (256 loc) · 9.61 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# Project settings
## Replace directory with a common distrobution point for the team
PRJ_DIR := prj_dir
## Replace with a customer-specific PRJ name
PRJ_NAME := prj_name
# virtualenv settings
ENV := env
# Flags for PHONY targets
DEPENDS_CI := $(ENV)/.depends-ci
DEPENDS_DEV := $(ENV)/.depends-dev
ALL := $(ENV)/.all
# Flags for targest ... modify for your project
SPECS_CHECK_FL := specs/.specs_check_FL
SPECS_CHECK_SYSRS := specs/.specs_check_SYSRS
SPECS_CHECK_CLHLR := specs/.specs_check_CLHLR
SPECS_CHECK_HWHLR := specs/.specs_check_HWHLR
SPECS_CHECK_MEHLR := specs/.specs_check_MEHLR
SPECS_CHECK_SWHLR := specs/.specs_check_SWHLR
EXCEL_CHECK_FL := xlsx/.excel_check_FL
EXCEL_CHECK_SYSRS := xlsx/.excel_check_SYSRS
EXCEL_CHECK_CLHLR := xlsx/.excel_check_CLHLR
EXCEL_CHECK_HWHLR := xlsx/.excel_check_HWHLR
EXCEL_CHECK_MEHLR := xlsx/.excel_check_MEHLR
EXCEL_CHECK_SWHLR := xlsx/.excel_check_SWHLR
# OS-specific paths (detected automatically from the system Python)
PLATFORM := $(shell python -c 'import sys; print(sys.platform)')
ifeq ($(OS),Windows_NT)
SYS_PYTHON := C:\\Python33\\python.exe
SYS_VIRTUALENV := C:\\Python33\\Scripts\\virtualenv.exe
BIN := $(ENV)/Scripts
OPEN := cmd /c start
FIND := C:\\cygwin\\bin\\find.exe
# https://bugs.launchpad.net/virtualenv/+bug/449537
export TCL_LIBRARY=C:\\Python33\\tcl\\tcl8.5
else
SYS_PYTHON := python3
SYS_VIRTUALENV := virtualenv
BIN := $(ENV)/bin
ifneq ($(findstring cygwin, $(PLATFORM)), )
OPEN := cygstart
FIND := find
else
OPEN := open
FIND := find
endif
endif
# virtualenv executables
PYTHON := $(BIN)/python
PIP := $(BIN)/pip
EASY_INSTALL := $(BIN)/easy_install
RST2HTML := $(PYTHON) $(BIN)/rst2html.py
PDOC := $(PYTHON) $(BIN)/pdoc
DOORSTOP := $(BIN)/doorstop
VERSION := $(shell python __version__.py)
BRANCH := $(shell git rev-parse --symbolic-full-name --abbrev-ref HEAD)
HASH := $(shell git rev-parse HEAD)
HASH8 := $(shell git rev-parse --short=8 HEAD)
# Main Targets ###############################################################
.PHONY: all
all: depends reqcheck doc $(ALL)
$(ALL):
touch $(ALL) # flag to indicate all setup steps were successful
.PHONY: ci
ci: reqcheck live
# Development Installation ###################################################
.PHONY: env
env: $(PIP)
$(PIP):
$(SYS_VIRTUALENV) --python $(SYS_PYTHON) $(ENV)
.PHONY: depends
depends: .depends-ci .depends-dev
.PHONY: .depends-ci
.depends-ci: env Makefile $(DEPENDS_CI)
$(DEPENDS_CI): Makefile
- $(PIP) uninstall doorstop --yes
#=======================
# install released
# $(PIP) install --upgrade doorstop
#=======================
# install master-release
# $(PIP) install https://github.com/jacebrowning/doorstop/archive/master.zip
#=======================
# install master-dev
$(PIP) install https://github.com/jacebrowning/doorstop/archive/develop.zip
#=======================
# install test-hash
# $(PIP) install https://github.com/jacebrowning/doorstop/archive/f5ee2b9dc1e3bb4483d9b582a86842b227074a81.zip
#=======================
touch $(DEPENDS_CI) # flag to indicate dependencies are installed
.PHONY: .depends-dev
.depends-dev: env Makefile $(DEPENDS_DEV)
$(DEPENDS_DEV): Makefile
$(PIP) install --upgrade docutils
touch $(DEPENDS_DEV) # flag to indicate dependencies are installed
# Documentation ##############################################################
.PHONY: specs
specs: .depends-ci docs/html/index.html
docs/html/index.html: $(shell $(FIND) specs -name '*.yml')
rm -rf docs/html
$(DOORSTOP) publish all docs/html --no-body-levels
.PHONY: readme
readme: .depends-dev docs/README-github.html docs/README-pypi.html
docs/README-github.html: README.md
pandoc -f markdown_github -t html -o docs/README-github.html README.md
docs/README-pypi.html: README.rst
$(RST2HTML) README.rst docs/README-pypi.html
README.rst: README.md
pandoc -f markdown_github -t rst -o README.rst README.md
.PHONY: doc
doc: specs readme
.PHONY: read
read: doc
$(OPEN) docs/README-github.html
$(OPEN) docs/html/index.html
# Static Analysis ############################################################
.PHONY: reqcheck
reqcheck: doorstop .git-no-changes
.PHONY: doorstop
doorstop: .depends-ci
# ====================================
# Implement during initial development ... displays WARNING's
$(DOORSTOP) --no-level-check
# ====================================
# Implement during maintenance and formal change control ... WARNING's cause ERROR's
# $(DOORSTOP) --no-level-check --error-all
# Worker Scripts #############################################################
.PHONY: excel-export
excel-export: .depends-ci $(SPECS_CHECK_FL) $(SPECS_CHECK_SYSRS) $(SPECS_CHECK_CLHLR) $(SPECS_CHECK_HWHLR) $(SPECS_CHECK_MEHLR) $(SPECS_CHECK_SWHLR)
$(SPECS_CHECK_FL): $(shell $(FIND) specs/FeatureList -name '*.yml')
$(DOORSTOP) export FL xlsx/FL.xlsx --xlsx
touch $(SPECS_CHECK_FL)
touch $(EXCEL_CHECK_FL)
$(SPECS_CHECK_SYSRS): $(shell $(FIND) specs/SYSRS -name '*.yml')
$(DOORSTOP) export SYSRS xlsx/SYSRS.xlsx --xlsx
touch $(SPECS_CHECK_SYSRS)
touch $(EXCEL_CHECK_SYSRS)
$(SPECS_CHECK_CLHLR): $(shell $(FIND) specs/CLRS -name '*.yml')
$(DOORSTOP) export CLHLR xlsx/CLHLR.xlsx --xlsx
touch $(SPECS_CHECK_CLHLR)
touch $(EXCEL_CHECK_CLHLR)
$(SPECS_CHECK_HWHLR): $(shell $(FIND) specs/HWRS -name '*.yml')
$(DOORSTOP) export HWHLR xlsx/HWHLR.xlsx --xlsx
touch $(SPECS_CHECK_HWHLR)
touch $(EXCEL_CHECK_HWHLR)
$(SPECS_CHECK_MEHLR): $(shell $(FIND) specs/MERS -name '*.yml')
$(DOORSTOP) export MEHLR xlsx/MEHLR.xlsx --xlsx
touch $(SPECS_CHECK_MEHLR)
touch $(EXCEL_CHECK_MEHLR)
$(SPECS_CHECK_SWHLR): $(shell $(FIND) specs/SWRS -name '*.yml')
$(DOORSTOP) export SWHLR xlsx/SWHLR.xlsx --xlsx
touch $(SPECS_CHECK_SWHLR)
touch $(EXCEL_CHECK_SWHLR)
.PHONY: excel-import
excel-import: .depends-ci $(EXCEL_CHECK_FL) $(EXCEL_CHECK_SYSRS) $(EXCEL_CHECK_CLHLR) $(EXCEL_CHECK_HWHLR) $(EXCEL_CHECK_MEHLR) $(EXCEL_CHECK_SWHLR)
$(EXCEL_CHECK_FL): xlsx/FL.xlsx
$(DOORSTOP) import xlsx/FL.xlsx FL
touch $(EXCEL_CHECK_FL)
$(EXCEL_CHECK_SYSRS): xlsx/SYSRS.xlsx
$(DOORSTOP) import xlsx/SYSRS.xlsx SYSRS
touch $(EXCEL_CHECK_SYSRS)
$(EXCEL_CHECK_CLHLR): xlsx/CLHLR.xlsx
$(DOORSTOP) import xlsx/CLHLR.xlsx CLHLR
touch $(EXCEL_CHECK_CLHLR)
$(EXCEL_CHECK_HWHLR): xlsx/HWHLR.xlsx
$(DOORSTOP) import xlsx/HWHLR.xlsx HWHLR
touch $(EXCEL_CHECK_HWHLR)
$(EXCEL_CHECK_MEHLR): xlsx/MEHLR.xlsx
$(DOORSTOP) import xlsx/MEHLR.xlsx MEHLR
touch $(EXCEL_CHECK_MEHLR)
$(EXCEL_CHECK_SWHLR): xlsx/SWHLR.xlsx
$(DOORSTOP) import xlsx/SWHLR.xlsx SWHLR
touch $(EXCEL_CHECK_SWHLR)
# Testing ####################################################################
# Cleanup ####################################################################
.PHONY: clean
clean: .clean-doc .clean-zips
rm -rf $(ALL)
.PHONY: clean-all
clean-all: clean .clean-env
.PHONY: .clean-env
.clean-env:
rm -rf $(ENV)
.PHONY: .clean-doc
.clean-doc:
rm -rf docs README.rst specs/.specs_check* xlsx
.PHONY: .clean-zips
.clean-zips:
rm -rf zips
# Release ####################################################################
.PHONY: .prj_dir-exists
.prj_dir-exists:
@if [ -d "$(PRJ_DIR)" ]; \
then \
echo Project Directory exists...; \
else \
echo ERROR: Project Directory does NOT exists!; \
exit -1; \
fi;
.PHONY: .git-no-changes
.git-no-changes:
@if git diff-index --name-status --exit-code HEAD; \
then \
echo Git working copy is clean...; \
else \
echo ; \
echo ERROR: Git working copy is dirty!; \
echo Commit your changes and try again.; \
exit -1; \
fi;
.PHONY: live
live: .prj_dir-exists .git-no-changes reqcheck excel-export doc
#=========================
# Shared Project Directory
rm -fr $(PRJ_DIR)/tmp-docs-$(BRANCH)
mkdir $(PRJ_DIR)/tmp-docs-$(BRANCH)
mkdir $(PRJ_DIR)/tmp-docs-$(BRANCH)/xlsx
cp -f xlsx/*.xlsx $(PRJ_DIR)/tmp-docs-$(BRANCH)/xlsx
cp -fr docs $(PRJ_DIR)/tmp-docs-$(BRANCH)
cp -fr tests $(PRJ_DIR)/tmp-docs-$(BRANCH)
cp -fr design $(PRJ_DIR)/tmp-docs-$(BRANCH)
cp -fr reviews $(PRJ_DIR)/tmp-docs-$(BRANCH)
touch $(PRJ_DIR)/tmp-docs-$(BRANCH)/$(HASH).hash
rm -fr $(PRJ_DIR)/$(BRANCH)
mkdir -p $(PRJ_DIR)/$(BRANCH)
mv $(PRJ_DIR)/tmp-docs-$(BRANCH)/* $(PRJ_DIR)/$(BRANCH)
rm -fr $(PRJ_DIR)/tmp-docs-$(BRANCH)
#=========================
# Google-Drive/Dropbox Directory
# mkdir -p $(PRJ_DIR)/$(BRANCH)/Specs
# mkdir -p $(PRJ_DIR)/$(BRANCH)/Tests
# mkdir -p $(PRJ_DIR)/$(BRANCH)/Design
# mkdir -p $(PRJ_DIR)/$(BRANCH)/Reviews
# rm -f $(PRJ_DIR)/$(BRANCH)/*.hash
# cp -fr docs/* $(PRJ_DIR)/$(BRANCH)/Specs
# cp -f xlsx/*.xlsx $(PRJ_DIR)/$(BRANCH)/Specs
# cp -fr tests/* $(PRJ_DIR)/$(BRANCH)/Tests
# cp -fr design/* $(PRJ_DIR)/$(BRANCH)/Design
# cp -fr reviews/* $(PRJ_DIR)/$(BRANCH)/Reviews
# touch $(PRJ_DIR)/$(BRANCH)/$(HASH).hash
.PHONY: zips
zips: .git-no-changes reqcheck excel-export doc
mkdir -p zips
zip -rv zips/$(PRJ_NAME)-Specs-$(BRANCH)-$(VERSION).zip docs -i *.html
zip -v zips/$(PRJ_NAME)-Specs-$(BRANCH)-$(VERSION).zip xlsx/* -i *.xlsx
zip -rv zips/$(PRJ_NAME)-Design-$(BRANCH)-$(VERSION).zip design
zip -rv zips/$(PRJ_NAME)-Tests-$(BRANCH)-$(VERSION).zip tests
zip -rv zips/$(PRJ_NAME)-Reviews-$(BRANCH)-$(VERSION).zip reviews
.PHONY: archive
archive: .git-no-changes
mkdir -p zips
git archive --format zip --output zips/$(PRJ_NAME)-Repo-$(BRANCH)-$(VERSION)-$(HASH8).zip $(BRANCH)
.PHONY: release
release: zips archive
git tag -a $(VERSION) -m '"Release of version $(VERSION)"'
git push --tags
# System Installation ########################################################