source: icXML/icXML-devel/scripts/gen_icxerces_links.py @ 2776

Last change on this file since 2776 was 2776, checked in by cameron, 6 years ago

Script to modify #includes to use root-relative paths

File size: 1.3 KB
Line 
1#
2# gen_icxerces_links.py
3# ICXML overrides.
4#
5# Licensed under Open Source License, 3.0.
6#
7import sys, re, os, shutil, optparse
8
9icxml_override_dir = "icxercesc"
10
11overridable = re.compile("\.(h|c|hpp|cpp|hxx|cxx)$")
12
13def read_overrides(root, subpath):
14        overrides = []
15        path = os.path.join(root, subpath)
16        for f in os.listdir(path):
17                newsubpath = os.path.join(subpath, f)
18                newpath = os.path.join(path, f)
19                if os.path.isdir(newpath):
20                        overrides += read_overrides(root, newsubpath)
21                else:
22                        if overridable.search(newpath):
23                                overrides.append(newsubpath)
24        return overrides
25
26def make_xercesc_to_icxercesc_include_link_file(path):
27        outdata = "#include <icxercesc/%s>\n" % path
28        outfile = open('xercesc/' + path, 'w')
29        outfile.write(outdata)
30        outfile.close()
31
32               
33if __name__ == '__main__':
34
35        option_parser = optparse.OptionParser(usage='python %prog [options] <path>', version='1.0')
36        options, args = option_parser.parse_args(sys.argv[1:])
37        if len(args) != 0:
38                option_parser.print_usage()
39                sys.exit()
40       
41        if not os.path.exists(icxml_override_dir):
42          print "Expecting icXML overrides directory: %s.  Please cd to src." % icxml_override_dir
43          exit()
44         
45        override_set = read_overrides(icxml_override_dir, '')
46       
47        for p in override_set:
48                make_xercesc_to_icxercesc_include_link_file(p)
49       
50
Note: See TracBrowser for help on using the repository browser.