File: warningstester_create_uber_header.py

package info (click to toggle)
libthrust 1.17.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 10,900 kB
  • sloc: ansic: 29,519; cpp: 23,989; python: 1,421; sh: 811; perl: 460; makefile: 112
file content (54 lines) | stat: -rw-r--r-- 1,615 bytes parent folder | download | duplicates (4)
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
'''
Helper script for creating a header file that includes all of Thrust's
public headers.  This is useful for instance, to quickly check that
all the thrust headers obey proper syntax or are warning free.

This script simply outputs a list of C-style #include's to the standard
output--this should be redirected to a header file by the caller.
'''

import sys
import os
import re
from stat import *

thrustdir = sys.argv[1]

def find_headers(base_dir, rel_dir, exclude = ['\B']):
    '''
    Recursively find all *.h files inside base_dir/rel_dir,
    except any that match the exclude regexp list
    '''
    assert(type(exclude) == list)
    full_dir = base_dir + '/' + rel_dir
    result = []
    for f in os.listdir(full_dir):
        rel_file = rel_dir + '/' + f
        for e in exclude:
            if re.match(e, rel_file):
                break
        else:
            if f.endswith('.h'):
                result.append(rel_file)
            elif S_ISDIR(os.stat(full_dir + '/' + f).st_mode):
                result.extend(find_headers(base_dir, rel_file, exclude))
    return result

print('/* File is generated by ' + sys.argv[0] + ' */')

exclude_re = ['.*/detail$',
              'thrust/iterator',
              'thrust/random',
              'thrust/system/tbb']
headers = find_headers(thrustdir, 'thrust', exclude_re)

if len(headers) == 0:
    print('#error no include files found\n')

print('#define THRUST_CPP11_REQUIRED_NO_ERROR')
print('#define THRUST_CPP14_REQUIRED_NO_ERROR')
print('#define THRUST_MODERN_GCC_REQUIRED_NO_ERROR')
for h in headers:
    print('#include <' + h + '>')

exit()