tools: kexttool: implement Makefile generation for internal kexts
This commit is contained in:
@@ -4,9 +4,11 @@ import os
|
||||
import glob
|
||||
|
||||
class KextSource:
|
||||
__kext_info = {}
|
||||
__src_dir_path = ''
|
||||
|
||||
src_languages = {
|
||||
'C': [ '.c' ],
|
||||
'CXX': [ '.cpp' ],
|
||||
'ASM': [ '.S' ],
|
||||
}
|
||||
|
||||
def scan(path):
|
||||
result = []
|
||||
@@ -29,11 +31,34 @@ class KextSource:
|
||||
self.__kext_info = yaml.safe_load(info_fp)
|
||||
|
||||
|
||||
def __extension_is_of_lang(ext, lang_name):
|
||||
for name, exts in KextSource.src_languages.items():
|
||||
if name == lang_name and ext in exts:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def __extension_get_lang(ext):
|
||||
for name, exts in src_languages.items():
|
||||
if ext in exts:
|
||||
return name
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def name(self):
|
||||
return self.__kext_info['name']
|
||||
|
||||
|
||||
def id(self):
|
||||
def description(self):
|
||||
return self.__kext_info['description']
|
||||
|
||||
|
||||
def id(self, underscores=False):
|
||||
if underscores:
|
||||
return self.__kext_info['id'].replace('.', '_').replace('-', '_')
|
||||
|
||||
return self.__kext_info['id']
|
||||
|
||||
|
||||
@@ -49,5 +74,33 @@ class KextSource:
|
||||
return self.__kext_info['sources']
|
||||
|
||||
|
||||
def source_languages(self):
|
||||
langs = []
|
||||
|
||||
for src in self.__kext_info['sources']:
|
||||
ext = os.path.splitext(src)[1]
|
||||
lang = KextSource.__extension_get_lang(ext)
|
||||
if lang == None:
|
||||
continue
|
||||
|
||||
langs.append(lang)
|
||||
|
||||
return langs
|
||||
|
||||
|
||||
def sources_filepath(self, lang=None):
|
||||
sources = []
|
||||
for s in self.__kext_info['sources']:
|
||||
if lang != None:
|
||||
ext = os.path.splitext(s)[1]
|
||||
if KextSource.__extension_is_of_lang(lang, ext):
|
||||
continue
|
||||
|
||||
full_path = os.path.join(self.__src_dir_path, s)
|
||||
sources.append(full_path)
|
||||
|
||||
return sources
|
||||
|
||||
|
||||
def src_dirpath(self):
|
||||
return self.__src_dir_path
|
||||
|
||||
Reference in New Issue
Block a user