diff options
| author | Xavier Claessens <xavier.claessens@collabora.com> | 2021-05-11 09:18:47 -0400 |
|---|---|---|
| committer | Xavier Claessens <xclaesse@gmail.com> | 2021-05-12 15:54:37 -0400 |
| commit | 4e312c19e693a69b0650ce6c8a8903163c959996 (patch) | |
| tree | 6f0eee6b0281536078d9b105a4985f504c9b930b /mesonbuild/modules/__init__.py | |
| parent | 44acefd8365c0ccca428e5ef69153c059aa8e575 (diff) | |
| download | meson-4e312c19e693a69b0650ce6c8a8903163c959996.tar.gz | |
gnome: Fix gtkdoc generation
install_scripts used to replace @BUILD_ROOT@ and @SOURCE_ROOT@ but it
was not documented and got removed in Meson 0.58.0. gnome.gtkdoc() was
relying on that behaviour, but it has always been broken in the case the
source or build directory contains spaces.
Fix this by changing get_include_args() to substitue paths directly
which will then get escaped correctly.
Add a unit test that builds GObject documentation which is where this
issue has been spotted.
Fixes: #8744
Diffstat (limited to 'mesonbuild/modules/__init__.py')
| -rw-r--r-- | mesonbuild/modules/__init__.py | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/mesonbuild/modules/__init__.py b/mesonbuild/modules/__init__.py index ddb5e3e6c..c0970294c 100644 --- a/mesonbuild/modules/__init__.py +++ b/mesonbuild/modules/__init__.py @@ -56,6 +56,33 @@ class ModuleState: self.target_machine = interpreter.builtin['target_machine'].held_object self.current_node = interpreter.current_node + def get_include_args(self, include_dirs, prefix='-I'): + if not include_dirs: + return [] + + srcdir = self.environment.get_source_dir() + builddir = self.environment.get_build_dir() + + dirs_str = [] + for dirs in unholder(include_dirs): + if isinstance(dirs, str): + dirs_str += [f'{prefix}{dirs}'] + continue + + # Should be build.IncludeDirs object. + basedir = dirs.get_curdir() + for d in dirs.get_incdirs(): + expdir = os.path.join(basedir, d) + srctreedir = os.path.join(srcdir, expdir) + buildtreedir = os.path.join(builddir, expdir) + dirs_str += [f'{prefix}{buildtreedir}', + f'{prefix}{srctreedir}'] + for d in dirs.get_extra_build_dirs(): + dirs_str += [f'{prefix}{d}'] + + return dirs_str + + class ModuleObject: """Base class for all objects returned by modules """ @@ -71,33 +98,6 @@ class ModuleObject: class ExtensionModule(ModuleObject): pass -def get_include_args(include_dirs, prefix='-I'): - ''' - Expand include arguments to refer to the source and build dirs - by using @SOURCE_ROOT@ and @BUILD_ROOT@ for later substitution - ''' - if not include_dirs: - return [] - - dirs_str = [] - for dirs in unholder(include_dirs): - if isinstance(dirs, str): - dirs_str += [f'{prefix}{dirs}'] - continue - - # Should be build.IncludeDirs object. - basedir = dirs.get_curdir() - for d in dirs.get_incdirs(): - expdir = os.path.join(basedir, d) - srctreedir = os.path.join('@SOURCE_ROOT@', expdir) - buildtreedir = os.path.join('@BUILD_ROOT@', expdir) - dirs_str += [f'{prefix}{buildtreedir}', - f'{prefix}{srctreedir}'] - for d in dirs.get_extra_build_dirs(): - dirs_str += [f'{prefix}{d}'] - - return dirs_str - def is_module_library(fname): ''' Check if the file is a library-like file generated by a module-specific |
