Add a depend_files: keyword to windows.compile_resources()

Expose depend_files: from the custom_target this creates.

This is the change suggested in #2815, with tests and documentation added.

Fixes #2789 (duplicate #2830)
pull/3668/head
Jon Turney 7 years ago committed by Nirbheek Chauhan
parent bf2e21ec0e
commit aa27f7cec9
  1. 5
      docs/markdown/Windows-module.md
  2. 4
      docs/markdown/snippets/windows-resources-dependencies.md
  3. 4
      mesonbuild/modules/windows.py
  4. 10
      run_unittests.py
  5. 1
      test cases/windows/5 resources/res/meson.build

@ -12,6 +12,9 @@ arguments. Returns an opaque object that you put in the list of
sources for the target you want to have the resources in. This method
has the following keyword argument.
- `args` lists extra arguments to pass to the resource compiler
- `args` lists extra arguments to pass to the resource compiler
- `depend_files` lists resource files that the resource script depends on
(e.g. bitmap, cursor, font, html, icon, message table, binary data or manifest
files referenced by the resource script) (*since 0.47.0*)
- `include_directories` which does the same thing as it does on target
declarations: specifies header search directories

@ -0,0 +1,4 @@
## Windows resource files dependencies
The `compile_resources()` function of the `windows` module now takes
the `depend_files:` keyword.

@ -30,11 +30,12 @@ class WindowsModule(ExtensionModule):
return compilers[l]
raise MesonException('Resource compilation requires a C or C++ compiler.')
@permittedKwargs({'args', 'include_directories'})
@permittedKwargs({'args', 'include_directories', 'depend_files'})
def compile_resources(self, state, args, kwargs):
comp = self.detect_compiler(state.compilers)
extra_args = mesonlib.stringlistify(kwargs.get('args', []))
wrc_deps = extract_as_list(kwargs, 'depend_files', pop = True)
inc_dirs = extract_as_list(kwargs, 'include_directories', pop = True)
for incd in inc_dirs:
if not isinstance(incd.held_object, (str, build.IncludeDirs)):
@ -83,6 +84,7 @@ class WindowsModule(ExtensionModule):
'output': '@BASENAME@.' + suffix,
'input': [src],
'command': [rescomp] + res_args,
'depend_files': wrc_deps,
}
if isinstance(src, (str, mesonlib.File)):

@ -2392,6 +2392,16 @@ class WindowsTests(BasePlatformTests):
for l in cc.ignore_libs:
self.assertEqual(cc.find_library(l, env, []), [])
def test_rc_depends_files(self):
testdir = os.path.join(self.platform_test_dir, '5 resources')
self.init(testdir)
self.build()
# Immediately rebuilding should not do anything
self.assertBuildIsNoop()
# Changing mtime of sample.ico should rebuild everything
self.utime(os.path.join(testdir, 'res', 'sample.ico'))
self.assertRebuiltTarget('prog')
class LinuxlikeTests(BasePlatformTests):
'''

@ -1,4 +1,5 @@
win = import('windows')
res = win.compile_resources('myres.rc',
depend_files: 'sample.ico',
include_directories : inc)

Loading…
Cancel
Save