Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 60 lines (46 sloc) 1.607 kB
4738ee4 @phooji ocamldebug directory script
phooji authored
1 #! /bin/env python
2
3 """Print the "directory blah" statements necessary for ocamldebug
4 to find all of the source files under a given root directory.
5 We could feasibly just generate the commandline ('-I') parameters,
6 but if we have many directories, we might hit the max command
7 length for the shell.
8
9 One relatively pain-free way to use this is to add something
10 like the following to your .emacs:
11
12 (global-set-key "\C-ci"
13 (lambda () (interactive)
14 (kill-new (shell-command-to-string
15 "/path/to/get_includes.py /path/to/pfff"))))
16 """
17
18 import os
19 import sys
20
21 def checkargs():
93d15af @phooji get_includes.py output for ocaml toplevel
phooji authored
22 usage = "Usage: get_includes.py debug|toplevel root_dir\n"
23 if len(sys.argv) <> 3:
4738ee4 @phooji ocamldebug directory script
phooji authored
24 print usage
93d15af @phooji get_includes.py output for ocaml toplevel
phooji authored
25 exit(-1)
26
27 if sys.argv[1] not in [ "debug", "toplevel" ]:
28 print usage
29 exit(-1)
4738ee4 @phooji ocamldebug directory script
phooji authored
30
31 def removenothrow(l, item):
32 """Remove a specified item from a list; don't do anything
33 if the item doesn't exist. """
34 try:
35 l.remove(item)
36 except:
37 pass
38
39
40 def getdirs(rootdir):
41 for root, dirs, files in os.walk(rootdir):
42 # add excludes here as needed
43 removenothrow(dirs, ".git")
44 removenothrow(dirs, "mini_www")
45 removenothrow(dirs, "docs")
46
47 for d in dirs:
48 yield "%s" % (os.path.join(root, d),)
49
50
51 if __name__ == "__main__":
52 checkargs()
93d15af @phooji get_includes.py output for ocaml toplevel
phooji authored
53 mode = sys.argv[1]
54 rootdir = sys.argv[2]
55 if mode == "debug":
56 print "".join(["directory %s\n" % (d,) for d in getdirs(rootdir)])
57 else:
58 print "".join(["#directory \"%s\";;\n" % (d,) for d in getdirs(rootdir)])
4738ee4 @phooji ocamldebug directory script
phooji authored
59
Something went wrong with that request. Please try again.