-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMykefile
351 lines (296 loc) · 10.6 KB
/
Mykefile
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
:import ARCH
# full path to the base python executable from a venv
:import PYTHON_EXE
PREFIX = /opt/css
weblocal = $(HOME)/@/ezos/html/cs/css
##hg_repos = sr.ht-css ssh://janus-wg/hg/css ssh://borg-wg/hg/css
hg_repos = sr.ht-css $${CSS_HG_REPOS}
git_repos = bitbucket-css github-css
www_sr_ht = https://hg.sr.ht/~cameron-simpson/css/log
www_bitbucket = https://bitbucket.org/cameron_simpson/css/commits
www_github = https://github.com/cameron-simpson/css
title = Cameron Simpson's Scripts
# used for pushing live code direct
RSYNC_TARGET_PYTHON_ENVVAR = RSYNC_TARGET_PYTHON
target = bin
trace = set-x
base_python = $(PYTHON_EXE)
base_pip = $(PYTHON_EXE) -m pip
# this is parallels $VIRTUAL_ENV in .env.sh
venv_dir = $(TMPDIR)/venv--$(.F)--$(ARCH)
venv_requirements = $./venv-requirements.txt
venv_python = $(venv_dir)/bin/python
venv_pip = $(venv_python) -m pip
uv = env 'VIRTUAL_ENV=$(venv_dir)' $(base_python) -m uv
srcdev = export 'ENV_DEV_DIR=$.'; . "$ENV_DEV_DIR/.env.sh"
dev = env-dev -d $. -x
rewrite = rewriteif -0 -v
JAVADIR = $(ETCDIR)/www/java/classes
java = $(localjava) $(subjava)
localjava= $('*.java' G)
subjava = $('cs/*.java' G?)
classes = $((java P)).class
subclasses=$((subjava P)).class
html = $('*.html' G)
htdocs = $(HOME)/@/ezos/html/cs
htmandir = $(htdocs)/css/manuals
pmsets = lib/perl/cs
pmset(set) = $('$(set)/*.pm' EG?) \
$('$(set)/*/*.pm' EG?) \
$('$(set)/*/*/*.pm' EG?)
pmsetmans(set) = $(MANDIR)/man3/$(('$(pmset($(set)))' Es[/]P :|/|::|)).3
pmsethtml(set) = $(htmandir)/$(('$(pmset($(set)))' Es[/]P :|/|::|)).3.html
pmmans = $('$$(pmsetmans($((pmsets))))' EE)
pmhtml = $('$$(pmsethtml($((pmsets))))' EE)
podman(podf) = $(MANDIR)/man$(podf FPS)/$(podf FP)
podmans = $('$$(podman($(("man/*.pod" G))))' EE)
pmFromMan(manf) = lib/$(manf FP :|::|/|).pm
pmFromHtml(html) = lib/$(html FPP :|::|/|).pm
podFromMan(manf) = man/$(manf F).pod
## pymanmods = cs.vt
## pymansrcs = $( "$((pymanmods :|\.|/|))/*.?.md" EG )
## pymanmoddirs = $(pymansrcs DU)
## pymandst(src) = $(MANDIR)/man$(src FPS)/$(src FP)
## pymandsts = $( '$$(pymandst("$((pymansrcs))"))' EE )
## pymansrc(dst) = $
##
## _t:
## echo $(pymansrcs)
## echo $(pymanmoddirs)
## echo $(pymandsts)
subdirs = $('*/.' GD)
allscripts = $('bin/*' GF !/\./ +"bin/rc.mobile" F)
scriptmandir = $(MANDIR)/man1
scriptmans = $(scriptmandir)/$((allscripts)).1
scriptfromman(manf) = $(manf FP)
pymdmans= $("lib/python/cs/*.[1-9].md" G?) \
$("lib/python/cs/*/*.[1-9].md" G?) \
$("lib/python/cs/*/*/*.[1-9].md" G?)
md2man = md2man-roff
rsync = rsync -iJOt --exclude='.*.swp' --exclude='*.pyc' --exclude='__pycache__'
_help:
@echo '_deploy - deploy current release to /opt/css'
@echo '_freshmeat - announce current release to freshmeat'
@echo '_home - deploy scripts to ~/bin etc'
@echo '_pending - report unreleased changelog and [M]odified files'
@echo '_pub - push to upstream repos'
@echo '_publish - deploy current release to /opt/css, ezos and tip to bitbucket'
@echo '_publish_ezos - deploy current release to /opt/css, ezos'
@echo '_publish_hg - publish to upstream repos'
@echo '_release - mark tip as new release'
@echo '_remote - rsync the Python tree to $$$(RSYNC_TARGET_PYTHON_ENVVAR)'
@echo '_tarball - make a tarball of the tip'
@echo '_test - do syntax checks and self tests (may set $$MYKE_TEST_PYTHON_MODULES if desired)'
@echo '_test3 - do python 3 syntax checks and self tests'
@echo '_updcss - deploy current tip to /opt/css'
@echo '_venv - make the Python virtual environment based off $(base_python) using $(venv_requirements)'
_setup:
:make _tags _venv
_venv:
set -uex \
[ -d $(venv_dir) ] || { \
$(base_python) -m ensurepip \
$(base_pip) install -U pip wheel build uv \
$(uv) venv --python $(base_python) --seed $(venv_dir) \
}
uv_reqs=$$TMPDIR/reqs-uv-$$$$.txt \
if grep -i '^ *[a-z]' $(venv_requirements) >"$$uv_reqs" \
then $(trace) $(uv) pip install -p '$(venv_python)' -r "$$uv_reqs" \
fi
pip_reqs=$$TMPDIR/reqs-pip-$$$$.txt \
if grep -i '^ *[^a-z#]' $(venv_requirements) >"$$pip_reqs" \
then $(trace) $(venv_pip) install -r "$$pip_reqs" \
fi
_tags: tags
tags: $("cs/*.py cs/*/*.py cs/*/*/*.py" G)
ctags-update -o '$@' $?
_updcss:
./bin-cs/updcss
_testhost:
set -ue \
hosts=$$(hostlist "$$TESTHOST") \
for testhost in $$hosts \
do \
for basedir in . $(PREFIX) \
do \
target=$$testhost:$$basedir \
pfx "$$target/bin" set-x \\
$(rsync) -a "bin/" "$$target/bin/" & \
pfx "$$target/lib/python/cs" set-x \\
$(rsync) -a '--include=*/' '--include=*.py' '--exclude=*' \\
lib/python/cs/ "$$target/lib/python/cs/" & \
done \
done \
wait
_tarball:
set -uex \
rev=tip \
today=$$(daycode | tr -d -) \
tardir=css-$$rev-$$today \
tarball=$$tardir.tar.gz \
[ -d "$$tardir/." ] || mkdir "$$tardir" \
./bin-cs/updcss -r "$$rev" "$$tardir" \
tar czf "$$tarball" "$$tardir"
_test:
find lib/python -type f -name '*.py[co]' -ls -delete
set -x; ./bin-cs/selftest -v --python lib/python cs $$MYKE_TEST_PYTHON_MODULES
_test3:
find lib/python -type f -name '*.py[co]' -ls -delete
set -x; ./bin-cs/selftest -v --state state3 --pycmd python3 --python lib/python cs $$MYKE_TEST_PYTHON_MODULES
deploy_dir(targetdir, base, includes) = \
( \
set -ue \
echo 'update $(targetdir)/$(base) ...' \
[ -d $(targetdir)/$(base) ] || ( \
set -x; mkdir -p $(targetdir)/$(base) \
) \
pfx $(targetdir)/$(base) \\
$(rsync) -a --delete $(base)/. $(targetdir)/$(base)/. \
)
deploy(targetdir) = \
( \
set -ue \
tmpdir=$$TMPDIR/css-deploy-$$$$ \
mkdir "$$tmpdir" \
( set -ue \
hg archive -t files -r tip "$$tmpdir" \
hg-apply-manifest-dates -r "tip" "$$tmpdir" \
cd "$$tmpdir" \
$(deploy_dir($(targetdir), bin, synonyms)) \
$(deploy_dir($(targetdir), bin-cs, synonyms)) \
$(deploy_dir($(targetdir), bin-darwin, synonyms)) \
$(deploy_dir($(targetdir), lib/js/cs, "")) \
$(deploy_dir($(targetdir), lib/perl/cs, "")) \
$(deploy_dir($(targetdir), lib/python/cs, "")) \
) \
xit=$$? \
rm -rf "$$tmpdir" \
exit $$xit \
)
_optcss:
@$(deploy(/opt/css))
_home:
@$(deploy($(HOME)))
_push:
set -ue; hg push "ssh://$$HG_PUSH_HOST/$$HG_PUSH_PATH"
set -ue; incd "$$HG_PUSH_HOST:$$HG_PUSH_PATH" hg up
_remote:
set -uex; rsync -ia --include=*/ --include=*.py --exclude=* cs/ "$$$(RSYNC_TARGET_PYTHON_ENVVAR)/"
bin_suffixes = cs darwin
_bin_$((bin_suffixes)):
@sfx=$(@S[_]) \
base=bin-$$sfx \
target=$(HOME)/$$base \
if [ -d "$$target/" ] \
then \
if [ -d "$$base/" ] \
then \
echo "update $$target ..." \
skip=$$( hg status | sed -n 's:^? '"$$base"'/\(.*\):--exclude=/\1:p' ) \
pfx "$$base" hg-shelved $(rsync) -a --delete $$skip "$$base/" "$$target/" \
else \
echo "WARNING: no $$base" >&2 \
fi \
else \
echo "WARNING: no $$target" >&2 \
fi
# squid_redirect
_all: 1INDEX.txt _submakes _man
_deploy:
:make _home
OPTCSS=$(PREFIX) updcss
_publish _pub:
:make _publish_hg _publish_git
#:make _publish_ezos
_publish_ezos:
:make _deploy
syncezos
_publish_git:
for repo in $(git_repos) \
do pfx "$$repo" hg-gitup -a -f -x "$$repo" \
done
@echo 'changes visible at $(www_bitbucket)/branch/'"$$(vcs branch)"
@echo 'code visible at $(www_github)'
_publish_hg:
for repo in $(hg_repos) \
do pfx "$$repo" hg push --new-branch -r tip "$$repo" & \
done \
wait
@echo 'changes visible at $(www_sr_ht)'
# mark the tip as a new release
_release:
:make _test
:make _release_force
_release_force:
cs-release add
_pending:
cs-release log
cs-release status
hg status | grep '^[^?]'; :
_freshmeat:
cs-release freshmeat-submit
CHANGELOG.txt: _always
>>$@; $(rewrite) $@ hglog
CHANGELOG.html: _always
>>$@; $(rewrite) $@ cvslog2html -O .
1INDEX.txt: $(allscripts)
@echo make $@ \
( cat INSTALL; mkscriptndx `ls -d $(allscripts) | sort` ) >$@
_man:
:make _podmans
:make _pmmans
:make _scriptmans
_podmans: $(podmans)
$(podmans): $(podFromMan($@))
:make $(@D)/.
>>$@; $(rewrite) $@ pod2man --center="$(title): $?" $?
chmod 644 $@
set -uex; htman=$(htmandir)/$(@F).html \
>>$$htman; $(rewrite) $$htman pod2html --title="$(title): $?" $? \
chmod 644 $$htman
_pmmans: $(pmmans)
$(pmmans): $(pmFromMan($@))
:make $(@D)/.
@if grep '^=head1 NAME' <$? >/dev/null \
then \
>>$@; $(rewrite) $@ pod2man --center="$(title): $?" $? \
chmod 644 $@ \
htman=$(htmandir)/$(@F).html \
>>$$htman; $(rewrite) $$htman pod2html --title="$(title): $?" $? \
chmod 644 $$htman \
else \
: \
fi
_scriptmans:
( cd bin; exec egrep -l '^(# *)?=head1 NAME' $(allscripts) ) \\
| sed 's|.*|$(scriptmandir)/&.1|' \\
| xxargs $(MAKE) MANDIR=$(MANDIR)
$(scriptmandir)/%.1: bin/%
:make $(@D)/.
@htman=$(htmandir)/$(@F).html \
case "`sed 1q <$?`" in \
'#!/usr/bin/perl'*) \
grep '^=head1 NAME' <$? >/dev/null || exit 0 \
>>$@; $(rewrite) $@ pod2man --release=CSS --section=1cs --center="$(title)" $? \
>>$$htman; $(rewrite) $$htman pod2html --title="$(title): $?" $? \
;; \
*) \
grep '^# *=head1 NAME' <$? >/dev/null || exit 0 \
tmp=$${TMPDIR:-/tmp}/$(@F).$$ \
unhashpod <$? >$$tmp \
>>$@; $(rewrite) $@ pod2man --section=1cs --center="$(title)" $$tmp \
>>$$htman; $(rewrite) $$htman pod2html --title="$(title): $?" $$tmp \
rm $$tmp \
;; \
esac \
chmod 644 $@ $$htman
noads = $(HOME)/@/adzapper.sf/html/rc/patterns
squid_redirect: $(noads)
@cd $(?DD) || exit 1 \
pwd; \
exec $(MAKE) _scripts
%.class: %.java %.class-prereqs : $(("%.class-prereqs" G?<P)).class
:make $(("$@-prereqs" E<P)).class
$(JAVAC) $(@P).java
%.class-prereqs: %.java
javaprereqs $(@P).java >$@