6
from elftools.elf.elffile import ELFFile
10
def meson_fetch_filename(filename_object):
11
if isinstance(filename_object, str):
12
return filename_object
14
return filename_object[0]
17
def needed_libs(filename):
18
print('Processing file:', filename)
20
with open(filename, 'rb') as f:
22
for section in elffile.iter_sections():
23
if section.name.startswith('.dynamic'):
24
for tag in section.iter_tags():
25
if tag.entry.d_tag == 'DT_NEEDED':
26
result.append(getattr(tag, tag.entry.d_tag[3:].lower()))
30
parser = argparse.ArgumentParser(description='Check that when build with efl-one that no module nor efl-one lib does drag in libeina or the likes')
31
parser.add_argument('builddir', metavar='build', help='the path where to find the meson build directory')
33
G = parser.parse_args()
36
meson_introspect = subprocess.Popen(["meson", "introspect", G.builddir, "--targets"],
37
stdout = subprocess.PIPE,
38
stderr = subprocess.PIPE,
40
meson_introspect.poll()
41
build_targets = json.loads(meson_introspect.stdout.read())
42
build_modules = [meson_fetch_filename(b["filename"]) for b in build_targets if "modules" in meson_fetch_filename(b["filename"]) and meson_fetch_filename(b["filename"]).endswith('.so')]
44
for build_modules in build_modules:
45
libs = needed_libs(build_modules)
46
lib_es = [lib for lib in libs if lib.startswith("libe") and lib != "libefl-one.so.1"]
48
print("Error, {} requies lib {}".format(build_modules, lib_es[0]))
51
print("Nothing wrong found!")