qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scripts/tracetool:Use posix paths in trace event generation
@ 2024-11-01 20:56 Roque Arcudia Hernandez
  2024-11-04  9:15 ` Daniel P. Berrangé
  0 siblings, 1 reply; 2+ messages in thread
From: Roque Arcudia Hernandez @ 2024-11-01 20:56 UTC (permalink / raw)
  To: jansene, stefanha, mads; +Cc: qemu-devel, Roque Arcudia Hernandez

On windows machines the path seperator is '\\' (backslash) which causes
the tracetool generator to output line information in the source code
with the '\\' character. This in turn confuses the compiler, causing
build breaks.

We now will always use posix paths, so the paths will use a '/'
(forward) slash.

Signed-off-by: Erwin Jansen <jansene@google.com>
Signed-off-by: Roque Arcudia Hernandez <roqueh@google.com>
---
 scripts/tracetool/__init__.py       | 3 ++-
 scripts/tracetool/backend/ftrace.py | 5 +++--
 scripts/tracetool/backend/log.py    | 5 +++--
 scripts/tracetool/backend/syslog.py | 6 +++---
 4 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index bc03238c0f..ccab820532 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -15,6 +15,7 @@
 import re
 import sys
 import weakref
+from pathlib import Path
 
 import tracetool.format
 import tracetool.backend
@@ -55,7 +56,7 @@ def out(*lines, **kwargs):
     for l in lines:
         kwargs['out_lineno'] = out_lineno
         kwargs['out_next_lineno'] = out_lineno + 1
-        kwargs['out_filename'] = out_filename
+        kwargs['out_filename'] = Path(out_filename).as_posix()
         output.append(l % kwargs)
         out_lineno += 1
 
diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backend/ftrace.py
index baed2ae61c..940c9be980 100644
--- a/scripts/tracetool/backend/ftrace.py
+++ b/scripts/tracetool/backend/ftrace.py
@@ -12,7 +12,8 @@
 __email__      = "stefanha@redhat.com"
 
 
-import os.path
+from os.path import relpath
+from pathlib import Path
 
 from tracetool import out
 
@@ -47,7 +48,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=Path(relpath(event.filename)).as_posix(),
         fmt=event.fmt.rstrip("\n"),
         argnames=argnames)
 
diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/log.py
index de27b7e62e..626840eef7 100644
--- a/scripts/tracetool/backend/log.py
+++ b/scripts/tracetool/backend/log.py
@@ -12,7 +12,8 @@
 __email__      = "stefanha@redhat.com"
 
 
-import os.path
+from pathlib import Path
+from os.path import relpath
 
 from tracetool import out
 
@@ -55,7 +56,7 @@ def generate_h(event, group):
         '    }',
         cond=cond,
         event_lineno=event.lineno,
-        event_filename=os.path.relpath(event.filename),
+        event_filename=Path(relpath(event.filename)).as_posix(),
         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 012970f6cc..32e4bba4f9 100644
--- a/scripts/tracetool/backend/syslog.py
+++ b/scripts/tracetool/backend/syslog.py
@@ -11,8 +11,8 @@
 __maintainer__ = "Stefan Hajnoczi"
 __email__      = "stefanha@redhat.com"
 
-
-import os.path
+from os.path import relpath
+from pathlib import Path
 
 from tracetool import out
 
@@ -43,7 +43,7 @@ def generate_h(event, group):
         '    }',
         cond=cond,
         event_lineno=event.lineno,
-        event_filename=os.path.relpath(event.filename),
+        event_filename=Path(relpath(event.filename)).as_posix(),
         name=event.name,
         fmt=event.fmt.rstrip("\n"),
         argnames=argnames)
-- 
2.47.0.163.g1226f6d8fa-goog



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] scripts/tracetool:Use posix paths in trace event generation
  2024-11-01 20:56 [PATCH] scripts/tracetool:Use posix paths in trace event generation Roque Arcudia Hernandez
@ 2024-11-04  9:15 ` Daniel P. Berrangé
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel P. Berrangé @ 2024-11-04  9:15 UTC (permalink / raw)
  To: Roque Arcudia Hernandez; +Cc: jansene, stefanha, mads, qemu-devel

