Merge pull request #169 from MaximeChretien/makefile-index

Makefile CONFIG_ index
This commit is contained in:
Michael Opdenacker 2020-06-15 14:49:35 +02:00 committed by GitHub
commit c6083a84b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 30 deletions

View file

@ -2,4 +2,3 @@
exec(open('kconfig.py').read())
exec(open('kconfigidents.py').read())
exec(open('makefilekconfig.py').read())

View file

@ -1,22 +0,0 @@
# Filters for Kconfig used in Makefiles
makefilekconfig = []
def keep_makefilekconfig(m):
makefilekconfig.append(m.group(1))
return '$(__KEEPMAKEFILEKCONFIG__' + encode_number(len(makefilekconfig)) + ')'
def replace_makefilekconfig(m):
i = makefilekconfig[decode_number(m.group(1)) - 1]
return '<a href="'+version+'/K/ident/'+i+'">'+i+'</a>'
makefilekconfig_filters = {
'case': 'filename',
'match': {'Makefile'},
'prerex': '\$\((CONFIG_\w+)\)',
'prefunc': keep_makefilekconfig,
'postrex': '__KEEPMAKEFILEKCONFIG__([A-J]+)',
'postfunc': replace_makefilekconfig
}
filters.append(makefilekconfig_filters)

View file

@ -11,7 +11,7 @@ def replace_makefileo(m):
w = makefileo[decode_number(m.group(1)) - 1]
dir_name = os.path.dirname(path)
if dir_name != '/':
dir_name += '/'
@ -20,7 +20,7 @@ def replace_makefileo(m):
makefileo_filters = {
'case': 'filename',
'match': {'Makefile'},
'prerex': '(?<=\s)([-\w/]+)\.o(?!\w)',
'prerex': '(?<=\s)([-\w/]+)\.o(?!\w)(?! :?=)',
'prefunc': keep_makefileo,
'postrex': '__KEEPMAKEFILEO__([A-J]+)\.o',
'postfunc': replace_makefileo

5
lib.py
View file

@ -207,6 +207,8 @@ def getFileFamily(filename):
# Some files are named like Kconfig-nommu so we only check the first 7 letters
# We also exclude documentation files that can be named kconfig
return 'K' # Kconfig files
elif name.lower()[:8] in ['makefile'] and not ext.lower() in ['.rst']:
return 'M' # Makefiles
else :
return None
@ -215,7 +217,8 @@ def getFileFamily(filename):
compatibility_list = {
'C' : ['C', 'K'],
'K' : ['K'],
'D' : ['D', 'CM']
'D' : ['D', 'CM'],
'M' : ['K']
}
# Check if families are compatible

View file

@ -231,7 +231,7 @@ class UpdateDefs(Thread):
filename = db.file.get(idx)
family = lib.getFileFamily(filename);
if family == None: continue
if family in [None, 'M']: continue
lines = scriptLines('parse-defs', hash, filename, family)
@ -312,7 +312,9 @@ class UpdateRefs(Thread):
if even:
tok = prefix + tok
if db.defs.exists(tok):
if (db.defs.exists(tok) and
(family != 'M' or tok.startswith(b'CONFIG_'))):
# We only index CONFIG_??? in makefiles
if tok in idents:
idents[tok] += ',' + str(line_num)
else:
@ -374,7 +376,7 @@ class UpdateDocs(Thread):
filename = db.file.get(idx)
family = lib.getFileFamily(filename)
if family == None: continue
if family in [None, 'M']: continue
lines = scriptLines('parse-docs', hash, filename)
with docs_lock:
@ -435,7 +437,7 @@ class UpdateComps(Thread):
filename = db.file.get(idx)
family = lib.getFileFamily(filename)
if family in [None, 'K']: continue
if family in [None, 'K', 'M']: continue
lines = compatibles_parser.run(scriptLines('get-blob', hash), family)
comps = {}