diff options
-rw-r--r-- | docs/markdown/snippets/windows-resources-dependencies.md | 3 | ||||
-rw-r--r-- | mesonbuild/modules/windows.py | 5 | ||||
-rwxr-xr-x | run_unittests.py | 8 | ||||
-rw-r--r-- | test cases/windows/5 resources/prog.c | 2 |
4 files changed, 17 insertions, 1 deletions
diff --git a/docs/markdown/snippets/windows-resources-dependencies.md b/docs/markdown/snippets/windows-resources-dependencies.md index f446ea5..e30e18c 100644 --- a/docs/markdown/snippets/windows-resources-dependencies.md +++ b/docs/markdown/snippets/windows-resources-dependencies.md @@ -2,3 +2,6 @@ The `compile_resources()` function of the `windows` module now takes the `depend_files:` keyword. + +When using binutils's `windres`, dependencies on files `#include`'d by the +preprocessor are now automatically tracked. diff --git a/mesonbuild/modules/windows.py b/mesonbuild/modules/windows.py index adb73d7..c6c9a64 100644 --- a/mesonbuild/modules/windows.py +++ b/mesonbuild/modules/windows.py @@ -100,6 +100,11 @@ class WindowsModule(ExtensionModule): # Path separators are not allowed in target names name = name.replace('/', '_').replace('\\', '_') + # instruct binutils windres to generate a preprocessor depfile + if comp.id != 'msvc': + res_kwargs['depfile'] = res_kwargs['output'] + '.d' + res_kwargs['command'] += ['--preprocessor-arg=-MD', '--preprocessor-arg=-MQ@OUTPUT@', '--preprocessor-arg=-MF@DEPFILE@'] + res_targets.append(build.CustomTarget('Windows resource for ' + name, state.subdir, state.subproject, res_kwargs)) add_target(args) diff --git a/run_unittests.py b/run_unittests.py index b599a5f..0814b34 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -2397,9 +2397,15 @@ class WindowsTests(BasePlatformTests): self.build() # Immediately rebuilding should not do anything self.assertBuildIsNoop() - # Changing mtime of sample.ico should rebuild everything + # Changing mtime of sample.ico should rebuild prog self.utime(os.path.join(testdir, 'res', 'sample.ico')) self.assertRebuiltTarget('prog') + # Changing mtime of resource.h should rebuild myres.rc and then prog + # (resource compiler depfile generation is not yet implemented for msvc) + env = Environment(testdir, self.builddir, get_fake_options(self.prefix), []) + if env.detect_c_compiler(False).get_id() != 'msvc': + self.utime(os.path.join(testdir, 'inc', 'resource', 'resource.h')) + self.assertRebuiltTarget('prog') class LinuxlikeTests(BasePlatformTests): diff --git a/test cases/windows/5 resources/prog.c b/test cases/windows/5 resources/prog.c index 2bef6a2..afbb6ae 100644 --- a/test cases/windows/5 resources/prog.c +++ b/test cases/windows/5 resources/prog.c @@ -1,5 +1,7 @@ #include<windows.h> +// deliberately don't get MY_ICON from resource.h so that depfile generation can +// be exercised in the WindowsTests.test_rc_depends_files unit test #define MY_ICON 1 int APIENTRY |