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 <jans...@google.com>
> Signed-off-by: Roque Arcudia Hernandez <roq...@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__      = "stefa...@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__      = "stefa...@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__      = "stefa...@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 :|


Reply via email to