23.12.2021 12:33, Vladimir Sementsov-Ogievskiy wrote:
23.12.2021 01:11, Paolo Bonzini wrote:
Il mar 21 dic 2021, 20:35 Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com
<mailto:vsement...@virtuozzo.com>> ha scritto:
--- a/trace/meson.build
+++ b/trace/meson.build
@@ -2,10 +2,14 @@
specific_ss.add(files('control-target.c'))
trace_events_files = []
-foreach dir : [ '.' ] + trace_events_subdirs
- trace_events_file = meson.project_source_root() / dir / 'trace-events'
+foreach path : [ '.' ] + trace_events_subdirs + qapi_trace_events
+ if path.contains('trace-events')
+ trace_events_file = meson.project_build_root() / 'qapi' / path
Just using "trace_events_file = 'qapi' / path" might work, since the build is
nonrecursive.
This say:
ninja: error: '../trace/qapi/qapi-commands-authz.trace-events', needed by
'trace/trace-events-all', missing and no known rule to make it
make[1]: *** [Makefile:162: run-ninja] Error 1
make[1]: Leaving directory '/work/src/qemu/up/up-trace-qmp-commands/build'
make: *** [GNUmakefile:11: all] Error 2
so, it consider the path relative to current "trace" directory.
If it doesn't, use the custom target object, possibly indexing it as ct[index]. You can
use a dictionary to store the custom targets and find them from the "path"
variable.
O! Great thanks! Magic. The following hack works:
diff --git a/meson.build b/meson.build
index 20d32fd20d..c42a76a14c 100644
--- a/meson.build
+++ b/meson.build
@@ -39,6 +39,7 @@ qemu_icondir = get_option('datadir') / 'icons'
config_host_data = configuration_data()
genh = []
qapi_trace_events = []
+qapi_trace_events_targets = {}
target_dirs = config_host['TARGET_DIRS'].split()
have_linux_user = false
diff --git a/qapi/meson.build b/qapi/meson.build
index 333ca60583..d4de04459d 100644
--- a/qapi/meson.build
+++ b/qapi/meson.build
@@ -139,6 +139,9 @@ foreach output : qapi_util_outputs
if output.endswith('.h')
genh += qapi_files[i]
endif
+ if output.endswith('.trace-events')
+ qapi_trace_events_targets += {output: qapi_files[i]}
+ endif
util_ss.add(qapi_files[i])
i = i + 1
endforeach
@@ -147,6 +150,9 @@ foreach output : qapi_specific_outputs +
qapi_nonmodule_outputs
if output.endswith('.h')
genh += qapi_files[i]
endif
+ if output.endswith('.trace-events')
+ qapi_trace_events_targets += {output: qapi_files[i]}
+ endif
specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: qapi_files[i])
i = i + 1
endforeach
diff --git a/trace/meson.build b/trace/meson.build
index 77e44fa68d..daa24c3a2d 100644
--- a/trace/meson.build
+++ b/trace/meson.build
@@ -4,7 +4,7 @@ specific_ss.add(files('control-target.c'))
trace_events_files = []
foreach path : [ '.' ] + trace_events_subdirs + qapi_trace_events
if path.contains('trace-events')
- trace_events_file = meson.project_build_root() / 'qapi' / path
+ trace_events_file = qapi_trace_events_targets[path]
else
trace_events_file = meson.project_source_root() / path / 'trace-events'
endif
Or even simpler, I can use a list combined from needed qapi_files[] elements.
So, the solution is to use custom target objects or their indexed subobjects
instead of raw paths. This way Meson resolves dependencies better.
--
Best regards,
Vladimir