1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """
18 ==================
19 Simple make base
20 ==================
21
22 Simple make base.
23 """
24 __author__ = u"Andr\xe9 Malo"
25 __docformat__ = "restructuredtext en"
26
27 import os as _os
28 import sys as _sys
29
30 from _setup import make as _make
31 from _setup import shell as _shell
32
33
35 """ Create a make file """
36 NAME = 'makefile'
37
39 def escape(value):
40 """ Escape for make and shell """
41 return '"%s"' % value.replace(
42 '\\', '\\\\').replace(
43 '"', '\\"').replace(
44 '$', '\\$$')
45 def decorate(line, prefix='# ', width=78, char='~', padding=' '):
46 """ Decorate a line """
47 line = line.center(width - len(prefix))
48 return '%s%s%s%s%s%s' % (
49 prefix,
50 char * (len(line) - len(line.lstrip()) - len(padding)),
51 padding,
52 line.strip(),
53 padding,
54 char * (len(line) - len(line.rstrip()) - len(padding)),
55 )
56
57 python = escape(_sys.executable)
58 script = escape(_sys.argv[0])
59 targets = self.runner.targetinfo()
60 names = []
61 for name, info in targets.items():
62 if not info['hide']:
63 names.append(name)
64 names.sort()
65
66 fp = file(_shell.native('Makefile'), 'w')
67 print >> fp, decorate("Generated Makefile, DO NOT EDIT")
68 print >> fp, decorate("python %s %s" % (
69 _os.path.basename(script), self.NAME
70 ))
71 print >> fp
72 print >> fp, "_default_:"
73 print >> fp, "\t@%s %s" % (python, script)
74 for name in names:
75 print >> fp, "\n"
76 print >> fp, "# %s" % \
77 targets[name]['desc'].splitlines()[0].strip()
78 print >> fp, "%s:" % name
79 print >> fp, "\t@%s %s %s" % (python, script, escape(name))
80 print >> fp
81 print >> fp, ".PHONY: _default_, %s\n\n" % ', '.join(names)
82 fp.close()
83
84
86 """ Clean the mess """
87 NAME = 'clean'
88 _scm, _dist = True, False
89
92
93
95 """ Clean as freshly unpacked dist package """
96 NAME = 'distclean'
97 _scm, _dist = False, True
98
99
101 """ Clean everything """
102 NAME = 'extraclean'
103 _scm, _dist = True, True
104