aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2022-09-25 13:51:07 -0400
committerXavier Claessens <xclaesse@gmail.com>2023-09-09 21:28:22 -0400
commit10708676ade79037f2d2ceeb98500a40a977abef (patch)
treedfe1175738d365c8476df7a629324432543cbb39 /mesonbuild
parent5f46ea116c6f80edd3633c03aacd7427ef3d0cec (diff)
downloadmeson-10708676ade79037f2d2ceeb98500a40a977abef.zip
meson-10708676ade79037f2d2ceeb98500a40a977abef.tar.gz
meson-10708676ade79037f2d2ceeb98500a40a977abef.tar.bz2
gnome.mkenum_simple(): Fix include path when header is in subdir
It was generating #include with the basename of every header file. That assumes that every directory where there are headers are also included into search path when compiling the .c file. Change to use path relative to current subdir, which can be both in build or source directory. That means that we assume that when the .c file is compiled, the target has a include_directories pointing to the directory where gnome.mkenum_simple() has been called, which is generally '.' and added automatically. Also fix type annotation to only allow str and File sources, other types have never been working, it would require to iterate over custom target outputs, etc. Fixes: #7582
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/modules/gnome.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index aee3af2..7de9d46 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -176,7 +176,6 @@ if T.TYPE_CHECKING:
class _MkEnumsCommon(TypedDict):
- sources: T.List[T.Union[FileOrString, build.GeneratedTypes]]
install_header: bool
install_dir: T.Optional[str]
identifier_prefix: T.Optional[str]
@@ -184,6 +183,7 @@ if T.TYPE_CHECKING:
class MkEnumsSimple(_MkEnumsCommon):
+ sources: T.List[FileOrString]
header_prefix: str
decorator: str
function_prefix: str
@@ -191,6 +191,7 @@ if T.TYPE_CHECKING:
class MkEnums(_MkEnumsCommon):
+ sources: T.List[T.Union[FileOrString, build.GeneratedTypes]]
c_template: T.Optional[FileOrString]
h_template: T.Optional[FileOrString]
comments: T.Optional[str]
@@ -221,12 +222,6 @@ _EXTRA_ARGS_KW: KwargInfo[T.List[str]] = KwargInfo(
_MK_ENUMS_COMMON_KWS: T.List[KwargInfo] = [
INSTALL_KW.evolve(name='install_header'),
INSTALL_DIR_KW,
- KwargInfo(
- 'sources',
- ContainerTypeInfo(list, (str, mesonlib.File, CustomTarget, CustomTargetIndex, GeneratedList)),
- listify=True,
- required=True,
- ),
KwargInfo('identifier_prefix', (str, NoneType)),
KwargInfo('symbol_prefix', (str, NoneType)),
]
@@ -1749,6 +1744,13 @@ class GnomeModule(ExtensionModule):
'gnome.mkenums',
*_MK_ENUMS_COMMON_KWS,
DEPENDS_KW,
+ KwargInfo(
+ 'sources',
+ ContainerTypeInfo(list, (str, mesonlib.File, CustomTarget, CustomTargetIndex,
+ GeneratedList)),
+ listify=True,
+ required=True,
+ ),
KwargInfo('c_template', (str, mesonlib.File, NoneType)),
KwargInfo('h_template', (str, mesonlib.File, NoneType)),
KwargInfo('comments', (str, NoneType)),
@@ -1824,6 +1826,12 @@ class GnomeModule(ExtensionModule):
@typed_kwargs(
'gnome.mkenums_simple',
*_MK_ENUMS_COMMON_KWS,
+ KwargInfo(
+ 'sources',
+ ContainerTypeInfo(list, (str, mesonlib.File)),
+ listify=True,
+ required=True,
+ ),
KwargInfo('header_prefix', str, default=''),
KwargInfo('function_prefix', str, default=''),
KwargInfo('body_prefix', str, default=''),
@@ -1851,8 +1859,9 @@ class GnomeModule(ExtensionModule):
if body_prefix != '':
fhead += '%s\n' % body_prefix
fhead += '#include "%s"\n' % hdr_filename
- for hdr in kwargs['sources']:
- fhead += '#include "{}"\n'.format(os.path.basename(str(hdr)))
+ for hdr in self.interpreter.source_strings_to_files(kwargs['sources']):
+ hdr_path = os.path.relpath(hdr.relative_name(), state.subdir)
+ fhead += f'#include "{hdr_path}"\n'
fhead += textwrap.dedent(
'''
#define C_ENUM(v) ((gint) v)