diff options
Diffstat (limited to 'mesonbuild/modules/windows.py')
-rw-r--r-- | mesonbuild/modules/windows.py | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/mesonbuild/modules/windows.py b/mesonbuild/modules/windows.py index c16d7a8..dc6e9d8 100644 --- a/mesonbuild/modules/windows.py +++ b/mesonbuild/modules/windows.py @@ -67,11 +67,42 @@ class WindowsModule(ExtensionModule): suffix = 'o' if not rescomp.found(): raise MesonException('Could not find Windows resource compiler %s.' % ' '.join(rescomp.get_command())) - res_kwargs = {'output': '@BASENAME@.' + suffix, - 'arguments': res_args} - res_gen = build.Generator([rescomp], res_kwargs) - res_output = res_gen.process_files('Windows resource', args, state) - return ModuleReturnValue(res_output, [res_output]) + + res_targets = [] + + def add_target(src): + if isinstance(src, list): + for subsrc in src: + add_target(subsrc) + return + + 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() |