aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/markdown/Gnome-module.md7
-rw-r--r--mesonbuild/modules/gnome.py27
-rw-r--r--test cases/frameworks/7 gnome/mkenums/meson.build10
-rw-r--r--test cases/frameworks/7 gnome/mkenums/subdir/h2.h.in5
-rw-r--r--test cases/frameworks/7 gnome/mkenums/subdir/h3.h5
-rw-r--r--test cases/frameworks/7 gnome/mkenums/subdir/meson.build2
6 files changed, 47 insertions, 9 deletions
diff --git a/docs/markdown/Gnome-module.md b/docs/markdown/Gnome-module.md
index d0cd24a..013e8c8 100644
--- a/docs/markdown/Gnome-module.md
+++ b/docs/markdown/Gnome-module.md
@@ -204,6 +204,13 @@ for a build target, you must add the generated header to the build
target's list of sources to codify the dependency. This is true for
all generated sources, not just `mkenums_simple`.
+The generated source file includes all headers passed to the sources keyword
+argument, using paths relative to current build or source directory. That means
+that targets that compile the generated source file must have the current
+directory in its `include_directories`. *Since 1.3.0* `sources` outside of
+current directory do not require adding those directories into
+`include_directories` anymore.
+
* `body_prefix`: additional prefix at the top of the body file,
e.g. for extra includes
* `decorator`: optional decorator for the function declarations,
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)
diff --git a/test cases/frameworks/7 gnome/mkenums/meson.build b/test cases/frameworks/7 gnome/mkenums/meson.build
index 4cf4dcf..2886be9 100644
--- a/test cases/frameworks/7 gnome/mkenums/meson.build
+++ b/test cases/frameworks/7 gnome/mkenums/meson.build
@@ -162,3 +162,13 @@ main = configure_file(
enumexe6 = executable('enumprog6', main, enums_c2, enums_h6,
dependencies : gobj)
test('enum test 4', enumexe6)
+
+# Test with headers coming from other directories
+# https://github.com/mesonbuild/meson/pull/10855
+subdir('subdir')
+enums7 = gnome.mkenums_simple('enums7', sources: ['meson-sample.h', h2, h3])
+main = configure_file(
+ input : 'main.c',
+ output : 'mai7.c',
+ configuration : {'ENUM_FILE': 'enums7.h'})
+test('enums7 test', executable('enumprog7', main, enums7, dependencies : gobj))
diff --git a/test cases/frameworks/7 gnome/mkenums/subdir/h2.h.in b/test cases/frameworks/7 gnome/mkenums/subdir/h2.h.in
new file mode 100644
index 0000000..7b40c4b
--- /dev/null
+++ b/test cases/frameworks/7 gnome/mkenums/subdir/h2.h.in
@@ -0,0 +1,5 @@
+#pragma once
+
+typedef enum {
+ MESON_SUBDIR_FOO,
+} MesonSubdir;
diff --git a/test cases/frameworks/7 gnome/mkenums/subdir/h3.h b/test cases/frameworks/7 gnome/mkenums/subdir/h3.h
new file mode 100644
index 0000000..9049d5c
--- /dev/null
+++ b/test cases/frameworks/7 gnome/mkenums/subdir/h3.h
@@ -0,0 +1,5 @@
+#pragma once
+
+typedef enum {
+ MESON_SUBDIR2_FOO,
+} MesonSubdir2;
diff --git a/test cases/frameworks/7 gnome/mkenums/subdir/meson.build b/test cases/frameworks/7 gnome/mkenums/subdir/meson.build
new file mode 100644
index 0000000..0b03846
--- /dev/null
+++ b/test cases/frameworks/7 gnome/mkenums/subdir/meson.build
@@ -0,0 +1,2 @@
+h2 = configure_file(input: 'h2.h.in', output: 'h2.h', copy: true)
+h3 = files('h3.h')