-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLUCKFILE.py
98 lines (76 loc) · 2.34 KB
/
LUCKFILE.py
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
# PREFIX = "/usr/local"
PREFIX = '~/.local'
DESTDIR= ""
from luck.shorts import RNS,DNS,LSC,TSSR, DC
from luck.types import NoCacheRule as NCR
RULE=TSSR
ns = RNS()
### always use NCR for aliasing
NCR.M(ns, 'all', 'build install')
### alias
NCR.M(ns, 'build','./bin/luckmake ./bin/luck')
_ = '''
- If you run "clean" first, then "build", then "install", the install would not happen
- If you run "clean" first, then "install", luckmake will do "build" then "install"
- this is because "build" is marked runned is the first run.
- it's important to select NCR / TSSR carefully.
- use NCR when the output cannot be cached. This is true for any command-like rule
- use TSSR or other stamped rule when the output is one or more files.
'''
### use LSC for bash command, f-string for string-completion
NCR.MWF(ns, 'install','build',
'''
install -d {DESTDIR}{PREFIX}/bin/
install -m 755 ./bin/luckmake {DESTDIR}{PREFIX}/bin/
install -m 755 ./bin/luck {DESTDIR}{PREFIX}/bin/
''')
luck_src = 'luck/**'
RULE.MWF(ns, luck_src)
RULE.MWF(ns, 'foo', luck_src, 'echo foo')
RULE.MWF(ns,'cli.spec')
RULE.MWF(ns, './bin/luckmake ./bin/luck', f'{luck_src} cli.spec',
'''
python3.7 -m PyInstaller cli.spec --distpath ./bin --clean
### this command would produce ./bin/luckmake and ./bin/luck
''')
### specify external root nodes with RULE=TSSR.
RULE.MWF(ns, 'luck/types.py', None)
# RULE.M(ns, 'foo', 'luck/**', lambda c:print('foo'))
### use NCR for commands that should always execute
NCR.MWF(ns, 'error', '', 'echo 1231243231 && false')
NCR.MWF(ns, 'pybuild',luck_src, 'python3.7 -m pip install . --user && pytest . && rm bin -rf')
TSSR.MWF(ns,'example-ece264-hw04.dir',None)
NCR.MWF(ns, 'time', 'example-ece264-hw04.dir',
DC('''
cd example-ece264-hw04.dir
unset time
alias time=/usr/bin/time
exec 3<>/dev/null
{
time {
make clean
make testall
} 1>&3 2>&3
time {
luckmake clean
luckmake testall
} 1>&3
time {
pyluckmake clean
pyluckmake testall
} 1>&3
} 2>&1
echo [finish]
exit 0
'''))
NCR.MWF(ns, 'pushf', '', '''proxychains git push -f 2>&1''')
NCR.MWF(ns, 'test.sh', '',
'''
cd example-ece264-hw04.dir/
python3.7 README-example.py build ./hw04
''')
NCR.MWF(ns, 'count-line', '', 'wc example-ece264-hw04.dir/{*E.py,Makefile} -c')
NCR.MWF(ns, 'clean', '','''
rm -rf bin/* build/*
''')
'cat -n test/pointer/Makefile && make -C test/pointer/ result.bar'