diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2025-01-10 15:10:09 +0100 |
|---|---|---|
| committer | Eli Schwartz <eschwartz93@gmail.com> | 2025-03-09 13:05:08 -0400 |
| commit | 528696300afd3236e173242e1e09d1ac80dfec81 (patch) | |
| tree | f3989f6d6c49e188201719dd13468e10128a755d /mesonbuild/scripts | |
| parent | 9c125a26dbf1b6ecc674df2bd1abc02ca48da2cd (diff) | |
| download | meson-528696300afd3236e173242e1e09d1ac80dfec81.tar.gz | |
mesonlib: extract and optimize is_parent_path
Introduce an alternative to os.path.commonpath(name, path) == path,
which is a common idiom throughout Meson. Call it is_parent_path
just like the existing static method in Generator.
It is a bit faster and handles drives on Windows without the need
for an exception handler.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'mesonbuild/scripts')
| -rw-r--r-- | mesonbuild/scripts/gtkdochelper.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/mesonbuild/scripts/gtkdochelper.py b/mesonbuild/scripts/gtkdochelper.py index 06844289f..a0b090584 100644 --- a/mesonbuild/scripts/gtkdochelper.py +++ b/mesonbuild/scripts/gtkdochelper.py @@ -7,7 +7,10 @@ import sys, os import subprocess import shutil import argparse -from ..mesonlib import MesonException, Popen_safe, is_windows, is_cygwin, split_args +from ..mesonlib import ( + MesonException, Popen_safe, is_windows, is_cygwin, is_parent_path, + split_args, +) from . import destdir_join import typing as T @@ -112,7 +115,7 @@ def build_gtkdoc(source_root: str, build_root: str, doc_subdir: str, src_subdirs # FIXME: Use mesonlib.File objects so we don't need to do this if not os.path.isabs(f): f = os.path.join(doc_src, f) - elif os.path.commonpath([f, build_root]) == build_root: + elif is_parent_path(build_root, f): continue shutil.copyfile(f, os.path.join(abs_out, os.path.basename(f))) |
