meson: fix Windows build
PATCH RESEND v3 1/1 meson: fix Windows build
Sorry, I forgot to cc the maintainers.
The build failed when run on Windows. I replaced calls to Unix programs like ´cat´, ´sed´ and ´true´ with calls to ´python´. I wrapped calls to ´os.path.relpath´ in try-except because it can fail when the two paths are on different drives. I made sure to convert the Windows paths to Unix paths to prevent warnings in generated files.
--- contrib/plugins/meson.build | 2 +- plugins/meson.build | 2 +- scripts/tracetool/__init__.py | 15 ++++++++++++--- scripts/tracetool/backend/ftrace.py | 4 +--- scripts/tracetool/backend/log.py | 4 +--- scripts/tracetool/backend/syslog.py | 4 +--- tests/functional/meson.build | 4 +--- tests/include/meson.build | 2 +- tests/tcg/plugins/meson.build | 2 +- trace/meson.build | 5 +++-- 10 files changed, 23 insertions(+), 21 deletions(-)
contrib/plugins/meson.build +1 -1
@@ -24,7 +24,7 @@ endif if t.length() > 0 alias_target('contrib-plugins', t) else - run_target('contrib-plugins', command: find_program('true')) + run_target('contrib-plugins', command: [python, '-c', '']) endif plugin_modules += t
plugins/meson.build +1 -1
@@ -33,7 +33,7 @@ if host_os == 'windows' input: qemu_plugin_symbols, output: 'qemu_plugin_api.def', capture: true, - command: ['sed', '-e', '0,/^/s//EXPORTS/; s/[{};]//g', '@INPUT@']) + command: [python, '-c', 'import fileinput, re; print("EXPORTS", end=""); [print(re.sub(r"[{};]", "", line), end="") for line in fileinput.input()]', '@INPUT@']) # then use dlltool to assemble a delaylib. # The delaylib will have an "imaginary" name (qemu.exe), that is used by the
scripts/tracetool/__init__.py +12 -3
@@ -12,12 +12,14 @@ __email__ = "[email protected]" +import os import re import sys import weakref +from pathlib import PurePath -import tracetool.format import tracetool.backend +import tracetool.format def error_write(*lines):
@@ -36,7 +38,7 @@ def error(*lines): def out_open(filename): global out_filename, out_fobj - out_filename = filename + out_filename = posix_relpath(filename) out_fobj = open(filename, 'wt') def out(*lines, **kwargs):
@@ -308,7 +310,7 @@ def build(line_str, lineno, filename): fmt = [fmt_trans, fmt] args = Arguments.build(groups["args"]) - return Event(name, props, fmt, args, lineno, filename) + return Event(name, props, fmt, args, lineno, posix_relpath(filename)) def __repr__(self): """Evaluable string representation for this object."""
@@ -447,3 +449,10 @@ def generate(events, group, format, backends, tracetool.backend.dtrace.PROBEPREFIX = probe_prefix tracetool.format.generate(events, format, backend, group) + +def posix_relpath(path, start=None): + try: + path = os.path.relpath(path, start) + except ValueError: + pass + return PurePath(path).as_posix()
scripts/tracetool/backend/ftrace.py +1 -3
@@ -12,8 +12,6 @@ __email__ = "[email protected]" -import os.path - from tracetool import out
@@ -47,7 +45,7 @@ def generate_h(event, group): args=event.args, event_id="TRACE_" + event.name.upper(), event_lineno=event.lineno, - event_filename=os.path.relpath(event.filename), + event_filename=event.filename, fmt=event.fmt.rstrip("\n"), argnames=argnames)
scripts/tracetool/backend/log.py +1 -3
@@ -12,8 +12,6 @@ __email__ = "[email protected]" -import os.path - from tracetool import out
@@ -55,7 +53,7 @@ def generate_h(event, group): ' }', cond=cond, event_lineno=event.lineno, - event_filename=os.path.relpath(event.filename), + event_filename=event.filename, name=event.name, fmt=event.fmt.rstrip("\n"), argnames=argnames)
scripts/tracetool/backend/syslog.py +1 -3
@@ -12,8 +12,6 @@ __email__ = "[email protected]" -import os.path - from tracetool import out
@@ -43,7 +41,7 @@ def generate_h(event, group): ' }', cond=cond, event_lineno=event.lineno, - event_filename=os.path.relpath(event.filename), + event_filename=event.filename, name=event.name, fmt=event.fmt.rstrip("\n"), argnames=argnames)
tests/functional/meson.build +1 -3
@@ -411,6 +411,4 @@ foreach speed : ['quick', 'thorough'] endforeach endforeach -run_target('precache-functional', - depends: precache_all, - command: ['true']) +alias_target('precache-functional', precache_all)
tests/include/meson.build +1 -1
@@ -13,4 +13,4 @@ test_qapi_outputs_extra = [ test_qapi_files_extra = custom_target('QAPI test (include)', output: test_qapi_outputs_extra, input: test_qapi_files, - command: 'true') + command: [python, '-c', ''])
tests/tcg/plugins/meson.build +1 -1
@@ -17,7 +17,7 @@ endif if t.length() > 0 alias_target('test-plugins', t) else - run_target('test-plugins', command: find_program('true')) + run_target('test-plugins', command: [python, '-c', '']) endif plugin_modules += t
trace/meson.build +3 -2
@@ -4,7 +4,7 @@ trace_events_files = [] foreach item : [ '.' ] + trace_events_subdirs + qapi_trace_events if item in qapi_trace_events trace_events_file = item - group_name = item.full_path().split('/')[-1].underscorify() + group_name = fs.name(item).underscorify() else trace_events_file = meson.project_source_root() / item / 'trace-events' group_name = item == '.' ? 'root' : item.underscorify()
@@ -57,10 +57,11 @@ foreach item : [ '.' ] + trace_events_subdirs + qapi_trace_events endif endforeach +cat = [ python, '-c', 'import fileinput; [print(line, end="") for line in fileinput.input()]', '@INPUT@' ] trace_events_all = custom_target('trace-events-all', output: 'trace-events-all', input: trace_events_files, - command: [ 'cat', '@INPUT@' ], + command: cat, capture: true, install: get_option('trace_backends') != [ 'nop' ], install_dir: qemu_datadir)
Signature · 1 line
2.49.0.windows.1
Quoted 9 lines · oltolm
Sorry, I forgot to cc the maintainers.
The build failed when run on Windows. I replaced calls to Unix programs like ´cat´, ´sed´ and ´true´ with calls to ´python´. I wrapped calls to ´os.path.relpath´ in try-except because it can fail when the two paths are on different drives. I made sure to convert the Windows paths to Unix paths to prevent warnings in generated files.
Signed-off-by oltolm <[email protected]>
Quoted 12 lines
--- contrib/plugins/meson.build | 2 +- plugins/meson.build | 2 +- scripts/tracetool/__init__.py | 15 ++++++++++++--- scripts/tracetool/backend/ftrace.py | 4 +--- scripts/tracetool/backend/log.py | 4 +--- scripts/tracetool/backend/syslog.py | 4 +--- tests/functional/meson.build | 4 +--- tests/include/meson.build | 2 +- tests/tcg/plugins/meson.build | 2 +- trace/meson.build | 5 +++-- 10 files changed, 23 insertions(+), 21 deletions(-)
Thank you for the tracing changes!
I have CCed Paolo for general meson knowledge and the plugins maintainers/reviewers. If no one responds by Wednesday I will merge it through my tracing tree.
Quoted 206 lines
contrib/plugins/meson.build +1
-1@@ -24,7 +24,7 @@ endif if t.length() > 0 alias_target('contrib-plugins', t) else - run_target('contrib-plugins', command: find_program('true')) + run_target('contrib-plugins', command: [python, '-c', '']) endif plugin_modules += tplugins/meson.build +1
-1@@ -33,7 +33,7 @@ if host_os == 'windows' input: qemu_plugin_symbols, output: 'qemu_plugin_api.def', capture: true, - command: ['sed', '-e', '0,/^/s//EXPORTS/; s/[{};]//g', '@INPUT@']) + command: [python, '-c', 'import fileinput, re; print("EXPORTS", end=""); [print(re.sub(r"[{};]", "", line), end="") for line in fileinput.input()]', '@INPUT@']) # then use dlltool to assemble a delaylib. # The delaylib will have an "imaginary" name (qemu.exe), that is used by thescripts/tracetool/__init__.py +12
-3@@ -12,12 +12,14 @@ __email__ = "[email protected]" +import os import re import sys import weakref +from pathlib import PurePath -import tracetool.format import tracetool.backend +import tracetool.format def error_write(*lines):@@ -36,7 +38,7 @@ def error(*lines): def out_open(filename): global out_filename, out_fobj - out_filename = filename + out_filename = posix_relpath(filename) out_fobj = open(filename, 'wt') def out(*lines, **kwargs):@@ -308,7 +310,7 @@ def build(line_str, lineno, filename): fmt = [fmt_trans, fmt] args = Arguments.build(groups["args"]) - return Event(name, props, fmt, args, lineno, filename) + return Event(name, props, fmt, args, lineno, posix_relpath(filename)) def __repr__(self): """Evaluable string representation for this object."""@@ -447,3 +449,10 @@ def generate(events, group, format, backends, tracetool.backend.dtrace.PROBEPREFIX = probe_prefix tracetool.format.generate(events, format, backend, group) + +def posix_relpath(path, start=None): + try: + path = os.path.relpath(path, start) + except ValueError: + pass + return PurePath(path).as_posix()scripts/tracetool/backend/ftrace.py +1
-3@@ -12,8 +12,6 @@ __email__ = "[email protected]" -import os.path - from tracetool import out@@ -47,7 +45,7 @@ def generate_h(event, group): args=event.args, event_id="TRACE_" + event.name.upper(), event_lineno=event.lineno, - event_filename=os.path.relpath(event.filename), + event_filename=event.filename, fmt=event.fmt.rstrip("\n"), argnames=argnames)scripts/tracetool/backend/log.py +1
-3@@ -12,8 +12,6 @@ __email__ = "[email protected]" -import os.path - from tracetool import out@@ -55,7 +53,7 @@ def generate_h(event, group): ' }', cond=cond, event_lineno=event.lineno, - event_filename=os.path.relpath(event.filename), + event_filename=event.filename, name=event.name, fmt=event.fmt.rstrip("\n"), argnames=argnames)scripts/tracetool/backend/syslog.py +1
-3@@ -12,8 +12,6 @@ __email__ = "[email protected]" -import os.path - from tracetool import out@@ -43,7 +41,7 @@ def generate_h(event, group): ' }', cond=cond, event_lineno=event.lineno, - event_filename=os.path.relpath(event.filename), + event_filename=event.filename, name=event.name, fmt=event.fmt.rstrip("\n"), argnames=argnames)tests/functional/meson.build +1
-3@@ -411,6 +411,4 @@ foreach speed : ['quick', 'thorough'] endforeach endforeach -run_target('precache-functional', - depends: precache_all, - command: ['true']) +alias_target('precache-functional', precache_all)tests/include/meson.build +1
-1@@ -13,4 +13,4 @@ test_qapi_outputs_extra = [ test_qapi_files_extra = custom_target('QAPI test (include)', output: test_qapi_outputs_extra, input: test_qapi_files, - command: 'true') + command: [python, '-c', ''])tests/tcg/plugins/meson.build +1
-1@@ -17,7 +17,7 @@ endif if t.length() > 0 alias_target('test-plugins', t) else - run_target('test-plugins', command: find_program('true')) + run_target('test-plugins', command: [python, '-c', '']) endif plugin_modules += ttrace/meson.build +3
-2@@ -4,7 +4,7 @@ trace_events_files = [] foreach item : [ '.' ] + trace_events_subdirs + qapi_trace_events if item in qapi_trace_events trace_events_file = item - group_name = item.full_path().split('/')[-1].underscorify() + group_name = fs.name(item).underscorify() else trace_events_file = meson.project_source_root() / item / 'trace-events' group_name = item == '.' ? 'root' : item.underscorify()@@ -57,10 +57,11 @@ foreach item : [ '.' ] + trace_events_subdirs + qapi_trace_events endif endforeach +cat = [ python, '-c', 'import fileinput; [print(line, end="") for line in fileinput.input()]', '@INPUT@' ] trace_events_all = custom_target('trace-events-all', output: 'trace-events-all', input: trace_events_files, - command: [ 'cat', '@INPUT@' ], + command: cat, capture: true, install: get_option('trace_backends') != [ 'nop' ], install_dir: qemu_datadir)Signature · 1 line
2.49.0.windows.1
Quoted 40 lines · oltolm
Sorry, I forgot to cc the maintainers.
The build failed when run on Windows. I replaced calls to Unix programs like ´cat´, ´sed´ and ´true´ with calls to ´python´. I wrapped calls to ´os.path.relpath´ in try-except because it can fail when the two paths are on different drives. I made sure to convert the Windows paths to Unix paths to prevent warnings in generated files.
Signed-off-by oltolm <[email protected]>--- contrib/plugins/meson.build | 2 +- plugins/meson.build | 2 +- scripts/tracetool/__init__.py | 15 ++++++++++++--- scripts/tracetool/backend/ftrace.py | 4 +--- scripts/tracetool/backend/log.py | 4 +--- scripts/tracetool/backend/syslog.py | 4 +--- tests/functional/meson.build | 4 +--- tests/include/meson.build | 2 +- tests/tcg/plugins/meson.build | 2 +- trace/meson.build | 5 +++-- 10 files changed, 23 insertions(+), 21 deletions(-)contrib/plugins/meson.build +1
-1@@ -24,7 +24,7 @@ endif if t.length() > 0 alias_target('contrib-plugins', t) else - run_target('contrib-plugins', command: find_program('true')) + run_target('contrib-plugins', command: [python, '-c', '']) endif plugin_modules += tplugins/meson.build +0
-0
plugins/meson.build if host_os == 'windows' · line 36
Quoted 5 lines
plugins/meson.build +1
-1@@ -33,7 +33,7 @@ if host_os == 'windows' input: qemu_plugin_symbols, output: 'qemu_plugin_api.def', capture: true, - command: ['sed', '-e', '0,/^/s//EXPORTS/; s/[{};]//g', '@INPUT@']) + command: [python, '-c', 'import fileinput, re; print("EXPORTS", end=""); [print(re.sub(r"[{};]", "", line), end="") for line in fileinput.input()]', '@INPUT@'])
On second thought, is print("EXPORTS", end="") correct? Unlike the lines coming from fileinput, there is no line ending. I though that .def files look like this:
EXPORTS
...
...
So maybe end="" should be dropped for EXPORTS to correctly format the .def file?
(I didn't have a Windows build environment to check myself, but it should be easy to diff the before/after files to verify whether there are any changes.)
Stefan
Am Sa., 7. Juni 2025 um 21:12 Uhr schrieb Stefan Hajnoczi <[email protected]>:
Quoted 56 lines · oltolm
Quoted 40 lines
Sorry, I forgot to cc the maintainers.
The build failed when run on Windows. I replaced calls to Unix programs like ´cat´, ´sed´ and ´true´ with calls to ´python´. I wrapped calls to ´os.path.relpath´ in try-except because it can fail when the two paths are on different drives. I made sure to convert the Windows paths to Unix paths to prevent warnings in generated files.
Signed-off-by oltolm <[email protected]>--- contrib/plugins/meson.build | 2 +- plugins/meson.build | 2 +- scripts/tracetool/__init__.py | 15 ++++++++++++--- scripts/tracetool/backend/ftrace.py | 4 +--- scripts/tracetool/backend/log.py | 4 +--- scripts/tracetool/backend/syslog.py | 4 +--- tests/functional/meson.build | 4 +--- tests/include/meson.build | 2 +- tests/tcg/plugins/meson.build | 2 +- trace/meson.build | 5 +++-- 10 files changed, 23 insertions(+), 21 deletions(-)contrib/plugins/meson.build +1
-1@@ -24,7 +24,7 @@ endif if t.length() > 0 alias_target('contrib-plugins', t) else - run_target('contrib-plugins', command: find_program('true')) + run_target('contrib-plugins', command: [python, '-c', '']) endif plugin_modules += tplugins/meson.build +0
-0plugins/meson.build if host_os == 'windows' · line 36
Quoted 5 lines
plugins/meson.build +1
-1@@ -33,7 +33,7 @@ if host_os == 'windows' input: qemu_plugin_symbols, output: 'qemu_plugin_api.def', capture: true, - command: ['sed', '-e', '0,/^/s//EXPORTS/; s/[{};]//g', '@INPUT@']) + command: [python, '-c', 'import fileinput, re; print("EXPORTS", end=""); [print(re.sub(r"[{};]", "", line), end="") for line in fileinput.input()]', '@INPUT@'])On second thought, is
print("EXPORTS", end="")correct? Unlike the lines coming from fileinput, there is no line ending. I though that .def files look like this:EXPORTS
...
...
Quoted 6 lines
So maybe end="" should be dropped for EXPORTS to correctly format the .def file?
(I didn't have a Windows build environment to check myself, but it should be easy to diff the before/after files to verify whether there are any changes.)
I already did that. It produces the same output.
Oleg
Quoted 9 lines · oltolm
Sorry, I forgot to cc the maintainers.
The build failed when run on Windows. I replaced calls to Unix programs like ´cat´, ´sed´ and ´true´ with calls to ´python´. I wrapped calls to ´os.path.relpath´ in try-except because it can fail when the two paths are on different drives. I made sure to convert the Windows paths to Unix paths to prevent warnings in generated files.
Signed-off-by oltolm <[email protected]>
for plugins:
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Quoted 9 lines · oltolm
Sorry, I forgot to cc the maintainers.
The build failed when run on Windows. I replaced calls to Unix programs like ´cat´, ´sed´ and ´true´ with calls to ´python´. I wrapped calls to ´os.path.relpath´ in try-except because it can fail when the two paths are on different drives. I made sure to convert the Windows paths to Unix paths to prevent warnings in generated files.
Signed-off-by oltolm <[email protected]>
Quoted 12 lines
--- contrib/plugins/meson.build | 2 +- plugins/meson.build | 2 +- scripts/tracetool/__init__.py | 15 ++++++++++++--- scripts/tracetool/backend/ftrace.py | 4 +--- scripts/tracetool/backend/log.py | 4 +--- scripts/tracetool/backend/syslog.py | 4 +--- tests/functional/meson.build | 4 +--- tests/include/meson.build | 2 +- tests/tcg/plugins/meson.build | 2 +- trace/meson.build | 5 +++-- 10 files changed, 23 insertions(+), 21 deletions(-)
Are you building using msys2, or another environment on Windows? I'm curious to know in which configuration the build is failing.
In case you use msys2, maybe you're simply missing some packages. Our documentation explains what to install [1].
Building out of msys2 on Windows is not recommended, as this is the only maintained setup (tested in our CI, and maintained as an msys2 package by msys2 maintainers) for this system.
[1] https://www.qemu.org/docs/master/devel/build-environment.html
Regards,
Pierrick
Am So., 8. Juni 2025 um 02:43 Uhr schrieb Pierrick Bouvier <[email protected]>:
Quoted 27 lines · oltolm
Quoted 9 lines
Sorry, I forgot to cc the maintainers.
The build failed when run on Windows. I replaced calls to Unix programs like ´cat´, ´sed´ and ´true´ with calls to ´python´. I wrapped calls to ´os.path.relpath´ in try-except because it can fail when the two paths are on different drives. I made sure to convert the Windows paths to Unix paths to prevent warnings in generated files.
Signed-off-by oltolm <[email protected]>Quoted 12 lines
--- contrib/plugins/meson.build | 2 +- plugins/meson.build | 2 +- scripts/tracetool/__init__.py | 15 ++++++++++++--- scripts/tracetool/backend/ftrace.py | 4 +--- scripts/tracetool/backend/log.py | 4 +--- scripts/tracetool/backend/syslog.py | 4 +--- tests/functional/meson.build | 4 +--- tests/include/meson.build | 2 +- tests/tcg/plugins/meson.build | 2 +- trace/meson.build | 5 +++-- 10 files changed, 23 insertions(+), 21 deletions(-)Are you building using msys2, or another environment on Windows? I'm curious to know in which configuration the build is failing.
Quoted 7 lines
In case you use msys2, maybe you're simply missing some packages. Our documentation explains what to install [1].
Building out of msys2 on Windows is not recommended, as this is the only maintained setup (tested in our CI, and maintained as an msys2 package by msys2 maintainers) for this system.[1] https://www.qemu.org/docs/master/devel/build-environment.html
Yes I do use msys2, but I only use bash for the initial configuration. Afterwards I just call meson and ninja from "cmd" not from bash.
Quoted 35 lines · Oleg Tolmatcev
Am So., 8. Juni 2025 um 02:43 Uhr schrieb Pierrick Bouvier <[email protected]>:
Quoted 33 lines · oltolm
Quoted 9 lines
Sorry, I forgot to cc the maintainers.
The build failed when run on Windows. I replaced calls to Unix programs like ´cat´, ´sed´ and ´true´ with calls to ´python´. I wrapped calls to ´os.path.relpath´ in try-except because it can fail when the two paths are on different drives. I made sure to convert the Windows paths to Unix paths to prevent warnings in generated files.
Signed-off-by oltolm <[email protected]>Quoted 12 lines
--- contrib/plugins/meson.build | 2 +- plugins/meson.build | 2 +- scripts/tracetool/__init__.py | 15 ++++++++++++--- scripts/tracetool/backend/ftrace.py | 4 +--- scripts/tracetool/backend/log.py | 4 +--- scripts/tracetool/backend/syslog.py | 4 +--- tests/functional/meson.build | 4 +--- tests/include/meson.build | 2 +- tests/tcg/plugins/meson.build | 2 +- trace/meson.build | 5 +++-- 10 files changed, 23 insertions(+), 21 deletions(-)Are you building using msys2, or another environment on Windows? I'm curious to know in which configuration the build is failing.
In case you use msys2, maybe you're simply missing some packages. Our documentation explains what to install [1].
Building out of msys2 on Windows is not recommended, as this is the only maintained setup (tested in our CI, and maintained as an msys2 package by msys2 maintainers) for this system.
Quoted 4 lines
Quoted 1 line
[1] https://www.qemu.org/docs/master/devel/build-environment.html
Yes I do use msys2, but I only use bash for the initial configuration. Afterwards I just call meson and ninja from "cmd" not from bash.
Maybe it's because it's complicated to execute a single command from msys2, and return. Using the -shell parameter of msys2_shell, you can pass arguments to bash.
cmd.exe /c c:/msys64/msys2_shell.cmd -defterm -here -no-start -mingw64
-shell bash -c 'ls / /tmp'
That said, I'm not opposed to the current series, I just wanted to understand what is the context.
Thanks,
Pierrick
Stefan Hajnoczi
AppliedQuoted 9 lines · oltolm
Sorry, I forgot to cc the maintainers.
The build failed when run on Windows. I replaced calls to Unix programs like ´cat´, ´sed´ and ´true´ with calls to ´python´. I wrapped calls to ´os.path.relpath´ in try-except because it can fail when the two paths are on different drives. I made sure to convert the Windows paths to Unix paths to prevent warnings in generated files.
Signed-off-by oltolm <[email protected]>
Quoted 12 lines
--- contrib/plugins/meson.build | 2 +- plugins/meson.build | 2 +- scripts/tracetool/__init__.py | 15 ++++++++++++--- scripts/tracetool/backend/ftrace.py | 4 +--- scripts/tracetool/backend/log.py | 4 +--- scripts/tracetool/backend/syslog.py | 4 +--- tests/functional/meson.build | 4 +--- tests/include/meson.build | 2 +- tests/tcg/plugins/meson.build | 2 +- trace/meson.build | 5 +++-- 10 files changed, 23 insertions(+), 21 deletions(-)
Thanks, applied to my tracing tree:
https://gitlab.com/stefanha/qemu/commits/tracing
Stefan
Quoted 169 lines · oltolm
Sorry, I forgot to cc the maintainers.
The build failed when run on Windows. I replaced calls to Unix programs like ´cat´, ´sed´ and ´true´ with calls to ´python´. I wrapped calls to ´os.path.relpath´ in try-except because it can fail when the two paths are on different drives. I made sure to convert the Windows paths to Unix paths to prevent warnings in generated files.
Signed-off-by oltolm <[email protected]>--- contrib/plugins/meson.build | 2 +- plugins/meson.build | 2 +- scripts/tracetool/__init__.py | 15 ++++++++++++--- scripts/tracetool/backend/ftrace.py | 4 +--- scripts/tracetool/backend/log.py | 4 +--- scripts/tracetool/backend/syslog.py | 4 +--- tests/functional/meson.build | 4 +--- tests/include/meson.build | 2 +- tests/tcg/plugins/meson.build | 2 +- trace/meson.build | 5 +++-- 10 files changed, 23 insertions(+), 21 deletions(-)contrib/plugins/meson.build +1
-1@@ -24,7 +24,7 @@ endif if t.length() > 0 alias_target('contrib-plugins', t) else - run_target('contrib-plugins', command: find_program('true')) + run_target('contrib-plugins', command: [python, '-c', '']) endif plugin_modules += tplugins/meson.build +1
-1@@ -33,7 +33,7 @@ if host_os == 'windows' input: qemu_plugin_symbols, output: 'qemu_plugin_api.def', capture: true, - command: ['sed', '-e', '0,/^/s//EXPORTS/; s/[{};]//g', '@INPUT@']) + command: [python, '-c', 'import fileinput, re; print("EXPORTS", end=""); [print(re.sub(r"[{};]", "", line), end="") for line in fileinput.input()]', '@INPUT@']) # then use dlltool to assemble a delaylib. # The delaylib will have an "imaginary" name (qemu.exe), that is used by thescripts/tracetool/__init__.py +12
-3@@ -12,12 +12,14 @@ __email__ = "[email protected]" +import os import re import sys import weakref +from pathlib import PurePath -import tracetool.format import tracetool.backend +import tracetool.format def error_write(*lines):@@ -36,7 +38,7 @@ def error(*lines): def out_open(filename): global out_filename, out_fobj - out_filename = filename + out_filename = posix_relpath(filename) out_fobj = open(filename, 'wt') def out(*lines, **kwargs):@@ -308,7 +310,7 @@ def build(line_str, lineno, filename): fmt = [fmt_trans, fmt] args = Arguments.build(groups["args"]) - return Event(name, props, fmt, args, lineno, filename) + return Event(name, props, fmt, args, lineno, posix_relpath(filename)) def __repr__(self): """Evaluable string representation for this object."""@@ -447,3 +449,10 @@ def generate(events, group, format, backends, tracetool.backend.dtrace.PROBEPREFIX = probe_prefix tracetool.format.generate(events, format, backend, group) + +def posix_relpath(path, start=None): + try: + path = os.path.relpath(path, start) + except ValueError: + pass + return PurePath(path).as_posix()scripts/tracetool/backend/ftrace.py +1
-3@@ -12,8 +12,6 @@ __email__ = "[email protected]" -import os.path - from tracetool import out@@ -47,7 +45,7 @@ def generate_h(event, group): args=event.args, event_id="TRACE_" + event.name.upper(), event_lineno=event.lineno, - event_filename=os.path.relpath(event.filename), + event_filename=event.filename, fmt=event.fmt.rstrip("\n"), argnames=argnames)scripts/tracetool/backend/log.py +1
-3@@ -12,8 +12,6 @@ __email__ = "[email protected]" -import os.path - from tracetool import out@@ -55,7 +53,7 @@ def generate_h(event, group): ' }', cond=cond, event_lineno=event.lineno, - event_filename=os.path.relpath(event.filename), + event_filename=event.filename, name=event.name, fmt=event.fmt.rstrip("\n"), argnames=argnames)scripts/tracetool/backend/syslog.py +1
-3@@ -12,8 +12,6 @@ __email__ = "[email protected]" -import os.path - from tracetool import out@@ -43,7 +41,7 @@ def generate_h(event, group): ' }', cond=cond, event_lineno=event.lineno, - event_filename=os.path.relpath(event.filename), + event_filename=event.filename, name=event.name, fmt=event.fmt.rstrip("\n"), argnames=argnames)tests/functional/meson.build +0
-0
tests/functional/meson.build foreach speed : ['quick', 'thorough'] · line 414
Quoted 7 lines
tests/functional/meson.build +1
-3@@ -411,6 +411,4 @@ foreach speed : ['quick', 'thorough'] endforeach endforeach -run_target('precache-functional', - depends: precache_all, - command: ['true']) +alias_target('precache-functional', precache_all)
Hi Oleg,
There is a CI hexagon build failure. Maybe precache_all is []:
../tests/functional/meson.build:417:0: ERROR: alias_target takes at least 2 arguments, but got 1.
https://gitlab.com/qemu-project/qemu/-/jobs/10336566320#L4267
Please take a look. Thanks!
Stefan
Quoted 53 lines
tests/include/meson.build +1
-1@@ -13,4 +13,4 @@ test_qapi_outputs_extra = [ test_qapi_files_extra = custom_target('QAPI test (include)', output: test_qapi_outputs_extra, input: test_qapi_files, - command: 'true') + command: [python, '-c', ''])tests/tcg/plugins/meson.build +1
-1@@ -17,7 +17,7 @@ endif if t.length() > 0 alias_target('test-plugins', t) else - run_target('test-plugins', command: find_program('true')) + run_target('test-plugins', command: [python, '-c', '']) endif plugin_modules += ttrace/meson.build +3
-3@@ -4,7 +4,7 @@ trace_events_files = [] foreach item : [ '.' ] + trace_events_subdirs + qapi_trace_events if item in qapi_trace_events trace_events_file = item - group_name = item.full_path().split('/')[-1].underscorify() + group_name = fs.name(item).underscorify() else trace_events_file = meson.project_source_root() / item / 'trace-events' group_name = item == '.' ? 'root' : item.underscorify()@@ -57,10 +57,11 @@ foreach item : [ '.' ] + trace_events_subdirs + qapi_trace_events endif endforeach +cat = [ python, '-c', 'import fileinput; [print(line, end="") for line in fileinput.input()]', '@INPUT@' ] trace_events_all = custom_target('trace-events-all', output: 'trace-events-all', input: trace_events_files, - command: [ 'cat', '@INPUT@' ], + command: cat, capture: true, install: get_option('trace_backends') != [ 'nop' ], install_dir: qemu_datadir) --2.49.0.windows.1
Am Do., 12. Juni 2025 um 21:35 Uhr schrieb Stefan Hajnoczi <[email protected]>:
Quoted 184 lines · oltolm
Quoted 169 lines
Sorry, I forgot to cc the maintainers.
The build failed when run on Windows. I replaced calls to Unix programs like ´cat´, ´sed´ and ´true´ with calls to ´python´. I wrapped calls to ´os.path.relpath´ in try-except because it can fail when the two paths are on different drives. I made sure to convert the Windows paths to Unix paths to prevent warnings in generated files.
Signed-off-by oltolm <[email protected]>--- contrib/plugins/meson.build | 2 +- plugins/meson.build | 2 +- scripts/tracetool/__init__.py | 15 ++++++++++++--- scripts/tracetool/backend/ftrace.py | 4 +--- scripts/tracetool/backend/log.py | 4 +--- scripts/tracetool/backend/syslog.py | 4 +--- tests/functional/meson.build | 4 +--- tests/include/meson.build | 2 +- tests/tcg/plugins/meson.build | 2 +- trace/meson.build | 5 +++-- 10 files changed, 23 insertions(+), 21 deletions(-)contrib/plugins/meson.build +1
-1@@ -24,7 +24,7 @@ endif if t.length() > 0 alias_target('contrib-plugins', t) else - run_target('contrib-plugins', command: find_program('true')) + run_target('contrib-plugins', command: [python, '-c', '']) endif plugin_modules += tplugins/meson.build +1
-1@@ -33,7 +33,7 @@ if host_os == 'windows' input: qemu_plugin_symbols, output: 'qemu_plugin_api.def', capture: true, - command: ['sed', '-e', '0,/^/s//EXPORTS/; s/[{};]//g', '@INPUT@']) + command: [python, '-c', 'import fileinput, re; print("EXPORTS", end=""); [print(re.sub(r"[{};]", "", line), end="") for line in fileinput.input()]', '@INPUT@']) # then use dlltool to assemble a delaylib. # The delaylib will have an "imaginary" name (qemu.exe), that is used by thescripts/tracetool/__init__.py +12
-3@@ -12,12 +12,14 @@ __email__ = "[email protected]" +import os import re import sys import weakref +from pathlib import PurePath -import tracetool.format import tracetool.backend +import tracetool.format def error_write(*lines):@@ -36,7 +38,7 @@ def error(*lines): def out_open(filename): global out_filename, out_fobj - out_filename = filename + out_filename = posix_relpath(filename) out_fobj = open(filename, 'wt') def out(*lines, **kwargs):@@ -308,7 +310,7 @@ def build(line_str, lineno, filename): fmt = [fmt_trans, fmt] args = Arguments.build(groups["args"]) - return Event(name, props, fmt, args, lineno, filename) + return Event(name, props, fmt, args, lineno, posix_relpath(filename)) def __repr__(self): """Evaluable string representation for this object."""@@ -447,3 +449,10 @@ def generate(events, group, format, backends, tracetool.backend.dtrace.PROBEPREFIX = probe_prefix tracetool.format.generate(events, format, backend, group) + +def posix_relpath(path, start=None): + try: + path = os.path.relpath(path, start) + except ValueError: + pass + return PurePath(path).as_posix()scripts/tracetool/backend/ftrace.py +1
-3@@ -12,8 +12,6 @@ __email__ = "[email protected]" -import os.path - from tracetool import out@@ -47,7 +45,7 @@ def generate_h(event, group): args=event.args, event_id="TRACE_" + event.name.upper(), event_lineno=event.lineno, - event_filename=os.path.relpath(event.filename), + event_filename=event.filename, fmt=event.fmt.rstrip("\n"), argnames=argnames)scripts/tracetool/backend/log.py +1
-3@@ -12,8 +12,6 @@ __email__ = "[email protected]" -import os.path - from tracetool import out@@ -55,7 +53,7 @@ def generate_h(event, group): ' }', cond=cond, event_lineno=event.lineno, - event_filename=os.path.relpath(event.filename), + event_filename=event.filename, name=event.name, fmt=event.fmt.rstrip("\n"), argnames=argnames)scripts/tracetool/backend/syslog.py +1
-3@@ -12,8 +12,6 @@ __email__ = "[email protected]" -import os.path - from tracetool import out@@ -43,7 +41,7 @@ def generate_h(event, group): ' }', cond=cond, event_lineno=event.lineno, - event_filename=os.path.relpath(event.filename), + event_filename=event.filename, name=event.name, fmt=event.fmt.rstrip("\n"), argnames=argnames)tests/functional/meson.build +0
-0tests/functional/meson.build foreach speed : ['quick', 'thorough'] · line 414
Quoted 7 lines
tests/functional/meson.build +1
-3@@ -411,6 +411,4 @@ foreach speed : ['quick', 'thorough'] endforeach endforeach -run_target('precache-functional', - depends: precache_all, - command: ['true']) +alias_target('precache-functional', precache_all)Hi Oleg,
There is a CI hexagon build failure. Maybeprecache_allis []:
../tests/functional/meson.build:417:0: ERROR:alias_targettakes at least 2 arguments, but got 1.
Quoted 3 lines
https://gitlab.com/qemu-project/qemu/-/jobs/10336566320#L4267
Please take a look. Thanks!
Hi Stefan,
this should be replaced with
run_target('precache-functional',
depends: precache_all,
command: [python, '-c', ''])Should I send a v4 of my patch?
Oleg
Quoted 191 lines · Oleg Tolmatcev
Am Do., 12. Juni 2025 um 21:35 Uhr schrieb Stefan Hajnoczi <[email protected]>:
Quoted 184 lines · oltolm
Quoted 169 lines
Sorry, I forgot to cc the maintainers.
The build failed when run on Windows. I replaced calls to Unix programs like ´cat´, ´sed´ and ´true´ with calls to ´python´. I wrapped calls to ´os.path.relpath´ in try-except because it can fail when the two paths are on different drives. I made sure to convert the Windows paths to Unix paths to prevent warnings in generated files.
Signed-off-by oltolm <[email protected]>--- contrib/plugins/meson.build | 2 +- plugins/meson.build | 2 +- scripts/tracetool/__init__.py | 15 ++++++++++++--- scripts/tracetool/backend/ftrace.py | 4 +--- scripts/tracetool/backend/log.py | 4 +--- scripts/tracetool/backend/syslog.py | 4 +--- tests/functional/meson.build | 4 +--- tests/include/meson.build | 2 +- tests/tcg/plugins/meson.build | 2 +- trace/meson.build | 5 +++-- 10 files changed, 23 insertions(+), 21 deletions(-)contrib/plugins/meson.build +1
-1@@ -24,7 +24,7 @@ endif if t.length() > 0 alias_target('contrib-plugins', t) else - run_target('contrib-plugins', command: find_program('true')) + run_target('contrib-plugins', command: [python, '-c', '']) endif plugin_modules += tplugins/meson.build +1
-1@@ -33,7 +33,7 @@ if host_os == 'windows' input: qemu_plugin_symbols, output: 'qemu_plugin_api.def', capture: true, - command: ['sed', '-e', '0,/^/s//EXPORTS/; s/[{};]//g', '@INPUT@']) + command: [python, '-c', 'import fileinput, re; print("EXPORTS", end=""); [print(re.sub(r"[{};]", "", line), end="") for line in fileinput.input()]', '@INPUT@']) # then use dlltool to assemble a delaylib. # The delaylib will have an "imaginary" name (qemu.exe), that is used by thescripts/tracetool/__init__.py +12
-3@@ -12,12 +12,14 @@ __email__ = "[email protected]" +import os import re import sys import weakref +from pathlib import PurePath -import tracetool.format import tracetool.backend +import tracetool.format def error_write(*lines):@@ -36,7 +38,7 @@ def error(*lines): def out_open(filename): global out_filename, out_fobj - out_filename = filename + out_filename = posix_relpath(filename) out_fobj = open(filename, 'wt') def out(*lines, **kwargs):@@ -308,7 +310,7 @@ def build(line_str, lineno, filename): fmt = [fmt_trans, fmt] args = Arguments.build(groups["args"]) - return Event(name, props, fmt, args, lineno, filename) + return Event(name, props, fmt, args, lineno, posix_relpath(filename)) def __repr__(self): """Evaluable string representation for this object."""@@ -447,3 +449,10 @@ def generate(events, group, format, backends, tracetool.backend.dtrace.PROBEPREFIX = probe_prefix tracetool.format.generate(events, format, backend, group) + +def posix_relpath(path, start=None): + try: + path = os.path.relpath(path, start) + except ValueError: + pass + return PurePath(path).as_posix()scripts/tracetool/backend/ftrace.py +1
-3@@ -12,8 +12,6 @@ __email__ = "[email protected]" -import os.path - from tracetool import out@@ -47,7 +45,7 @@ def generate_h(event, group): args=event.args, event_id="TRACE_" + event.name.upper(), event_lineno=event.lineno, - event_filename=os.path.relpath(event.filename), + event_filename=event.filename, fmt=event.fmt.rstrip("\n"), argnames=argnames)scripts/tracetool/backend/log.py +1
-3@@ -12,8 +12,6 @@ __email__ = "[email protected]" -import os.path - from tracetool import out@@ -55,7 +53,7 @@ def generate_h(event, group): ' }', cond=cond, event_lineno=event.lineno, - event_filename=os.path.relpath(event.filename), + event_filename=event.filename, name=event.name, fmt=event.fmt.rstrip("\n"), argnames=argnames)scripts/tracetool/backend/syslog.py +1
-3@@ -12,8 +12,6 @@ __email__ = "[email protected]" -import os.path - from tracetool import out@@ -43,7 +41,7 @@ def generate_h(event, group): ' }', cond=cond, event_lineno=event.lineno, - event_filename=os.path.relpath(event.filename), + event_filename=event.filename, name=event.name, fmt=event.fmt.rstrip("\n"), argnames=argnames)tests/functional/meson.build +0
-0tests/functional/meson.build foreach speed : ['quick', 'thorough'] · line 414
Quoted 7 lines
tests/functional/meson.build +1
-3@@ -411,6 +411,4 @@ foreach speed : ['quick', 'thorough'] endforeach endforeach -run_target('precache-functional', - depends: precache_all, - command: ['true']) +alias_target('precache-functional', precache_all)Hi Oleg,
There is a CI hexagon build failure. Maybeprecache_allis []:
../tests/functional/meson.build:417:0: ERROR:alias_targettakes at least 2 arguments, but got 1.Quoted 3 lines
https://gitlab.com/qemu-project/qemu/-/jobs/10336566320#L4267
Please take a look. Thanks!
Hi Stefan,
Quoted 7 lines
this should be replaced with
run_target('precache-functional',
depends: precache_all, command: [python, '-c', ''])Should I send a v4 of my patch?
I think it would help if you can send a v4 also fixing up the commit message as was discussed so Stefan does not have to do it. Generally more than trivial fixup needs a new version of the patch sent by the author, only fixing simple typos might not need a resend. Ideally maintainers should not need to do any fixup just take the latest patch version.
Regards,
BALATON Zoltan