blob: 88eaa2eaa92746184ba3f3c9348696f7adfbec49 [file] [log] [blame]
Ebrahim Byagowi7250ade2020-05-29 12:34:30 +04301#!/usr/bin/env python3
2
3import sys, os, re
4
Ebrahim Byagowia07672d2020-07-04 14:12:55 +04305os.chdir (os.getenv ('srcdir', os.path.dirname (__file__)))
Ebrahim Byagowi7250ade2020-05-29 12:34:30 +04306
Ebrahim Byagowia07672d2020-07-04 14:12:55 +04307HBHEADERS = [os.path.basename (x) for x in os.getenv ('HBHEADERS', '').split ()] or \
Ebrahim Byagowi7250ade2020-05-29 12:34:30 +04308 [x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith ('.h')]
Ebrahim Byagowia07672d2020-07-04 14:12:55 +04309HBSOURCES = [os.path.basename (x) for x in os.getenv ('HBSOURCES', '').split ()] or \
Ebrahim Byagowi7250ade2020-05-29 12:34:30 +043010 [x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith (('.cc', '.hh'))]
11
12stat = 0
13
14print ('Checking that public header files #include "hb-common.h" or "hb.h" first (or none)')
15for x in HBHEADERS:
16 if x == 'hb.h' or x == 'hb-common.h': continue
17 with open (x, 'r', encoding='utf-8') as f: content = f.read ()
18 first = re.findall (r'#.*include.*', content)[0]
19 if first not in ['#include "hb.h"', '#include "hb-common.h"']:
20 print ('failure on %s' % x)
21 stat = 1
22
23print ('Checking that source files #include a private header first (or none)')
24for x in HBSOURCES:
25 with open (x, 'r', encoding='utf-8') as f: content = f.read ()
26 includes = re.findall (r'#.*include.*', content)
27 if includes:
28 if not len (re.findall (r'"hb.*\.hh"', includes[0])):
29 print ('failure on %s' % x)
30 stat = 1
31
32print ('Checking that there is no #include <hb-*.h>')
33for x in HBHEADERS + HBSOURCES:
34 with open (x, 'r', encoding='utf-8') as f: content = f.read ()
35 if re.findall ('#.*include.*<.*hb', content):
36 print ('failure on %s' % x)
37 stat = 1
38
39sys.exit (stat)