summaryrefslogtreecommitdiff
path: root/hacks/check_includes
blob: 8a4f901143156e861af264e0c2a6e8e046e4b05a (plain)
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
#!/usr/bin/python

import sys

for a in sys.argv[1:]:
    includes = []
    for line in open(a, 'r'):
        if line.startswith('#include'):
            includes.append(line.strip()[9:])

    std = ['<cstdio>', '<unistd.h>', '<stdexcept>', '<iostream>', '<algorithm>', '<fstream>', '<cstdlib>', '<iomanip>', '<stdint.h>', '<cmath>', '<cassert>', '<cstring>', '<mntent.h>', '<windows.h>', '<shlwapi.h>', '<sys/sysctl.h>', '<mach-o/dyld.h>', '<IOKit/pwr_mgt/IOPMLib.h>', '<sys/types.h>', '<ifaddrs.h>', '<netinet/in.h>', '<arpa/inet.h>', '<cerrno>']

    current_group = 0
    for i in includes:
        if i == '"i18n.h"':
            continue

        if i in std:
            group = 5
        elif i.find("<boost/") != -1:
            group = 4
        elif i.find("<libxml++/") != -1 or i == '<glib.h>':
            group = 3
        elif i.find("<libcxml/") != -1 or i.find("<dcp/") != -1:
            group = 2
        elif i.find("\"wx/") != -1:
            group = 1
        else:
            group = 0

        if group < current_group:
            print '%s: first wrong order is %s' % (a, i)
            break

        current_group = group