diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:41:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:41:38 +0000 |
commit | 7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch) | |
tree | 4a2738d69fa2814659fdadddf5826282e73d81f4 /test cases/windows/5 resources | |
parent | Initial commit. (diff) | |
download | meson-upstream.tar.xz meson-upstream.zip |
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | test cases/windows/5 resources/inc/meson.build | 1 | ||||
-rw-r--r-- | test cases/windows/5 resources/inc/resource/resource.h | 1 | ||||
-rw-r--r-- | test cases/windows/5 resources/meson.build | 69 | ||||
-rw-r--r-- | test cases/windows/5 resources/prog.c | 21 | ||||
-rw-r--r-- | test cases/windows/5 resources/res/dummy.c | 0 | ||||
-rw-r--r-- | test cases/windows/5 resources/res/meson.build | 10 | ||||
-rw-r--r-- | test cases/windows/5 resources/res/myres.rc | 4 | ||||
-rw-r--r-- | test cases/windows/5 resources/res/sample.ico | bin | 0 -> 9662 bytes |
8 files changed, 106 insertions, 0 deletions
diff --git a/test cases/windows/5 resources/inc/meson.build b/test cases/windows/5 resources/inc/meson.build new file mode 100644 index 0000000..b8b511a --- /dev/null +++ b/test cases/windows/5 resources/inc/meson.build @@ -0,0 +1 @@ +inc = include_directories('resource') diff --git a/test cases/windows/5 resources/inc/resource/resource.h b/test cases/windows/5 resources/inc/resource/resource.h new file mode 100644 index 0000000..dbdd509 --- /dev/null +++ b/test cases/windows/5 resources/inc/resource/resource.h @@ -0,0 +1 @@ +#define ICON_ID 1 diff --git a/test cases/windows/5 resources/meson.build b/test cases/windows/5 resources/meson.build new file mode 100644 index 0000000..27b2fcc --- /dev/null +++ b/test cases/windows/5 resources/meson.build @@ -0,0 +1,69 @@ +project('winmain', 'c') + +# MinGW windres has a bug due to which it doesn't parse args with space properly: +# https://github.com/mesonbuild/meson/pull/1346 +# https://sourceware.org/bugzilla/show_bug.cgi?id=4933 +if ['gcc', 'clang'].contains(meson.get_compiler('c').get_id()) and host_machine.system() == 'windows' + # Construct build_to_src and skip this test if it has spaces + # because then the -I flag to windres will also have spaces + # and we know the test will fail + src_parts = meson.source_root().split('/') + build_parts = meson.build_root().split('/') + + # Get the common path (which might just be '/' or 'C:/') + common = [] + done = false + count = 0 + if src_parts.length() > build_parts.length() + parts = build_parts + other = src_parts + else + parts = src_parts + other = build_parts + endif + foreach part : parts + if not done and part == other.get(count) + common += [part] + else + done = true + endif + count += 1 + endforeach + + # Create path components to go down from the build root to the common path + count = 0 + rel = build_parts + foreach build : build_parts + if count < build_parts.length() - common.length() + rel += ['..'] + endif + count += 1 + endforeach + + # Create path components to go up from the common path to the build root + count = 0 + foreach src : src_parts + if count >= common.length() + rel += [src] + endif + count += 1 + endforeach + + build_to_src = '/'.join(rel) + + if build_to_src.contains(' ') + message('build_to_src is: ' + build_to_src) + error('MESON_SKIP_TEST build_to_src has spaces') + endif + # Welcome to the end of this conditional. + # We hope you never have to implement something like this. +endif + +subdir('inc') +subdir('res') + +exe = executable('prog', 'prog.c', + res, + gui_app : true) + +test('winmain', exe) diff --git a/test cases/windows/5 resources/prog.c b/test cases/windows/5 resources/prog.c new file mode 100644 index 0000000..3409c39 --- /dev/null +++ b/test cases/windows/5 resources/prog.c @@ -0,0 +1,21 @@ +#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 +WinMain( + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpszCmdLine, + int nCmdShow) { + HICON hIcon; + hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(MY_ICON)); +// avoid unused argument error while matching template + ((void)hInstance); + ((void)hPrevInstance); + ((void)lpszCmdLine); + ((void)nCmdShow); + return hIcon ? 0 : 1; +} diff --git a/test cases/windows/5 resources/res/dummy.c b/test cases/windows/5 resources/res/dummy.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/windows/5 resources/res/dummy.c diff --git a/test cases/windows/5 resources/res/meson.build b/test cases/windows/5 resources/res/meson.build new file mode 100644 index 0000000..74e0778 --- /dev/null +++ b/test cases/windows/5 resources/res/meson.build @@ -0,0 +1,10 @@ +win = import('windows') + +res = win.compile_resources('myres.rc', + depend_files: 'sample.ico', + include_directories : inc, + args : [['-DFOO'], '-DBAR']) + +# test that with MSVC tools, LIB/LINK invokes CVTRES with correct /MACHINE +static_library('reslib', res, 'dummy.c') +shared_library('shreslib', res, 'dummy.c') diff --git a/test cases/windows/5 resources/res/myres.rc b/test cases/windows/5 resources/res/myres.rc new file mode 100644 index 0000000..802bc7b --- /dev/null +++ b/test cases/windows/5 resources/res/myres.rc @@ -0,0 +1,4 @@ +#include<windows.h> +#include"resource.h" + +ICON_ID ICON "sample.ico" diff --git a/test cases/windows/5 resources/res/sample.ico b/test cases/windows/5 resources/res/sample.ico Binary files differnew file mode 100644 index 0000000..24bd3d9 --- /dev/null +++ b/test cases/windows/5 resources/res/sample.ico |