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

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

Script for generating link files.

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