-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakedeps.py
59 lines (47 loc) · 1.54 KB
/
makedeps.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
r"""
Script for generating Makefile dependencies.
"""
__all__ = [
]
# ---------------------------------------------------------
from path import *
# ---------------------------------------------------------
def print_dependencies(n):
r"""
Print the Makefile dependencies for size n.
"""
print "PATHS-{n} :=".format(n=n)
for path in iter_path(n):
path_string = ''.join(map(str, path))
print "PATHS-{n} += {path_string}".format(n=n, path_string=path_string)
print "OUTFILES += $(PATHS-{n}:%=output/csf-%.py)".format(n=n)
print "OUTFILES += $(PATHS-{n}:%=output/hess-%.py)".format(n=n)
print "$(PATHS-{n}:%=output/csf-%.py): var/csf-size-{n}".format(n=n)
print "\ttouch $@"
# ---------------------------------------------------------
def doctest():
import doctest
doctest.testmod(verbose=False)
# ---------------------------------------------------------
def argparse():
import argparse
parser = argparse.ArgumentParser(
description='Generate Makefile dependencies for Dyck paths of size n.',
)
parser.add_argument(
'n',
type=int,
choices=range(1, 11),
metavar='n',
help='The size of Dyck path to consider (from 1 to 10).',
)
args = parser.parse_args()
return args.n
# ---------------------------------------------------------
if __name__ == '__main__':
doctest()
n = argparse()
print_dependencies(n)
# ---------------------------------------------------------