From 2a3cd335fda59085868f1b390106f953990bde58 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Tue, 14 Aug 2018 19:36:35 +0100 Subject: [PATCH 1/2] Extend test case to cover issue #3999 Extend test case for issue #3575 for Windows resource files with the same name to cover the case where duplicate outputs exist due to use of pathnames. Also Test using file objects as well as literal filenames --- .../exe3/meson.build | 5 +++++ .../exe3/src_dll/main.c | 6 ++++++ .../exe3/src_dll/version.rc | 11 +++++++++++ .../exe3/src_exe/main.c | 3 +++ .../exe3/src_exe/version.rc | 11 +++++++++++ .../exe4/meson.build | 5 +++++ .../exe4/src_dll/main.c | 6 ++++++ .../exe4/src_dll/version.rc | 11 +++++++++++ .../exe4/src_exe/main.c | 3 +++ .../exe4/src_exe/version.rc | 11 +++++++++++ .../meson.build | 2 ++ 11 files changed, 74 insertions(+) create mode 100644 test cases/windows/15 resource scripts with duplicate filenames/exe3/meson.build create mode 100644 test cases/windows/15 resource scripts with duplicate filenames/exe3/src_dll/main.c create mode 100644 test cases/windows/15 resource scripts with duplicate filenames/exe3/src_dll/version.rc create mode 100644 test cases/windows/15 resource scripts with duplicate filenames/exe3/src_exe/main.c create mode 100644 test cases/windows/15 resource scripts with duplicate filenames/exe3/src_exe/version.rc create mode 100644 test cases/windows/15 resource scripts with duplicate filenames/exe4/meson.build create mode 100644 test cases/windows/15 resource scripts with duplicate filenames/exe4/src_dll/main.c create mode 100644 test cases/windows/15 resource scripts with duplicate filenames/exe4/src_dll/version.rc create mode 100644 test cases/windows/15 resource scripts with duplicate filenames/exe4/src_exe/main.c create mode 100644 test cases/windows/15 resource scripts with duplicate filenames/exe4/src_exe/version.rc diff --git a/test cases/windows/15 resource scripts with duplicate filenames/exe3/meson.build b/test cases/windows/15 resource scripts with duplicate filenames/exe3/meson.build new file mode 100644 index 000000000..1b97435e7 --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/exe3/meson.build @@ -0,0 +1,5 @@ +dll_res = win.compile_resources('src_dll/version.rc') +shared_library('lib3', 'src_dll/main.c', dll_res) + +exe_res = win.compile_resources('src_exe/version.rc') +executable('exe3', 'src_exe/main.c', exe_res) diff --git a/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_dll/main.c b/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_dll/main.c new file mode 100644 index 000000000..673b5e4f9 --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_dll/main.c @@ -0,0 +1,6 @@ +#include + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + return TRUE; +} diff --git a/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_dll/version.rc b/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_dll/version.rc new file mode 100644 index 000000000..abdbaaa64 --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_dll/version.rc @@ -0,0 +1,11 @@ + #include + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,0 + PRODUCTVERSION 1,0,0,0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS 0 + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP +BEGIN +END diff --git a/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_exe/main.c b/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_exe/main.c new file mode 100644 index 000000000..11b7fad8e --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_exe/main.c @@ -0,0 +1,3 @@ +int main(int argc, char **argv) { + return 0; +} diff --git a/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_exe/version.rc b/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_exe/version.rc new file mode 100644 index 000000000..abdbaaa64 --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_exe/version.rc @@ -0,0 +1,11 @@ + #include + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,0 + PRODUCTVERSION 1,0,0,0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS 0 + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP +BEGIN +END diff --git a/test cases/windows/15 resource scripts with duplicate filenames/exe4/meson.build b/test cases/windows/15 resource scripts with duplicate filenames/exe4/meson.build new file mode 100644 index 000000000..2ae3a7125 --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/exe4/meson.build @@ -0,0 +1,5 @@ +dll_res = win.compile_resources(files('src_dll/version.rc')) +shared_library('lib4', 'src_dll/main.c', dll_res) + +exe_res = win.compile_resources(files('src_exe/version.rc')) +executable('exe4', 'src_exe/main.c', exe_res) diff --git a/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_dll/main.c b/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_dll/main.c new file mode 100644 index 000000000..673b5e4f9 --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_dll/main.c @@ -0,0 +1,6 @@ +#include + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + return TRUE; +} diff --git a/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_dll/version.rc b/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_dll/version.rc new file mode 100644 index 000000000..abdbaaa64 --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_dll/version.rc @@ -0,0 +1,11 @@ + #include + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,0 + PRODUCTVERSION 1,0,0,0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS 0 + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP +BEGIN +END diff --git a/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_exe/main.c b/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_exe/main.c new file mode 100644 index 000000000..11b7fad8e --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_exe/main.c @@ -0,0 +1,3 @@ +int main(int argc, char **argv) { + return 0; +} diff --git a/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_exe/version.rc b/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_exe/version.rc new file mode 100644 index 000000000..abdbaaa64 --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_exe/version.rc @@ -0,0 +1,11 @@ + #include + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,0 + PRODUCTVERSION 1,0,0,0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS 0 + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP +BEGIN +END diff --git a/test cases/windows/15 resource scripts with duplicate filenames/meson.build b/test cases/windows/15 resource scripts with duplicate filenames/meson.build index 4073a8e7c..9fa352520 100644 --- a/test cases/windows/15 resource scripts with duplicate filenames/meson.build +++ b/test cases/windows/15 resource scripts with duplicate filenames/meson.build @@ -5,6 +5,8 @@ win = import('windows') subdir('a') subdir('b') subdir('c') +subdir('exe3') +subdir('exe4') main = win.compile_resources('rsrc.rc') From c2f3785383f3083de57930246e47d65d9bda77b9 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Tue, 14 Aug 2018 20:13:33 +0100 Subject: [PATCH 2/2] Use unique output for windows.compile_resources() Use a unique output filename for windows.compile_resources() even when input basename is not unique. --- mesonbuild/modules/windows.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/mesonbuild/modules/windows.py b/mesonbuild/modules/windows.py index 19f3e2b73..24bd750ca 100644 --- a/mesonbuild/modules/windows.py +++ b/mesonbuild/modules/windows.py @@ -88,35 +88,38 @@ class WindowsModule(ExtensionModule): if hasattr(src, 'held_object'): src = src.held_object - res_kwargs = { - 'output': '@BASENAME@.' + suffix, - 'input': [src], - 'command': [rescomp] + res_args, - 'depend_files': wrc_depend_files, - 'depends': wrc_depends, - } - if isinstance(src, str): - name = 'file {!r}'.format(os.path.join(state.subdir, src)) + name_format = 'file {!r}' + name = format(os.path.join(state.subdir, src)) elif isinstance(src, mesonlib.File): - name = 'file {!r}'.format(src.relative_name()) + name_format = 'file {!r}' + name = format(src.relative_name()) 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()) + name_format = 'target {!r}' + name = 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_kwargs = { + 'output': name + '_@BASENAME@.' + suffix, + 'input': [src], + 'command': [rescomp] + res_args, + 'depend_files': wrc_depend_files, + 'depends': wrc_depends, + } + # 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)) + res_targets.append(build.CustomTarget('Windows resource for ' + name_format.format(name), state.subdir, state.subproject, res_kwargs)) add_target(args)