[reorg] Fix check-* scripts to work with sources files in directories.

This commit is contained in:
Garret Rieger 2022-01-20 14:39:48 -08:00
parent 3ef180db44
commit f577d02f4a
8 changed files with 56 additions and 22 deletions

View File

@ -88,6 +88,10 @@ HB_BASE_sources = \
hb-ot-layout-gdef-table.hh \
hb-ot-layout-gpos-table.hh \
hb-ot-layout-gsub-table.hh \
OT/Layout/GSUB/Common.hh \
OT/Layout/GSUB/SingleSubstFormat1.hh \
OT/Layout/GSUB/SingleSubstFormat2.hh \
OT/Layout/GSUB/SingleSubst.hh \
hb-ot-layout-gsubgpos.hh \
hb-ot-layout-jstf-table.hh \
hb-ot-layout.cc \

View File

@ -1,5 +1,5 @@
#ifndef OT_LAYOUT_GSUB_COMMON
#define OT_LAYOUT_GSUB_COMMON
#ifndef OT_LAYOUT_GSUB_COMMON_HH
#define OT_LAYOUT_GSUB_COMMON_HH
#include "hb-serialize.hh"
@ -17,4 +17,4 @@ static void SingleSubst_serialize (hb_serialize_context_t *c,
}
}
#endif
#endif /* OT_LAYOUT_GSUB_COMMON_HH */

View File

@ -1,5 +1,5 @@
#ifndef OT_LAYOUT_GSUB_SINGLE_SUBST
#define OT_LAYOUT_GSUB_SINGLE_SUBST
#ifndef OT_LAYOUT_GSUB_SINGLESUBST_HH
#define OT_LAYOUT_GSUB_SINGLESUBST_HH
#include "Common.hh"
#include "SingleSubstFormat1.hh"
@ -71,4 +71,4 @@ SingleSubst_serialize (hb_serialize_context_t *c,
}
}
#endif
#endif /* OT_LAYOUT_GSUB_SINGLESUBST_HH */

View File

@ -1,5 +1,5 @@
#ifndef OT_LAYOUT_GSUB_SINGLE_SUBST_FORMAT_1
#define OT_LAYOUT_GSUB_SINGLE_SUBST_FORMAT_1
#ifndef OT_LAYOUT_GSUB_SINGLESUBSTFORMAT1_HH
#define OT_LAYOUT_GSUB_SINGLESUBSTFORMAT1_HH
#include "Common.hh"
#include "hb-ot-layout-gsubgpos.hh"
@ -122,4 +122,4 @@ struct SingleSubstFormat1
}
#endif
#endif /* OT_LAYOUT_GSUB_SINGLESUBSTFORMAT1_HH */

View File

@ -1,5 +1,5 @@
#ifndef OT_LAYOUT_GSUB_SINGLE_SUBST_FORMAT_2
#define OT_LAYOUT_GSUB_SINGLE_SUBST_FORMAT_2
#ifndef OT_LAYOUT_GSUB_SINGLESUBSTFORMAT2_HH
#define OT_LAYOUT_GSUB_SINGLESUBSTFORMAT2_HH
#include "Common.hh"
#include "hb-ot-layout-gsubgpos.hh"
@ -120,4 +120,4 @@ struct SingleSubstFormat2
}
}
#endif
#endif /* OT_LAYOUT_GSUB_SINGLESUBSTFORMAT2_HH */

View File

@ -4,11 +4,19 @@ import sys, os
os.chdir (os.getenv ('srcdir', os.path.dirname (__file__)))
def removeprefix(s, prefix):
if s.startswith(prefix):
return s[len(prefix):]
else:
return s[:]
HBHEADERS = [os.path.basename (x) for x in os.getenv ('HBHEADERS', '').split ()] or \
[x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith ('.h')]
HBSOURCES = [os.path.basename (x) for x in os.getenv ('HBSOURCES', '').split ()] or \
[x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith (('.cc', '.hh'))]
HBSOURCES = [
removeprefix(x, 'src%s' % os.path.sep) for x in os.getenv ('HBSOURCES', '').split ()
] or [
x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith (('.cc', '.hh'))
]
stat = 0
for x in HBHEADERS:

View File

@ -4,19 +4,30 @@ import sys, os, re
os.chdir (os.getenv ('srcdir', os.path.dirname (__file__)))
def removeprefix(s, prefix):
if s.startswith(prefix):
return s[len(prefix):]
else:
return s[:]
HBHEADERS = [os.path.basename (x) for x in os.getenv ('HBHEADERS', '').split ()] or \
[x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith ('.h')]
HBSOURCES = [os.path.basename (x) for x in os.getenv ('HBSOURCES', '').split ()] or \
[x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith (('.cc', '.hh'))]
HBSOURCES = [
removeprefix(x, 'src%s' % os.path.sep) for x in os.getenv ('HBSOURCES', '').split ()
] or [
x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith (('.cc', '.hh'))
]
stat = 0
for x in HBHEADERS + HBSOURCES:
if not x.endswith ('h') or x == 'hb-gobject-structs.h': continue
tag = x.upper ().replace ('.', '_').replace ('-', '_')
tag = x.upper ().replace ('.', '_').replace ('-', '_').replace(os.path.sep, '_').replace('/', '_')
with open (x, 'r', encoding='utf-8') as f: content = f.read ()
if len (re.findall (tag + r'\b', content)) != 3:
print ('Ouch, header file %s does not have correct preprocessor guards' % x)
print ('Ouch, header file %s does not have correct preprocessor guards. Expected: %s' % (x, tag))
stat = 1
sys.exit (stat)

View File

@ -4,10 +4,21 @@ import sys, os, re
os.chdir (os.getenv ('srcdir', os.path.dirname (__file__)))
def removeprefix(s, prefix):
if s.startswith(prefix):
return s[len(prefix):]
else:
return s[:]
HBHEADERS = [os.path.basename (x) for x in os.getenv ('HBHEADERS', '').split ()] or \
[x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith ('.h')]
HBSOURCES = [os.path.basename (x) for x in os.getenv ('HBSOURCES', '').split ()] or \
[x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith (('.cc', '.hh'))]
HBSOURCES = [
removeprefix(x, 'src%s' % os.path.sep) for x in os.getenv ('HBSOURCES', '').split ()
] or [
x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith (('.cc', '.hh'))
]
stat = 0
@ -25,7 +36,7 @@ for x in HBSOURCES:
with open (x, 'r', encoding='utf-8') as f: content = f.read ()
includes = re.findall (r'#.*include.*', content)
if includes:
if not len (re.findall (r'"hb.*\.hh"', includes[0])):
if not len (re.findall (r'".*\.hh"', includes[0])):
print ('failure on %s' % x)
stat = 1