lib.py: mark .mk files as makefiles

OpenSBI uses `.mk` files. The tokenizer does not get ran on files
without a family (sad). Adding this means we index references
inside .mk files, eg:

    # opensbi/lib/utils/i2c/objects.mk
    libsbiutils-objs-$(CONFIG_I2C) += i2c/i2c.o

Also, refactor the getFileFamily():
 - All usage of name/ext do a .lower() on them, move it to the top.
 - Use `x == "A"` checks rather than `x in ["A"]`.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
This commit is contained in:
Théo Lebrun 2025-10-15 11:37:50 +02:00
parent 05da14b295
commit 773e2df1b5

View file

@ -223,16 +223,17 @@ def validFamily(family):
def getFileFamily(filename):
name, ext = os.path.splitext(filename)
name, ext = name.lower(), ext.lower()
if ext.lower() in ['.c', '.cc', '.cpp', '.c++', '.cxx', '.h', '.s'] :
if ext in ['.c', '.cc', '.cpp', '.c++', '.cxx', '.h', '.s'] :
return 'C' # C file family and ASM
elif ext.lower() in ['.dts', '.dtsi'] :
elif ext in ['.dts', '.dtsi'] :
return 'D' # Devicetree files
elif name.lower()[:7] in ['kconfig'] and not ext.lower() in ['.rst']:
elif name[:7] == 'kconfig' and ext != '.rst':
# 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']:
elif name[:8] == 'makefile' and ext != '.rst' or ext == '.mk':
return 'M' # Makefiles
else :
return None