On Fri, Nov 01, 2024 at 08:56:16PM +0000, Roque Arcudia Hernandez wrote:
> On windows machines the path seperator is '\\' (backslash) which causes
> the tracetool generator to output line information in the source code
> with the '\\' character. This in turn confuses the compiler, causing
> build breaks.
> 
> We now will always use posix paths, so the paths will use a '/'
> (forward) slash.
> 
> Signed-off-by: Erwin Jansen <jansene@google.com>
> Signed-off-by: Roque Arcudia Hernandez <roqueh@google.com>
> ---
>  scripts/tracetool/__init__.py       | 3 ++-
>  scripts/tracetool/backend/ftrace.py | 5 +++--
>  scripts/tracetool/backend/log.py    | 5 +++--
>  scripts/tracetool/backend/syslog.py | 6 +++---
>  4 files changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
> index bc03238c0f..ccab820532 100644
> --- a/scripts/tracetool/__init__.py
> +++ b/scripts/tracetool/__init__.py
> @@ -15,6 +15,7 @@
>  import re
>  import sys
>  import weakref
> +from pathlib import Path
>  
>  import tracetool.format
>  import tracetool.backend
> @@ -55,7 +56,7 @@ def out(*lines, **kwargs):
>      for l in lines:
>          kwargs['out_lineno'] = out_lineno
>          kwargs['out_next_lineno'] = out_lineno + 1
> -        kwargs['out_filename'] = out_filename
> +        kwargs['out_filename'] = Path(out_filename).as_posix()
>          output.append(l % kwargs)
>          out_lineno += 1
>  
> diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backend/ftrace.py
> index baed2ae61c..940c9be980 100644
> --- a/scripts/tracetool/backend/ftrace.py
> +++ b/scripts/tracetool/backend/ftrace.py
> @@ -12,7 +12,8 @@
>  __email__      = "stefanha@redhat.com"
>  
>  
> -import os.path
> +from os.path import relpath
> +from pathlib import Path

There is no need to use os.path here - the Path object has
the 'relative_to' method.

>  
>  from tracetool import out
>  
> @@ -47,7 +48,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=Path(relpath(event.filename)).as_posix(),
>          fmt=event.fmt.rstrip("\n"),
>          argnames=argnames)
>  
> diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/log.py
> index de27b7e62e..626840eef7 100644
> --- a/scripts/tracetool/backend/log.py
> +++ b/scripts/tracetool/backend/log.py
> @@ -12,7 +12,8 @@
>  __email__      = "stefanha@redhat.com"
>  
>  
> -import os.path
> +from pathlib import Path
> +from os.path import relpath
>  
>  from tracetool import out
>  
> @@ -55,7 +56,7 @@ def generate_h(event, group):
>          '    }',
>          cond=cond,
>          event_lineno=event.lineno,
> -        event_filename=os.path.relpath(event.filename),
> +        event_filename=Path(relpath(event.filename)).as_posix(),
>          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 012970f6cc..32e4bba4f9 100644
> --- a/scripts/tracetool/backend/syslog.py
> +++ b/scripts/tracetool/backend/syslog.py
> @@ -11,8 +11,8 @@
>  __maintainer__ = "Stefan Hajnoczi"
>  __email__      = "stefanha@redhat.com"
>  
> -
> -import os.path
> +from os.path import relpath
> +from pathlib import Path
>  
>  from tracetool import out
>  
> @@ -43,7 +43,7 @@ def generate_h(event, group):
>          '    }',
>          cond=cond,
>          event_lineno=event.lineno,
> -        event_filename=os.path.relpath(event.filename),
> +        event_filename=Path(relpath(event.filename)).as_posix(),
>          name=event.name,
>          fmt=event.fmt.rstrip("\n"),
>          argnames=argnames)
> -- 
> 2.47.0.163.g1226f6d8fa-goog
> 
> 

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-11-04  9:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-01 20:56 [PATCH] scripts/tracetool:Use posix paths in trace event generation Roque Arcudia Hernandez
2024-11-04  9:15 ` Daniel P. Berrangé

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).