Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions docs/markdown/Windows-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ Compiles Windows `rc` files specified in the positional arguments.
Returns a list of `CustomTarget` objects that you put in the list of sources for
the target you want to have the resources in.

*Since 0.61.0* `CustomTargetIndexes` and `CustomTargets` with more than one output
may be used as positional arguments.

*Since 1.10.0* Changes to included header files are now detected when using
`rc.exe` resource compiler.
*Since 0.61.0* CustomTargetIndexes and CustomTargets with more than out output
*may be used as positional arguments.

This method has the following keyword arguments:

Expand Down
10 changes: 0 additions & 10 deletions docs/markdown/snippets/windows_rc_depfile.md

This file was deleted.

46 changes: 5 additions & 41 deletions mesonbuild/modules/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
from . import ModuleState
from ..compilers import Compiler
from ..interpreter import Interpreter
from ..interpreter.interpreter import SourceOutputs

from typing_extensions import TypedDict

class CompileResources(TypedDict):

depend_files: T.List[mesonlib.FileOrString]
depends: T.List[T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex]]
depends: T.List[T.Union[build.BuildTarget, build.CustomTarget]]
include_directories: T.List[T.Union[str, build.IncludeDirs]]
args: T.List[str]

Expand Down Expand Up @@ -108,33 +108,6 @@ def search_programs(names: T.List[str]) -> T.Optional[ExternalProgram]:

return self._rescomp

def get_preprocessor_target(self,
name_formatted: str,
src: T.Union[str, mesonlib.File, build.CustomTarget, build.CustomTargetIndex],
include_directories: T.List[build.IncludeDirs],
state: ModuleState) -> build.CustomTargetIndex:
compiler = self.detect_compiler(state.environment.coredata.compilers[MachineChoice.HOST])
_sources: T.List[T.Union[mesonlib.File, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList]] = self.interpreter.source_strings_to_files([src])
sources = T.cast('T.List[SourceOutputs]', _sources)

tg = build.CompileTarget(
name_formatted,
state.subdir,
state.subproject,
state.environment,
sources,
'@[email protected]',
compiler.get_preprocessor(),
state.backend,
['-DRC_INVOKED'],
include_directories,
[],
[])
self.interpreter.add_target(tg.name, tg)

private_dir = os.path.relpath(state.backend.get_target_private_dir(tg), state.subdir)
return build.CustomTargetIndex(tg, os.path.join(private_dir, tg.outputs[0]))

@typed_pos_args('windows.compile_resources', varargs=(str, mesonlib.File, build.CustomTarget, build.CustomTargetIndex), min_varargs=1)
@typed_kwargs(
'windows.compile_resources',
Expand All @@ -154,8 +127,7 @@ def compile_resources(self, state: 'ModuleState',
extra_args += state.get_include_args([
build.IncludeDirs('', [], False, [os.path.join('@BUILD_ROOT@', self.interpreter.backend.get_target_dir(d))])
])
include_directories = self.interpreter.extract_incdirs(kwargs)
extra_args += state.get_include_args(include_directories)
extra_args += state.get_include_args(kwargs['include_directories'])

rescomp, rescomp_type = self._find_resource_compiler(state)
if rescomp_type == ResourceCompilerType.rc:
Expand Down Expand Up @@ -212,20 +184,12 @@ def get_names() -> T.Iterable[T.Tuple[str, str, T.Union[str, mesonlib.File, buil
command.append(rescomp)
command.extend(res_args)
depfile: T.Optional[str] = None
extra_depends = wrc_depends.copy()
# instruct binutils windres to generate a preprocessor depfile
if rescomp_type == ResourceCompilerType.windres:
# instruct binutils windres to generate a preprocessor depfile
depfile = f'{output}.d'
command.extend(['--preprocessor-arg=-MD',
'--preprocessor-arg=-MQ@OUTPUT@',
'--preprocessor-arg=-MF@DEPFILE@'])
elif rescomp_type == ResourceCompilerType.rc:
# use preprocessor to detect header dependencies
extra_depends.append(self.get_preprocessor_target(
name_formatted + '_i',
src,
include_directories,
state))

res_targets.append(build.CustomTarget(
name_formatted,
Expand All @@ -237,7 +201,7 @@ def get_names() -> T.Iterable[T.Tuple[str, str, T.Union[str, mesonlib.File, buil
[output],
depfile=depfile,
depend_files=wrc_depend_files,
extra_depends=extra_depends,
extra_depends=wrc_depends,
description='Compiling Windows resource {}',
))

Expand Down
Loading