aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJose R. Ziviani <jziviani@suse.de>2022-05-28 00:20:35 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2022-06-06 09:26:53 +0200
commit05d6814c3eb16524e992bb7048d3385f8e99dd6a (patch)
tree2addbfd92970f00c81c98cafc58f54648e5ad6c5 /scripts
parent24ce7aa77dd1a3095d994bf53d60cce6e672cf4d (diff)
modules: generates per-target modinfo
This patch changes the way modinfo is generated and built. Instead of one modinfo.c it generates one modinfo-<target>-softmmu.c per target. It aims a fine-tune control of modules by configuring Kconfig. Signed-off-by: Jose R. Ziviani <jziviani@suse.de> Signed-off-by: Dario Faggioli <dfaggioli@suse.com> Message-Id: <165369003038.5857.13084289285185196779.stgit@work> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/modinfo-generate.py49
1 files changed, 35 insertions, 14 deletions
diff --git a/scripts/modinfo-generate.py b/scripts/modinfo-generate.py
index 689f33c0f2..b1538fcced 100755
--- a/scripts/modinfo-generate.py
+++ b/scripts/modinfo-generate.py
@@ -32,7 +32,7 @@ def parse_line(line):
continue
return (kind, data)
-def generate(name, lines):
+def generate(name, lines, enabled):
arch = ""
objs = []
deps = []
@@ -49,7 +49,13 @@ def generate(name, lines):
elif kind == 'arch':
arch = data;
elif kind == 'kconfig':
- pass # ignore
+ # don't add a module which dependency is not enabled
+ # in kconfig
+ if data.strip() not in enabled:
+ print(" /* module {} isn't enabled in Kconfig. */"
+ .format(data.strip()))
+ print("/* },{ */")
+ return None
else:
print("unknown:", kind)
exit(1)
@@ -60,8 +66,8 @@ def generate(name, lines):
print_array("objs", objs)
print_array("deps", deps)
print_array("opts", opts)
- print("},{");
- return deps
+ print("},{")
+ return {dep.strip('" ') for dep in deps}
def print_pre():
print("/* generated by scripts/modinfo-generate.py */")
@@ -74,23 +80,38 @@ def print_post():
print("}};")
def main(args):
- deps = {}
+ if len(args) < 3 or args[0] != '--devices':
+ print('Expected: modinfo-generate.py --devices '
+ 'config-device.mak [modinfo files]', file=sys.stderr)
+ exit(1)
+
+ # get all devices enabled in kconfig, from *-config-device.mak
+ enabled = set()
+ with open(args[1]) as file:
+ for line in file.readlines():
+ config = line.split('=')
+ if config[1].rstrip() == 'y':
+ enabled.add(config[0][7:]) # remove CONFIG_
+
+ deps = set()
+ modules = set()
print_pre()
- for modinfo in args:
+ for modinfo in args[2:]:
with open(modinfo) as f:
lines = f.readlines()
print(" /* %s */" % modinfo)
- (basename, ext) = os.path.splitext(modinfo)
- deps[basename] = generate(basename, lines)
+ (basename, _) = os.path.splitext(modinfo)
+ moddeps = generate(basename, lines, enabled)
+ if moddeps is not None:
+ modules.add(basename)
+ deps.update(moddeps)
print_post()
- flattened_deps = {flat.strip('" ') for dep in deps.values() for flat in dep}
error = False
- for dep in flattened_deps:
- if dep not in deps.keys():
- print("Dependency {} cannot be satisfied".format(dep),
- file=sys.stderr)
- error = True
+ for dep in deps.difference(modules):
+ print("Dependency {} cannot be satisfied".format(dep),
+ file=sys.stderr)
+ error = True
if error:
exit(1)