summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-05-28 11:46:45 +0200
committerStefan Schmidt <s.schmidt@samsung.com>2020-05-28 13:16:00 +0200
commitc5c28120f7c7a567b1a5540310535a4efc7b607f (patch)
treefa24d7b75c0d9ef4abceefae9e718709ef3cfa3b
parentee905100141b10127514cdcbe55407a297f2dd92 (diff)
Introduce a test to verify efl-one only links to the correct libs
whenever this script finds any module linked to libe* (but not libefl-one.so) it will error. Differential Revision: https://phab.enlightenment.org/D11900
-rwxr-xr-xscripts/test-efl-one.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/scripts/test-efl-one.py b/scripts/test-efl-one.py
new file mode 100755
index 0000000000..ba3e34e63d
--- /dev/null
+++ b/scripts/test-efl-one.py
@@ -0,0 +1,52 @@
1#!/bin/env python3
2import os
3import subprocess
4import argparse
5import json
6from elftools.elf.elffile import ELFFile
7
8
9#meson changed behaviour from 0.49 to 0.50 so we need this:
10def meson_fetch_filename(filename_object):
11 if isinstance(filename_object, str):
12 return filename_object
13 else:
14 return filename_object[0]
15
16
17def needed_libs(filename):
18 print('Processing file:', filename)
19 result = []
20 with open(filename, 'rb') as f:
21 elffile = ELFFile(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()))
27 return result
28
29
30parser = argparse.ArgumentParser(description='Check that when build with efl-one that no module nor efl-one lib does drag in libeina or the likes')
31parser.add_argument('builddir', metavar='build', help='the path where to find the meson build directory')
32
33G = parser.parse_args()
34
35#Run meson to fetch all examples
36meson_introspect = subprocess.Popen(["meson", "introspect", G.builddir, "--targets"],
37 stdout = subprocess.PIPE,
38 stderr = subprocess.PIPE,
39)
40meson_introspect.poll()
41build_targets = json.loads(meson_introspect.stdout.read())
42build_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')]
43
44for 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"]
47 if len(lib_es) != 0:
48 print("Error, {} requies lib {}".format(build_modules, lib_es[0]))
49 exit(-1)
50
51print("Nothing wrong found!")
52