From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>, "Jose R . Ziviani" <jziviani@suse.de>
Subject: [PULL 06/48] modules: collect module meta-data
Date: Thu, 8 Jul 2021 17:17:06 +0200 [thread overview]
Message-ID: <20210708151748.408754-7-pbonzini@redhat.com> (raw)
In-Reply-To: <20210708151748.408754-1-pbonzini@redhat.com>
From: Gerd Hoffmann <kraxel@redhat.com>
Add script to collect the module meta-data from the source code,
store the results in *.modinfo files.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jose R. Ziviani <jziviani@suse.de>
Message-Id: <20210624103836.2382472-3-kraxel@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
meson.build | 16 +++++++++
scripts/modinfo-collect.py | 67 ++++++++++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+)
create mode 100755 scripts/modinfo-collect.py
diff --git a/meson.build b/meson.build
index 9cd966a86b..ff580f1f80 100644
--- a/meson.build
+++ b/meson.build
@@ -2241,6 +2241,9 @@ subdir('tests/qtest/fuzz')
# Library dependencies #
########################
+modinfo_collect = find_program('scripts/modinfo-collect.py')
+modinfo_files = []
+
block_mods = []
softmmu_mods = []
foreach d, list : modules
@@ -2254,6 +2257,19 @@ foreach d, list : modules
else
softmmu_mods += sl
endif
+ if module_ss.sources() != []
+ # FIXME: Should use sl.extract_all_objects(recursive: true) as
+ # input. Sources can be used multiple times but objects are
+ # unique when it comes to lookup in compile_commands.json.
+ # Depnds on a mesion version with
+ # https://github.com/mesonbuild/meson/pull/8900
+ modinfo_files += custom_target(d + '-' + m + '.modinfo',
+ output: d + '-' + m + '.modinfo',
+ input: module_ss.sources(),
+ capture: true,
+ build_by_default: true, # to be removed when added to a target
+ command: [modinfo_collect, '@INPUT@'])
+ endif
else
if d == 'block'
block_ss.add_all(module_ss)
diff --git a/scripts/modinfo-collect.py b/scripts/modinfo-collect.py
new file mode 100755
index 0000000000..4acb188c3e
--- /dev/null
+++ b/scripts/modinfo-collect.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import os
+import sys
+import json
+import shlex
+import subprocess
+
+def find_command(src, target, compile_commands):
+ for command in compile_commands:
+ if command['file'] != src:
+ continue
+ if target != '' and command['command'].find(target) == -1:
+ continue
+ return command['command']
+ return 'false'
+
+def process_command(src, command):
+ skip = False
+ arg = False
+ out = []
+ for item in shlex.split(command):
+ if arg:
+ out.append(x)
+ arg = False
+ continue
+ if skip:
+ skip = False
+ continue
+ if item == '-MF' or item == '-MQ' or item == '-o':
+ skip = True
+ continue
+ if item == '-c':
+ skip = True
+ continue
+ out.append(item)
+ out.append('-DQEMU_MODINFO')
+ out.append('-E')
+ out.append(src)
+ return out
+
+def main(args):
+ target = ''
+ if args[0] == '--target':
+ args.pop(0)
+ target = args.pop(0)
+ print("MODINFO_DEBUG target %s" % target)
+ arch = target[:-8] # cut '-softmmu'
+ print("MODINFO_START arch \"%s\" MODINFO_END" % arch)
+ with open('compile_commands.json') as f:
+ compile_commands = json.load(f)
+ for src in args:
+ print("MODINFO_DEBUG src %s" % src)
+ command = find_command(src, target, compile_commands)
+ cmdline = process_command(src, command)
+ print("MODINFO_DEBUG cmd", cmdline)
+ result = subprocess.run(cmdline, stdout = subprocess.PIPE,
+ universal_newlines = True)
+ if result.returncode != 0:
+ sys.exit(result.returncode)
+ for line in result.stdout.split('\n'):
+ if line.find('MODINFO') != -1:
+ print(line)
+
+if __name__ == "__main__":
+ main(sys.argv[1:])
--
2.31.1
next prev parent reply other threads:[~2021-07-08 15:24 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-08 15:17 [PULL 00/48] Misc patches for QEMU 6.1 soft freeze Paolo Bonzini
2021-07-08 15:17 ` [PULL 01/48] configure: fix libdaxctl options Paolo Bonzini
2021-07-08 15:17 ` [PULL 02/48] configure: fix libpmem configuration option Paolo Bonzini
2021-07-08 15:17 ` [PULL 03/48] meson: fix missing preprocessor symbols Paolo Bonzini
2021-07-08 15:17 ` [PULL 04/48] osdep: fix HAVE_BROKEN_SIZE_MAX case Paolo Bonzini
2021-07-08 15:17 ` [PULL 05/48] modules: add modinfo macros Paolo Bonzini
2021-07-08 15:17 ` Paolo Bonzini [this message]
2021-07-08 15:17 ` [PULL 07/48] modules: generate modinfo.c Paolo Bonzini
2021-07-08 15:17 ` [PULL 08/48] modules: check if all dependencies can be satisfied Paolo Bonzini
2021-07-08 15:17 ` [PULL 09/48] modules: add qxl module annotations Paolo Bonzini
2021-07-08 15:17 ` [PULL 10/48] modules: add virtio-gpu " Paolo Bonzini
2021-07-08 15:17 ` [PULL 11/48] modules: add chardev " Paolo Bonzini
2021-07-08 15:17 ` [PULL 12/48] modules: add audio " Paolo Bonzini
2021-07-08 15:17 ` [PULL 13/48] modules: add usb-redir " Paolo Bonzini
2021-07-08 15:17 ` [PULL 14/48] modules: add ccid " Paolo Bonzini
2021-07-08 15:17 ` [PULL 15/48] modules: add ui " Paolo Bonzini
2021-07-08 15:17 ` [PULL 16/48] modules: add s390x " Paolo Bonzini
2021-07-08 15:17 ` [PULL 17/48] modules: add block " Paolo Bonzini
2021-07-08 15:17 ` [PULL 18/48] modules: use modinfo for dependencies Paolo Bonzini
2021-07-08 15:17 ` [PULL 19/48] modules: use modinfo for qom load Paolo Bonzini
2021-07-08 15:17 ` [PULL 20/48] modules: use modinfo for qemu opts load Paolo Bonzini
2021-07-08 15:17 ` [PULL 21/48] modules: add tracepoints Paolo Bonzini
2021-07-08 15:17 ` [PULL 22/48] modules: check arch and block load on mismatch Paolo Bonzini
2021-07-08 15:17 ` [PULL 23/48] modules: check arch on qom lookup Paolo Bonzini
2021-07-08 15:17 ` [PULL 24/48] modules: target-specific module build infrastructure Paolo Bonzini
2021-07-08 15:17 ` [PULL 25/48] modules: add documentation for module sourcesets Paolo Bonzini
2021-07-08 15:17 ` [PULL 26/48] modules: add module_obj() note to QOM docs Paolo Bonzini
2021-07-08 15:17 ` [PULL 27/48] modules: module.h kerneldoc annotations Paolo Bonzini
2021-07-08 15:17 ` [PULL 28/48] modules: hook up modules.h to docs build Paolo Bonzini
2021-07-08 15:17 ` [PULL 29/48] accel: autoload modules Paolo Bonzini
2021-07-08 15:17 ` [PULL 30/48] accel: add qtest module annotations Paolo Bonzini
2021-07-08 15:17 ` [PULL 31/48] accel: build qtest modular Paolo Bonzini
2021-07-08 15:17 ` [PULL 32/48] accel: add tcg module annotations Paolo Bonzini
2021-07-08 15:17 ` [PULL 33/48] accel: build tcg modular Paolo Bonzini
2021-07-08 15:17 ` [PULL 34/48] monitor: allow register hmp commands Paolo Bonzini
2021-07-08 15:17 ` [PULL 35/48] usb: drop usb_host_dev_is_scsi_storage hook Paolo Bonzini
2021-07-08 15:17 ` [PULL 36/48] monitor/usb: register 'info usbhost' dynamically Paolo Bonzini
2021-07-08 15:17 ` [PULL 37/48] usb: build usb-host as module Paolo Bonzini
2021-07-22 14:10 ` Peter Krempa
2021-07-23 6:18 ` Gerd Hoffmann
2021-07-08 15:17 ` [PULL 38/48] monitor/tcg: move tcg hmp commands to accel/tcg, register them dynamically Paolo Bonzini
2021-07-08 15:17 ` [PULL 39/48] target/i386: Added MSRPM and IOPM size check Paolo Bonzini
2021-07-08 15:17 ` [PULL 40/48] target/i386: Added DR6 and DR7 consistency checks Paolo Bonzini
2021-07-08 15:17 ` [PULL 41/48] target/i386: fix exceptions for MOV to DR Paolo Bonzini
2021-07-08 15:17 ` [PULL 42/48] vl: fix leak of qdict_crumple return value Paolo Bonzini
2021-07-08 15:17 ` [PULL 43/48] meson: switch function tests from compilation to linking Paolo Bonzini
2021-07-08 15:17 ` [PULL 44/48] meson: Introduce target-specific Kconfig Paolo Bonzini
2021-07-17 22:59 ` Peter Maydell
2021-07-19 19:15 ` Peter Maydell
2021-07-08 15:17 ` [PULL 45/48] hw/arm: add dependency on OR_IRQ for XLNX_VERSAL Paolo Bonzini
2021-07-08 15:17 ` [PULL 46/48] hw/arm: move CONFIG_V7M out of default-devices Paolo Bonzini
2021-07-08 15:17 ` [PULL 47/48] configs: rename default-configs to configs and reorganise Paolo Bonzini
2021-07-08 15:17 ` [PULL 48/48] configure: allow the selection of alternate config in the build Paolo Bonzini
2021-07-09 15:45 ` [PULL 00/48] Misc patches for QEMU 6.1 soft freeze Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210708151748.408754-7-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=jziviani@suse.de \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).