contrib/plugins/meson.build | 2 +- scripts/tracetool/backend/ftrace.py | 9 ++++++++- scripts/tracetool/backend/log.py | 9 ++++++++- scripts/tracetool/backend/syslog.py | 9 ++++++++- tests/functional/meson.build | 2 +- tests/include/meson.build | 2 +- tests/tcg/plugins/meson.build | 2 +- trace/meson.build | 4 ++-- 8 files changed, 30 insertions(+), 9 deletions(-)
The build failed when run on Windows. I replaced calls to Unix programs
like `cat` 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 <oleg.tolmatcev@gmail.com>
---
contrib/plugins/meson.build | 2 +-
scripts/tracetool/backend/ftrace.py | 9 ++++++++-
scripts/tracetool/backend/log.py | 9 ++++++++-
scripts/tracetool/backend/syslog.py | 9 ++++++++-
tests/functional/meson.build | 2 +-
tests/include/meson.build | 2 +-
tests/tcg/plugins/meson.build | 2 +-
trace/meson.build | 4 ++--
8 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build
index fa8a426c8..1876bc784 100644
--- a/contrib/plugins/meson.build
+++ b/contrib/plugins/meson.build
@@ -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
diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backend/ftrace.py
index baed2ae61..81a5f93b3 100644
--- a/scripts/tracetool/backend/ftrace.py
+++ b/scripts/tracetool/backend/ftrace.py
@@ -13,6 +13,7 @@
import os.path
+from pathlib import PurePath
from tracetool import out
@@ -30,6 +31,12 @@ def generate_h(event, group):
if len(event.args) > 0:
argnames = ", " + argnames
+ try:
+ event_filename = os.path.relpath(event.filename)
+ except ValueError:
+ event_filename = event.filename
+ event_filename = PurePath(event_filename).as_posix()
+
out(' {',
' char ftrace_buf[MAX_TRACE_STRLEN];',
' int unused __attribute__ ((unused));',
@@ -47,7 +54,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)
diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/log.py
index de27b7e62..241fbbbd0 100644
--- a/scripts/tracetool/backend/log.py
+++ b/scripts/tracetool/backend/log.py
@@ -13,6 +13,7 @@
import os.path
+from pathlib import PurePath
from tracetool import out
@@ -37,6 +38,12 @@ def generate_h(event, group):
else:
cond = "trace_event_get_state(%s)" % ("TRACE_" + event.name.upper())
+ try:
+ event_filename = os.path.relpath(event.filename)
+ except ValueError:
+ event_filename = event.filename
+ event_filename = PurePath(event_filename).as_posix()
+
out(' if (%(cond)s && qemu_loglevel_mask(LOG_TRACE)) {',
' if (message_with_timestamp) {',
' struct timeval _now;',
@@ -55,7 +62,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)
diff --git a/scripts/tracetool/backend/syslog.py b/scripts/tracetool/backend/syslog.py
index 012970f6c..2e010e7c9 100644
--- a/scripts/tracetool/backend/syslog.py
+++ b/scripts/tracetool/backend/syslog.py
@@ -13,6 +13,7 @@
import os.path
+from pathlib import PurePath
from tracetool import out
@@ -36,6 +37,12 @@ def generate_h(event, group):
else:
cond = "trace_event_get_state(%s)" % ("TRACE_" + event.name.upper())
+ try:
+ event_filename = os.path.relpath(event.filename)
+ except ValueError:
+ event_filename = event.filename
+ event_filename = PurePath(event_filename).as_posix()
+
out(' if (%(cond)s) {',
'#line %(event_lineno)d "%(event_filename)s"',
' syslog(LOG_INFO, "%(name)s " %(fmt)s %(argnames)s);',
@@ -43,7 +50,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)
diff --git a/tests/functional/meson.build b/tests/functional/meson.build
index 52b4706cf..2e3bd4057 100644
--- a/tests/functional/meson.build
+++ b/tests/functional/meson.build
@@ -413,4 +413,4 @@ endforeach
run_target('precache-functional',
depends: precache_all,
- command: ['true'])
+ command: [python, '-c', ''])
diff --git a/tests/include/meson.build b/tests/include/meson.build
index 9abba308f..8e8d1ec4e 100644
--- a/tests/include/meson.build
+++ b/tests/include/meson.build
@@ -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', ''])
diff --git a/tests/tcg/plugins/meson.build b/tests/tcg/plugins/meson.build
index 41f02f2c7..029342282 100644
--- a/tests/tcg/plugins/meson.build
+++ b/tests/tcg/plugins/meson.build
@@ -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
diff --git a/trace/meson.build b/trace/meson.build
index 3df454935..3a318713c 100644
--- a/trace/meson.build
+++ b/trace/meson.build
@@ -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()
@@ -60,7 +60,7 @@ endforeach
trace_events_all = custom_target('trace-events-all',
output: 'trace-events-all',
input: trace_events_files,
- command: [ 'cat', '@INPUT@' ],
+ command: [ python, '-c', 'import fileinput;[print(line) for line in fileinput.input()]', '@INPUT@' ],
capture: true,
install: get_option('trace_backends') != [ 'nop' ],
install_dir: qemu_datadir)
--
2.49.0.windows.1
On 5/23/25 21:57, oltolm wrote:
> The build failed when run on Windows. I replaced calls to Unix programs
> like `cat` 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.
Thanks for the patch! The Windows build configurations that we support
currently are cross-building from Linux and native build with MSYS2.
MSYS2 is sufficiently POSIX-like, and also has a nice package manager.
Can you share how you set up your build environment, and especially
where you get all the dependencies? Generally we'd prefer to have it
covered in CI to avoid that it breaks again.
Some more comments below.
> import os.path
> +from pathlib import PurePath
>
> from tracetool import out
>
> @@ -30,6 +31,12 @@ def generate_h(event, group):
> if len(event.args) > 0:
> argnames = ", " + argnames
>
> + try:
> + event_filename = os.path.relpath(event.filename)
> + except ValueError:
> + event_filename = event.filename
Can this actually happen during the build? (Same for other backends)
> diff --git a/tests/functional/meson.build b/tests/functional/meson.build
> index 52b4706cf..2e3bd4057 100644
> --- a/tests/functional/meson.build
> +++ b/tests/functional/meson.build
> @@ -413,4 +413,4 @@ endforeach
>
> run_target('precache-functional',
> depends: precache_all,
> - command: ['true'])
> + command: [python, '-c', ''])
I wonder if this can be replaced with alias_target() too; and also the
pre-existing code suggests that alias_target needs at least one target,
but is that really true?
So, maybe all or most uses of 'true' can just go away.
> diff --git a/trace/meson.build b/trace/meson.build
> index 3df454935..3a318713c 100644
> --- a/trace/meson.build
> +++ b/trace/meson.build
> @@ -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()
Even better.
> trace_events_all = custom_target('trace-events-all',
> output: 'trace-events-all',
> input: trace_events_files,
> - command: [ 'cat', '@INPUT@' ],
> + command: [ python, '-c', 'import fileinput;[print(line) for line in fileinput.input()]', '@INPUT@' ],
Maybe put the command in a variable name cat, like
cat = [ python, '-c',
'import fileinput;[print(line) for line in fileinput.input()]']
Thanks,
Paolo
Am Fr., 23. Mai 2025 um 23:28 Uhr schrieb Paolo Bonzini <pbonzini@redhat.com>:
>
> Thanks for the patch! The Windows build configurations that we support
> currently are cross-building from Linux and native build with MSYS2.
> MSYS2 is sufficiently POSIX-like, and also has a nice package manager.
>
> Can you share how you set up your build environment, and especially
> where you get all the dependencies? Generally we'd prefer to have it
> covered in CI to avoid that it breaks again.
I use MSYS2, but I only use `bash` it to run `configure` initially and
afterwards I use `cmd.exe` for running Meson and Ninja.
> Some more comments below.
>
> > import os.path
> > +from pathlib import PurePath
> >
> > from tracetool import out
> >
> > @@ -30,6 +31,12 @@ def generate_h(event, group):
> > if len(event.args) > 0:
> > argnames = ", " + argnames
> >
> > + try:
> > + event_filename = os.path.relpath(event.filename)
> > + except ValueError:
> > + event_filename = event.filename
>
> Can this actually happen during the build? (Same for other backends)
I only tested with the `log` backend.
[18/1577] Generating trace/trace-crypto.h with a custom command
FAILED: trace/trace-crypto.h
"C:\msys64\mingw64\bin\python.exe" "C:/src/qemu/scripts/tracetool.py"
"--backend=log" "--group=crypto" "--format=h"
"C:/src/qemu/crypto/trace-events" "trace/trace-crypto.h"
Traceback (most recent call last):
File "C:/src/qemu/scripts/tracetool.py", line 140, in <module>
main(sys.argv)
File "C:/src/qemu/scripts/tracetool.py", line 134, in main
tracetool.generate(events, arg_group, arg_format, arg_backends,
File "C:\src\qemu\scripts\tracetool\__init__.py", line 449, in generate
tracetool.format.generate(events, format, backend, group)
File "C:\src\qemu\scripts\tracetool\format\__init__.py", line 84, in generate
func(events, backend, group)
File "C:\src\qemu\scripts\tracetool\format\h.py", line 70, in generate
backend.generate(e, group)
File "C:\src\qemu\scripts\tracetool\backend\__init__.py", line 119,
in generate
self._run_function("generate_%s", event, group)
File "C:\src\qemu\scripts\tracetool\backend\__init__.py", line 113,
in _run_function
func(*args, **kwargs)
File "C:\src\qemu\scripts\tracetool\backend\log.py", line 58, in generate_h
event_filename=os.path.relpath(event.filename),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen ntpath>", line 808, in relpath
ValueError: path is on mount 'C:', start on mount 'E:'
> > diff --git a/tests/functional/meson.build b/tests/functional/meson.build
> > index 52b4706cf..2e3bd4057 100644
> > --- a/tests/functional/meson.build
> > +++ b/tests/functional/meson.build
> > @@ -413,4 +413,4 @@ endforeach
> >
> > run_target('precache-functional',
> > depends: precache_all,
> > - command: ['true'])
> > + command: [python, '-c', ''])
>
> I wonder if this can be replaced with alias_target() too; and also the
> pre-existing code suggests that alias_target needs at least one target,
> but is that really true?
>
> So, maybe all or most uses of 'true' can just go away.
I could replace this one with `alias_target()`, but it does need at
least one dependency so I could not replace the others.
Best regards
Oleg Tolmatcev
© 2016 - 2025 Red Hat, Inc.