aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules/windows.py
diff options
context:
space:
mode:
authorAndrei Alexeyev <0x416b617269@gmail.com>2017-12-22 20:16:56 +0200
committerAndrei Alexeyev <0x416b617269@gmail.com>2018-01-12 23:36:48 +0200
commitf8bd1c5ff26bbb6b88dedcb400a33841201bf4eb (patch)
tree3f9193278b3d6fc20adadee4fa14a282e37a5638 /mesonbuild/modules/windows.py
parentef7cb9f280175d026b16e8e02ecda9ec87d7fd6d (diff)
downloadmeson-f8bd1c5ff26bbb6b88dedcb400a33841201bf4eb.zip
meson-f8bd1c5ff26bbb6b88dedcb400a33841201bf4eb.tar.gz
meson-f8bd1c5ff26bbb6b88dedcb400a33841201bf4eb.tar.bz2
windows.compile_resources: fix compiling multiple resources within one project
Diffstat (limited to 'mesonbuild/modules/windows.py')
-rw-r--r--mesonbuild/modules/windows.py40
1 files changed, 33 insertions, 7 deletions
diff --git a/mesonbuild/modules/windows.py b/mesonbuild/modules/windows.py
index 22bf49b..dc6e9d8 100644
--- a/mesonbuild/modules/windows.py
+++ b/mesonbuild/modules/windows.py
@@ -68,15 +68,41 @@ class WindowsModule(ExtensionModule):
if not rescomp.found():
raise MesonException('Could not find Windows resource compiler %s.' % ' '.join(rescomp.get_command()))
- res_kwargs = {
- 'output': '@BASENAME@.' + suffix,
- 'input': args,
- 'command': [rescomp] + res_args,
- }
+ res_targets = []
- res_target = build.CustomTarget('Windows resource', state.subdir, state.subproject, res_kwargs)
+ def add_target(src):
+ if isinstance(src, list):
+ for subsrc in src:
+ add_target(subsrc)
+ return
- return ModuleReturnValue(res_target, [res_target])
+ if hasattr(src, 'held_object'):
+ src = src.held_object
+
+ res_kwargs = {
+ 'output': '@BASENAME@.' + suffix,
+ 'input': [src],
+ 'command': [rescomp] + res_args,
+ }
+
+ if isinstance(src, (str, mesonlib.File)):
+ name = 'file {!r}'.format(str(src))
+ elif isinstance(src, build.CustomTarget):
+ if len(src.get_outputs()) > 1:
+ raise MesonException('windows.compile_resources does not accept custom targets with more than 1 output.')
+
+ name = 'target {!r}'.format(src.get_id())
+ else:
+ raise MesonException('Unexpected source type {!r}. windows.compile_resources accepts only strings, files, custom targets, and lists thereof.'.format(src))
+
+ # Path separators are not allowed in target names
+ name = name.replace('/', '_').replace('\\', '_')
+
+ res_targets.append(build.CustomTarget('Windows resource for ' + name, state.subdir, state.subproject, res_kwargs))
+
+ add_target(args)
+
+ return ModuleReturnValue(res_targets, [res_targets])
def initialize():
return WindowsModule()