[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 12/30] modinfo: lookup compile_commands.json by object
From: |
Marc-André Lureau |
Subject: |
Re: [PATCH 12/30] modinfo: lookup compile_commands.json by object |
Date: |
Mon, 12 Dec 2022 12:47:03 +0400 |
On Fri, Dec 9, 2022 at 3:43 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> With Meson 0.63 having fixed various issues with extract_objects, the
> compile_commands.json lookups can be simplified. If the lookup uses
> the object file as key, there is no need to use the command line to
> distinguish among all entries for a given source.
>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> meson.build | 14 ++++----------
> scripts/modinfo-collect.py | 23 +++++++++++------------
> 2 files changed, 15 insertions(+), 22 deletions(-)
>
> diff --git a/meson.build b/meson.build
> index 9ccbe0f6e4ee..8a9ed5628317 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -3123,16 +3123,11 @@ foreach d, list : modules
> 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() + genh,
> + input:
> sl.extract_all_objects(recursive: true),
> capture: true,
> - command: [modinfo_collect,
> module_ss.sources()])
> + command: [modinfo_collect, '@INPUT@'])
> endif
> else
> if d == 'block'
> @@ -3165,12 +3160,11 @@ foreach d, list : target_modules
> c_args: c_args,
> pic: true)
> softmmu_mods += sl
> - # FIXME: Should use sl.extract_all_objects(recursive: true) too.
> modinfo_files += custom_target(module_name + '.modinfo',
> output: module_name + '.modinfo',
> - input: target_module_ss.sources()
> + genh,
> + input:
> sl.extract_all_objects(recursive: true),
> capture: true,
> - command: [modinfo_collect,
> '--target', target, target_module_ss.sources()])
> + command: [modinfo_collect,
> '--target', target, '@INPUT@'])
> endif
> endif
> endforeach
> diff --git a/scripts/modinfo-collect.py b/scripts/modinfo-collect.py
> index 4e7584df6676..48bd92bd6180 100755
> --- a/scripts/modinfo-collect.py
> +++ b/scripts/modinfo-collect.py
> @@ -7,15 +7,6 @@
> 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
> out = []
> @@ -43,14 +34,22 @@ def main(args):
> 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:
> + compile_commands_json = json.load(f)
> + compile_commands = { x['output']: x for x in compile_commands_json }
> +
> + for obj in args:
> + entry = compile_commands.get(obj, None)
> + if not entry:
> + sys.stderr.print('modinfo: Could not find object file', obj)
> + sys.exit(1)
> + src = entry['file']
> if not src.endswith('.c'):
> print("MODINFO_DEBUG skip %s" % src)
> continue
> + command = entry['command']
> 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,
> --
> 2.38.1
>
>
--
Marc-André Lureau
- Re: [PATCH 09/30] meson: use prefer_static option, (continued)
- [PATCH 06/30] meson: tweak hardening options for Windows, Paolo Bonzini, 2022/12/09
- [PATCH 14/30] configure: test all warnings, Paolo Bonzini, 2022/12/09
- [PATCH 12/30] modinfo: lookup compile_commands.json by object, Paolo Bonzini, 2022/12/09
- Re: [PATCH 12/30] modinfo: lookup compile_commands.json by object,
Marc-André Lureau <=
- [PATCH 28/30] docs: update build system docs, Paolo Bonzini, 2022/12/09
- [PATCH 21/30] build: move sanitizer tests to meson, Paolo Bonzini, 2022/12/09
- [PATCH 24/30] build: move stack protector flag selection to meson, Paolo Bonzini, 2022/12/09
- [PATCH 30/30] meson: always log qemu-iotests verbosely, Paolo Bonzini, 2022/12/09