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 | |
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 'test cases/windows')
106 files changed, 1033 insertions, 0 deletions
diff --git a/test cases/windows/1 basic/meson.build b/test cases/windows/1 basic/meson.build new file mode 100644 index 0000000..03d5436 --- /dev/null +++ b/test cases/windows/1 basic/meson.build @@ -0,0 +1,4 @@ +project('wintest', 'c') + +prog = executable('prog', 'prog.c', install : true) +test('wintest', prog) diff --git a/test cases/windows/1 basic/prog.c b/test cases/windows/1 basic/prog.c new file mode 100644 index 0000000..f400e12 --- /dev/null +++ b/test cases/windows/1 basic/prog.c @@ -0,0 +1,5 @@ +#include <windows.h> + +int main(void) { + return 0; +} diff --git a/test cases/windows/1 basic/test.json b/test cases/windows/1 basic/test.json new file mode 100644 index 0000000..650a6e2 --- /dev/null +++ b/test cases/windows/1 basic/test.json @@ -0,0 +1,6 @@ +{ + "installed": [ + {"type": "file", "file": "usr/bin/prog.exe"}, + {"type": "pdb", "file": "usr/bin/prog"} + ] +} diff --git a/test cases/windows/10 vs module defs generated custom target/meson.build b/test cases/windows/10 vs module defs generated custom target/meson.build new file mode 100644 index 0000000..7728ca7 --- /dev/null +++ b/test cases/windows/10 vs module defs generated custom target/meson.build @@ -0,0 +1,5 @@ +project('generated_dll_module_defs', 'c') + +subdir('subdir') +exe = executable('prog', 'prog.c', link_with : shlib) +test('runtest', exe) diff --git a/test cases/windows/10 vs module defs generated custom target/prog.c b/test cases/windows/10 vs module defs generated custom target/prog.c new file mode 100644 index 0000000..066ac22 --- /dev/null +++ b/test cases/windows/10 vs module defs generated custom target/prog.c @@ -0,0 +1,5 @@ +int somedllfunc(void); + +int main(void) { + return somedllfunc() == 42 ? 0 : 1; +} diff --git a/test cases/windows/10 vs module defs generated custom target/subdir/make_def.py b/test cases/windows/10 vs module defs generated custom target/subdir/make_def.py new file mode 100755 index 0000000..50acfb5 --- /dev/null +++ b/test cases/windows/10 vs module defs generated custom target/subdir/make_def.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 +import sys + +with open(sys.argv[1], 'w') as f: + print('EXPORTS', file=f) + print(' somedllfunc', file=f) diff --git a/test cases/windows/10 vs module defs generated custom target/subdir/meson.build b/test cases/windows/10 vs module defs generated custom target/subdir/meson.build new file mode 100644 index 0000000..c4ae33a --- /dev/null +++ b/test cases/windows/10 vs module defs generated custom target/subdir/meson.build @@ -0,0 +1,7 @@ +make_def = find_program('make_def.py') + +def_file = custom_target('gen_def', + command: [make_def, '@OUTPUT@'], + output: 'somedll.def') + +shlib = shared_library('somedll', 'somedll.c', vs_module_defs: def_file) diff --git a/test cases/windows/10 vs module defs generated custom target/subdir/somedll.c b/test cases/windows/10 vs module defs generated custom target/subdir/somedll.c new file mode 100644 index 0000000..f095b18 --- /dev/null +++ b/test cases/windows/10 vs module defs generated custom target/subdir/somedll.c @@ -0,0 +1,3 @@ +int somedllfunc(void) { + return 42; +} diff --git a/test cases/windows/11 exe implib/meson.build b/test cases/windows/11 exe implib/meson.build new file mode 100644 index 0000000..0a38ec1 --- /dev/null +++ b/test cases/windows/11 exe implib/meson.build @@ -0,0 +1,7 @@ +project('wintest', 'c') + +# Test that we can produce an implib for an executable on Windows, and that it's +# name can be set, and that it is installed along with the executable + +executable('prog', 'prog.c', install: true, implib: true) +executable('prog2', 'prog.c', install: true, implib: 'burble', install_dir: get_option('bindir')) diff --git a/test cases/windows/11 exe implib/prog.c b/test cases/windows/11 exe implib/prog.c new file mode 100644 index 0000000..aa3bc5c --- /dev/null +++ b/test cases/windows/11 exe implib/prog.c @@ -0,0 +1,6 @@ +#include <windows.h> + +int __declspec(dllexport) +main(void) { + return 0; +} diff --git a/test cases/windows/11 exe implib/test.json b/test cases/windows/11 exe implib/test.json new file mode 100644 index 0000000..f719568 --- /dev/null +++ b/test cases/windows/11 exe implib/test.json @@ -0,0 +1,12 @@ +{ + "installed": [ + {"type": "file", "file": "usr/bin/prog.exe"}, + {"type": "pdb", "file": "usr/bin/prog"}, + {"type": "file", "file": "usr/bin/prog2.exe"}, + {"type": "pdb", "file": "usr/bin/prog2"}, + {"type": "file", "platform": "gcc", "file": "usr/lib/libprog.exe.a"}, + {"type": "file", "platform": "gcc", "file": "usr/lib/libburble.a"}, + {"type": "file", "platform": "msvc", "file": "usr/lib/prog.exe.lib"}, + {"type": "file", "platform": "msvc", "file": "usr/lib/burble.lib"} + ] +} diff --git a/test cases/windows/12 resources with custom targets/meson.build b/test cases/windows/12 resources with custom targets/meson.build new file mode 100644 index 0000000..282272d --- /dev/null +++ b/test cases/windows/12 resources with custom targets/meson.build @@ -0,0 +1,70 @@ +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('res') + +foreach id : [0, 1, 2] + exe = executable('prog_@0@'.format(id), 'prog.c', + res[id], + gui_app : true) + + test('winmain_@0@'.format(id), exe) +endforeach diff --git a/test cases/windows/12 resources with custom targets/prog.c b/test cases/windows/12 resources with custom targets/prog.c new file mode 100644 index 0000000..cb6892d --- /dev/null +++ b/test cases/windows/12 resources with custom targets/prog.c @@ -0,0 +1,19 @@ +#include<windows.h> + +#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/12 resources with custom targets/res/gen-res.py b/test cases/windows/12 resources with custom targets/res/gen-res.py new file mode 100755 index 0000000..e5ef6b1 --- /dev/null +++ b/test cases/windows/12 resources with custom targets/res/gen-res.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 + +import sys + +with open(sys.argv[1]) as infile, open(sys.argv[2], 'w') as outfile: + outfile.write(infile.read().format(icon=sys.argv[3])) diff --git a/test cases/windows/12 resources with custom targets/res/meson.build b/test cases/windows/12 resources with custom targets/res/meson.build new file mode 100644 index 0000000..9797637 --- /dev/null +++ b/test cases/windows/12 resources with custom targets/res/meson.build @@ -0,0 +1,19 @@ +win = import('windows') + +rc_writer = find_program('./gen-res.py') + +rc_sources = [] + +foreach id : [1, 2] + rc_sources += custom_target('RC source file @0@'.format(id), + input : 'myres.rc.in', + output : 'myres_@0@.rc'.format(id), + command : [rc_writer, '@INPUT@', '@OUTPUT@', files('sample.ico')], + install : false, + build_always : false) +endforeach + +rc_sources += files('myres_static.rc') + +res = win.compile_resources(rc_sources, + include_directories: include_directories('.')) diff --git a/test cases/windows/12 resources with custom targets/res/myres.rc.in b/test cases/windows/12 resources with custom targets/res/myres.rc.in new file mode 100644 index 0000000..0cff642 --- /dev/null +++ b/test cases/windows/12 resources with custom targets/res/myres.rc.in @@ -0,0 +1,4 @@ +#include<windows.h> +#include<resource.h> + +1 ICON "{icon}" diff --git a/test cases/windows/12 resources with custom targets/res/myres_static.rc b/test cases/windows/12 resources with custom targets/res/myres_static.rc new file mode 100644 index 0000000..12838ae --- /dev/null +++ b/test cases/windows/12 resources with custom targets/res/myres_static.rc @@ -0,0 +1,3 @@ +#include<windows.h> + +1 ICON "sample.ico" diff --git a/test cases/windows/12 resources with custom targets/res/resource.h b/test cases/windows/12 resources with custom targets/res/resource.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/windows/12 resources with custom targets/res/resource.h diff --git a/test cases/windows/12 resources with custom targets/res/sample.ico b/test cases/windows/12 resources with custom targets/res/sample.ico Binary files differnew file mode 100644 index 0000000..24bd3d9 --- /dev/null +++ b/test cases/windows/12 resources with custom targets/res/sample.ico diff --git a/test cases/windows/13 test argument extra paths/exe/main.c b/test cases/windows/13 test argument extra paths/exe/main.c new file mode 100644 index 0000000..1032ae2 --- /dev/null +++ b/test cases/windows/13 test argument extra paths/exe/main.c @@ -0,0 +1,5 @@ +#include <foo.h> + +int main(void) { + return foo_process(); +} diff --git a/test cases/windows/13 test argument extra paths/exe/meson.build b/test cases/windows/13 test argument extra paths/exe/meson.build new file mode 100644 index 0000000..138500a --- /dev/null +++ b/test cases/windows/13 test argument extra paths/exe/meson.build @@ -0,0 +1,3 @@ +barexe = executable('bar', 'main.c', + include_directories: incfoo, + link_with: libfoo) diff --git a/test cases/windows/13 test argument extra paths/lib/foo.c b/test cases/windows/13 test argument extra paths/lib/foo.c new file mode 100644 index 0000000..86b1a03 --- /dev/null +++ b/test cases/windows/13 test argument extra paths/lib/foo.c @@ -0,0 +1,6 @@ +#include "foo.h" + +int +foo_process(void) { + return 42; +} diff --git a/test cases/windows/13 test argument extra paths/lib/foo.h b/test cases/windows/13 test argument extra paths/lib/foo.h new file mode 100644 index 0000000..5078c58 --- /dev/null +++ b/test cases/windows/13 test argument extra paths/lib/foo.h @@ -0,0 +1,14 @@ +#pragma once + +#if defined _WIN32 || defined __CYGWIN__ + #define DLL_PUBLIC __declspec(dllexport) +#else + #if defined __GNUC__ + #define DLL_PUBLIC __attribute__ ((visibility("default"))) + #else + #pragma message ("Compiler does not support symbol visibility.") + #define DLL_PUBLIC + #endif +#endif + +DLL_PUBLIC int foo_process(void); diff --git a/test cases/windows/13 test argument extra paths/lib/meson.build b/test cases/windows/13 test argument extra paths/lib/meson.build new file mode 100644 index 0000000..aa0bf14 --- /dev/null +++ b/test cases/windows/13 test argument extra paths/lib/meson.build @@ -0,0 +1,3 @@ +incfoo = include_directories('.') + +libfoo = library('foo', 'foo.c') diff --git a/test cases/windows/13 test argument extra paths/meson.build b/test cases/windows/13 test argument extra paths/meson.build new file mode 100644 index 0000000..f105946 --- /dev/null +++ b/test cases/windows/13 test argument extra paths/meson.build @@ -0,0 +1,5 @@ +project('test argument extra paths', 'c') + +subdir('lib') +subdir('exe') +subdir('test') diff --git a/test cases/windows/13 test argument extra paths/test/meson.build b/test cases/windows/13 test argument extra paths/test/meson.build new file mode 100644 index 0000000..2e608be --- /dev/null +++ b/test cases/windows/13 test argument extra paths/test/meson.build @@ -0,0 +1,3 @@ +python3 = import('python').find_installation('') + +test('run_exe', python3, args: [files('test_run_exe.py')[0], barexe]) diff --git a/test cases/windows/13 test argument extra paths/test/test_run_exe.py b/test cases/windows/13 test argument extra paths/test/test_run_exe.py new file mode 100644 index 0000000..77c7ddc --- /dev/null +++ b/test cases/windows/13 test argument extra paths/test/test_run_exe.py @@ -0,0 +1,12 @@ +import subprocess +import argparse +import sys + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('prog') + args = parser.parse_args() + + res = subprocess.run(args.prog) + + sys.exit(res.returncode - 42) diff --git a/test cases/windows/14 resources with custom target depend_files/ico/gen-ico.py b/test cases/windows/14 resources with custom target depend_files/ico/gen-ico.py new file mode 100755 index 0000000..c49e0dd --- /dev/null +++ b/test cases/windows/14 resources with custom target depend_files/ico/gen-ico.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 + +import sys + +with open(sys.argv[1], 'rb') as infile, open(sys.argv[2], 'wb') as outfile: + outfile.write(infile.read()) diff --git a/test cases/windows/14 resources with custom target depend_files/ico/meson.build b/test cases/windows/14 resources with custom target depend_files/ico/meson.build new file mode 100644 index 0000000..3fae9e8 --- /dev/null +++ b/test cases/windows/14 resources with custom target depend_files/ico/meson.build @@ -0,0 +1,8 @@ +ico_writer = find_program('gen-ico.py') + +ico = custom_target('makeico', + input : 'sample.ico.in', + output : 'sample.ico', + command : [ico_writer, '@INPUT@', '@OUTPUT@'], + install : false, + build_always : false) diff --git a/test cases/windows/14 resources with custom target depend_files/ico/sample.ico.in b/test cases/windows/14 resources with custom target depend_files/ico/sample.ico.in Binary files differnew file mode 100644 index 0000000..24bd3d9 --- /dev/null +++ b/test cases/windows/14 resources with custom target depend_files/ico/sample.ico.in diff --git a/test cases/windows/14 resources with custom target depend_files/meson.build b/test cases/windows/14 resources with custom target depend_files/meson.build new file mode 100644 index 0000000..85ba06f --- /dev/null +++ b/test cases/windows/14 resources with custom target depend_files/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 meson.get_compiler('c').get_id() == 'gcc' 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('ico') +subdir('res') + +exe = executable('prog', 'prog.c', + res, + gui_app : true) + +test('winmain', exe) diff --git a/test cases/windows/14 resources with custom target depend_files/prog.c b/test cases/windows/14 resources with custom target depend_files/prog.c new file mode 100644 index 0000000..cb6892d --- /dev/null +++ b/test cases/windows/14 resources with custom target depend_files/prog.c @@ -0,0 +1,19 @@ +#include<windows.h> + +#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/14 resources with custom target depend_files/res/meson.build b/test cases/windows/14 resources with custom target depend_files/res/meson.build new file mode 100644 index 0000000..3d43b3f --- /dev/null +++ b/test cases/windows/14 resources with custom target depend_files/res/meson.build @@ -0,0 +1,4 @@ +win = import('windows') + +res = win.compile_resources('myres.rc', + depends: ico) diff --git a/test cases/windows/14 resources with custom target depend_files/res/myres.rc b/test cases/windows/14 resources with custom target depend_files/res/myres.rc new file mode 100644 index 0000000..12838ae --- /dev/null +++ b/test cases/windows/14 resources with custom target depend_files/res/myres.rc @@ -0,0 +1,3 @@ +#include<windows.h> + +1 ICON "sample.ico" diff --git a/test cases/windows/15 resource scripts with duplicate filenames/a/meson.build b/test cases/windows/15 resource scripts with duplicate filenames/a/meson.build new file mode 100644 index 0000000..73f18c8 --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/a/meson.build @@ -0,0 +1 @@ +a = win.compile_resources('rsrc.rc') diff --git a/test cases/windows/15 resource scripts with duplicate filenames/a/rsrc.rc b/test cases/windows/15 resource scripts with duplicate filenames/a/rsrc.rc new file mode 100644 index 0000000..1997b8e --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/a/rsrc.rc @@ -0,0 +1 @@ +a RCDATA { "a" } diff --git a/test cases/windows/15 resource scripts with duplicate filenames/b/meson.build b/test cases/windows/15 resource scripts with duplicate filenames/b/meson.build new file mode 100644 index 0000000..d0b0aab --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/b/meson.build @@ -0,0 +1,2 @@ +bf = files('rsrc.rc') +b = win.compile_resources(bf) diff --git a/test cases/windows/15 resource scripts with duplicate filenames/b/rsrc.rc b/test cases/windows/15 resource scripts with duplicate filenames/b/rsrc.rc new file mode 100644 index 0000000..a8e3b27 --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/b/rsrc.rc @@ -0,0 +1 @@ +b RCDATA { "b" } diff --git a/test cases/windows/15 resource scripts with duplicate filenames/c/meson.build b/test cases/windows/15 resource scripts with duplicate filenames/c/meson.build new file mode 100644 index 0000000..a7b7e30 --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/c/meson.build @@ -0,0 +1,2 @@ +cf = files('rsrc.rc') +c = win.compile_resources(cf) diff --git a/test cases/windows/15 resource scripts with duplicate filenames/c/rsrc.rc b/test cases/windows/15 resource scripts with duplicate filenames/c/rsrc.rc new file mode 100644 index 0000000..1fa2c1c --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/c/rsrc.rc @@ -0,0 +1 @@ +c RCDATA { "c" } 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 0000000..1b97435 --- /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 0000000..2bd8cd2 --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_dll/main.c @@ -0,0 +1,10 @@ +#include <windows.h> + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + // avoid unused argument error while matching template + ((void)hinstDLL); + ((void)fdwReason); + ((void)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 0000000..abdbaaa --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_dll/version.rc @@ -0,0 +1,11 @@ + #include <windows.h> + +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 0000000..9b6bdc2 --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_exe/main.c @@ -0,0 +1,3 @@ +int main(void) { + 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 0000000..abdbaaa --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_exe/version.rc @@ -0,0 +1,11 @@ + #include <windows.h> + +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 0000000..2ae3a71 --- /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 0000000..2bd8cd2 --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_dll/main.c @@ -0,0 +1,10 @@ +#include <windows.h> + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + // avoid unused argument error while matching template + ((void)hinstDLL); + ((void)fdwReason); + ((void)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 0000000..abdbaaa --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_dll/version.rc @@ -0,0 +1,11 @@ + #include <windows.h> + +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 0000000..9b6bdc2 --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_exe/main.c @@ -0,0 +1,3 @@ +int main(void) { + 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 0000000..abdbaaa --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_exe/version.rc @@ -0,0 +1,11 @@ + #include <windows.h> + +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 new file mode 100644 index 0000000..9fa3525 --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/meson.build @@ -0,0 +1,21 @@ +project('foobar', 'c') + +win = import('windows') + +subdir('a') +subdir('b') +subdir('c') +subdir('exe3') +subdir('exe4') + +main = win.compile_resources('rsrc.rc') + +testa = executable('testa', 'verify.c', a) +testb = executable('testb', 'verify.c', b) +testc = executable('testc', 'verify.c', c) +testmain = executable('testmain', 'verify.c', main) + +test('a', testa, args: 'a') +test('b', testb, args: 'b') +test('c', testc, args: 'c') +test('main', testmain, args: 'main') diff --git a/test cases/windows/15 resource scripts with duplicate filenames/rsrc.rc b/test cases/windows/15 resource scripts with duplicate filenames/rsrc.rc new file mode 100644 index 0000000..8f6aa1f --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/rsrc.rc @@ -0,0 +1 @@ +main RCDATA { "main" } diff --git a/test cases/windows/15 resource scripts with duplicate filenames/verify.c b/test cases/windows/15 resource scripts with duplicate filenames/verify.c new file mode 100644 index 0000000..8f5b88e --- /dev/null +++ b/test cases/windows/15 resource scripts with duplicate filenames/verify.c @@ -0,0 +1,25 @@ +#include <assert.h> +#include <windows.h> + +int main(int argc, char *argv[]) +{ + // verify that the expected resource exists and has the expected contents + HRSRC hRsrc; + unsigned int size; + HGLOBAL hGlobal; + void* data; + + ((void)argc); + + hRsrc = FindResource(NULL, argv[1], RT_RCDATA); + assert(hRsrc); + + size = SizeofResource(NULL, hRsrc); + hGlobal = LoadResource(NULL, hRsrc); + data = LockResource(hGlobal); + + assert(size == strlen(argv[1])); + assert(memcmp(data, argv[1], size) == 0); + + return 0; +} diff --git a/test cases/windows/16 gui app/console_prog.c b/test cases/windows/16 gui app/console_prog.c new file mode 100644 index 0000000..9b6bdc2 --- /dev/null +++ b/test cases/windows/16 gui app/console_prog.c @@ -0,0 +1,3 @@ +int main(void) { + return 0; +} diff --git a/test cases/windows/16 gui app/dummy.c b/test cases/windows/16 gui app/dummy.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/windows/16 gui app/dummy.c diff --git a/test cases/windows/16 gui app/gui_app_tester.py b/test cases/windows/16 gui app/gui_app_tester.py new file mode 100644 index 0000000..53e7649 --- /dev/null +++ b/test cases/windows/16 gui app/gui_app_tester.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 + +import os +import sys +try: + import pefile +except ImportError: + if 'CI' in os.environ: + raise + # Skip the test if not on CI + sys.exit(77) + +executable = sys.argv[1] +expected = int(sys.argv[2]) + +actual = pefile.PE(executable).dump_dict()['OPTIONAL_HEADER']['Subsystem']['Value'] + +print('subsystem expected: %d, actual: %d' % (expected, actual)) +sys.exit(0 if (expected == actual) else 1) diff --git a/test cases/windows/16 gui app/gui_prog.c b/test cases/windows/16 gui app/gui_prog.c new file mode 100644 index 0000000..9cdf170 --- /dev/null +++ b/test cases/windows/16 gui app/gui_prog.c @@ -0,0 +1,11 @@ +#include <windows.h> + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, + LPSTR lpCmdLine, int nCmdShow) { + // avoid unused argument error while matching template + ((void)hInstance); + ((void)hPrevInstance); + ((void)lpCmdLine); + ((void)nCmdShow); + return 0; +} diff --git a/test cases/windows/16 gui app/meson.build b/test cases/windows/16 gui app/meson.build new file mode 100644 index 0000000..3021c43 --- /dev/null +++ b/test cases/windows/16 gui app/meson.build @@ -0,0 +1,26 @@ +project('gui_app_test', 'c') + +# +# test that linking a Windows console applications with the main function in a +# library is correctly instructed which entrypoint function to look for +# + +console_lib = static_library('main', 'console_prog.c') +executable('console', 'dummy.c', link_with: console_lib, win_subsystem: 'console') +executable('console2', 'dummy.c', link_with: console_lib, gui_app: false) + +# +# also verify that the correct subsystem is set by executable(gui_app:) +# + +gui_prog = executable('gui_prog', 'gui_prog.c', win_subsystem: 'windows,6.0') +gui_prog2 = executable('gui_prog2', 'gui_prog.c', gui_app: true) +console_prog = executable('console_prog', 'console_prog.c', win_subsystem: 'console') +console_prog2 = executable('console_prog2', 'console_prog.c', gui_app: false) + +tester = find_program('gui_app_tester.py') + +test('is_gui', tester, args: [gui_prog, '2']) +test('is_gui2', tester, args: [gui_prog2, '2']) +test('not_gui', tester, args: [console_prog, '3']) +test('not_gui2', tester, args: [console_prog2, '3']) diff --git a/test cases/windows/17 msvc ndebug/main.cpp b/test cases/windows/17 msvc ndebug/main.cpp new file mode 100644 index 0000000..d647d71 --- /dev/null +++ b/test cases/windows/17 msvc ndebug/main.cpp @@ -0,0 +1,9 @@ +int main() { +#ifdef NDEBUG + // NDEBUG is defined + return 0; +#else + // NDEBUG is not defined + return 1; +#endif +}
\ No newline at end of file diff --git a/test cases/windows/17 msvc ndebug/meson.build b/test cases/windows/17 msvc ndebug/meson.build new file mode 100644 index 0000000..78eaf89 --- /dev/null +++ b/test cases/windows/17 msvc ndebug/meson.build @@ -0,0 +1,7 @@ +project('msvc_ndebug', 'cpp', + default_options : [ 'b_ndebug=true' ] +) + +exe = executable('exe', 'main.cpp') + +test('ndebug', exe) diff --git a/test cases/windows/18 msvc charset/iso-8859-1.c b/test cases/windows/18 msvc charset/iso-8859-1.c new file mode 100644 index 0000000..66c6a00 --- /dev/null +++ b/test cases/windows/18 msvc charset/iso-8859-1.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char *argcv[]) +{ + printf("This is ISO-8859-1 encoded é\n"); + return 0; +} diff --git a/test cases/windows/18 msvc charset/meson.build b/test cases/windows/18 msvc charset/meson.build new file mode 100644 index 0000000..bb6f667 --- /dev/null +++ b/test cases/windows/18 msvc charset/meson.build @@ -0,0 +1,15 @@ +project('charset', 'c') + +cc = meson.get_compiler('c') + +if cc.get_id() != 'msvc' + error('MESON_SKIP_TEST requires MSVC.') +endif + +executable('utf8', 'utf8.c') + +if get_option('test-failure') + executable('iso-8859-1', 'iso-8859-1.c') +else + executable('iso-8859-1', 'iso-8859-1.c', c_args: '/source-charset:.850') +endif diff --git a/test cases/windows/18 msvc charset/meson_options.txt b/test cases/windows/18 msvc charset/meson_options.txt new file mode 100644 index 0000000..2cfba63 --- /dev/null +++ b/test cases/windows/18 msvc charset/meson_options.txt @@ -0,0 +1 @@ +option('test-failure', type: 'boolean', value: false) diff --git a/test cases/windows/18 msvc charset/utf8.c b/test cases/windows/18 msvc charset/utf8.c new file mode 100644 index 0000000..d6dc5aa --- /dev/null +++ b/test cases/windows/18 msvc charset/utf8.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char *argcv[]) +{ + printf("This is UTF-8 encoded é\n"); + return 0; +} diff --git a/test cases/windows/19 msvc cplusplus define/main.cpp b/test cases/windows/19 msvc cplusplus define/main.cpp new file mode 100644 index 0000000..bc0b1fd --- /dev/null +++ b/test cases/windows/19 msvc cplusplus define/main.cpp @@ -0,0 +1,7 @@ +int main() { +#if __cplusplus == 199711L + return 1; +#else + return 0; +#endif +} diff --git a/test cases/windows/19 msvc cplusplus define/meson.build b/test cases/windows/19 msvc cplusplus define/meson.build new file mode 100644 index 0000000..9b85ff6 --- /dev/null +++ b/test cases/windows/19 msvc cplusplus define/meson.build @@ -0,0 +1,14 @@ +project('msvc __cplusplus', 'cpp', default_options : ['cpp_std=c++14']) + +cpp = meson.get_compiler('cpp') + +if cpp.get_id() != 'msvc' + error('MESON_SKIP_TEST: test is only relevant for msvc') +elif meson.project_version().version_compare('< 15.7') + error('MESON_SKIP_TEST: test is only relevant for msvc versions >= 15.7') +endif + +test( + 'main', + executable('main', 'main.cpp'), +) diff --git a/test cases/windows/2 winmain/meson.build b/test cases/windows/2 winmain/meson.build new file mode 100644 index 0000000..ea0d23b --- /dev/null +++ b/test cases/windows/2 winmain/meson.build @@ -0,0 +1,4 @@ +project('winmain', 'c') + +exe = executable('prog', 'prog.c', gui_app : true) +test('winmain', exe) diff --git a/test cases/windows/2 winmain/prog.c b/test cases/windows/2 winmain/prog.c new file mode 100644 index 0000000..3bd4c95 --- /dev/null +++ b/test cases/windows/2 winmain/prog.c @@ -0,0 +1,15 @@ +#include<windows.h> + +int APIENTRY +WinMain( + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpszCmdLine, + int nCmdShow) { +// avoid unused argument error while matching template + ((void)hInstance); + ((void)hPrevInstance); + ((void)lpszCmdLine); + ((void)nCmdShow); + return 0; +} diff --git a/test cases/windows/20 vs install static lib with generated obj deps/both_lib_source.c b/test cases/windows/20 vs install static lib with generated obj deps/both_lib_source.c new file mode 100644 index 0000000..aa926b1 --- /dev/null +++ b/test cases/windows/20 vs install static lib with generated obj deps/both_lib_source.c @@ -0,0 +1,7 @@ +extern int static_lib_function(void); +extern __declspec(dllexport) int both_lib_function(void); + +int both_lib_function(void) +{ + return static_lib_function(); +} diff --git a/test cases/windows/20 vs install static lib with generated obj deps/copyfile.py b/test cases/windows/20 vs install static lib with generated obj deps/copyfile.py new file mode 100644 index 0000000..738e894 --- /dev/null +++ b/test cases/windows/20 vs install static lib with generated obj deps/copyfile.py @@ -0,0 +1,4 @@ +from shutil import copyfile +import sys + +copyfile(sys.argv[1], sys.argv[2]) diff --git a/test cases/windows/20 vs install static lib with generated obj deps/generated_source.c b/test cases/windows/20 vs install static lib with generated obj deps/generated_source.c new file mode 100644 index 0000000..8671cbf --- /dev/null +++ b/test cases/windows/20 vs install static lib with generated obj deps/generated_source.c @@ -0,0 +1,4 @@ +int generated_function(void) +{ + return 42; +} diff --git a/test cases/windows/20 vs install static lib with generated obj deps/meson.build b/test cases/windows/20 vs install static lib with generated obj deps/meson.build new file mode 100644 index 0000000..bc61772 --- /dev/null +++ b/test cases/windows/20 vs install static lib with generated obj deps/meson.build @@ -0,0 +1,20 @@ +project('test', 'c') + +generated_c = custom_target( + 'generated.c', + input : files('generated_source.c', 'copyfile.py'), + output : 'generated.c', + command : ['python', '@INPUT1@', '@INPUT0@', '@OUTPUT@'], +) + +static_lib = static_library( + 'static_lib', + [files('static_lib_source.c'), generated_c], +) + +both_lib = both_libraries( + 'both_lib', + [files('both_lib_source.c')], + link_with : [static_lib], + install : true, +) diff --git a/test cases/windows/20 vs install static lib with generated obj deps/static_lib_source.c b/test cases/windows/20 vs install static lib with generated obj deps/static_lib_source.c new file mode 100644 index 0000000..e86153a --- /dev/null +++ b/test cases/windows/20 vs install static lib with generated obj deps/static_lib_source.c @@ -0,0 +1,6 @@ +extern int generated_function(void); + +int static_lib_function(void) +{ + return generated_function(); +} diff --git a/test cases/windows/20 vs install static lib with generated obj deps/test.json b/test cases/windows/20 vs install static lib with generated obj deps/test.json new file mode 100644 index 0000000..451da1e --- /dev/null +++ b/test cases/windows/20 vs install static lib with generated obj deps/test.json @@ -0,0 +1,13 @@ +{ + "installed": [ + {"type": "file", "file": "usr/lib/libboth_lib.a"}, + + {"type": "shared_lib", "platform": "msvc", "file": "usr/bin/both_lib"}, + {"type": "implib", "platform": "msvc", "file": "usr/lib/both_lib"}, + {"type": "pdb", "platform": "msvc", "file": "usr/bin/both_lib"}, + + {"type": "expr", "platform": "gcc", "file": "usr/lib/?libboth_lib.dll"}, + {"type": "implib", "platform": "gcc", "file": "usr/lib/libboth_lib"}, + {"type": "pdb", "platform": "gcc", "file": "usr/bin/libboth_lib"} + ] +} diff --git a/test cases/windows/21 masm/hello.masm b/test cases/windows/21 masm/hello.masm new file mode 100644 index 0000000..a47dc96 --- /dev/null +++ b/test cases/windows/21 masm/hello.masm @@ -0,0 +1,33 @@ +; --------------------------------------------- +; Hello World for Win64 Intel x64 Assembly +; +; by fruel (https://github.com/fruel) +; 13 June 2016 +; --------------------------------------------- + +GetStdHandle PROTO +ExitProcess PROTO +WriteConsoleA PROTO + +.data +msg BYTE "Hello World!",0 +bytesWritten DWORD ? + +.code +mainCRTStartup proc + sub rsp, 5 * 8 ; reserve shadow space + + mov rcx, -11 ; nStdHandle (STD_OUTPUT_HANDLE) + call GetStdHandle + + mov rcx, rax ; hConsoleOutput + lea rdx, msg ; *lpBuffer + mov r8, LENGTHOF msg - 1 ; nNumberOfCharsToWrite + lea r9, bytesWritten ; lpNumberOfCharsWritten + mov QWORD PTR [rsp + 4 * SIZEOF QWORD], 0 ; lpReserved + call WriteConsoleA + + mov rcx, 0 ; uExitCode + call ExitProcess +mainCRTStartup endp +END diff --git a/test cases/windows/21 masm/meson.build b/test cases/windows/21 masm/meson.build new file mode 100644 index 0000000..b6b8fbb --- /dev/null +++ b/test cases/windows/21 masm/meson.build @@ -0,0 +1,14 @@ +project('test-masm', 'c') + +if get_option('backend').startswith('vs') + error('MESON_SKIP_TEST: masm is not supported by vs backend') +endif + +cc = meson.get_compiler('c') + +# MASM must be found when using MSVC, otherwise it is optional +if not add_languages('masm', required: cc.get_argument_syntax() == 'msvc') + error('MESON_SKIP_TEST: masm not available') +endif + +executable('app', 'hello.masm') diff --git a/test cases/windows/3 cpp/meson.build b/test cases/windows/3 cpp/meson.build new file mode 100644 index 0000000..a9e6569 --- /dev/null +++ b/test cases/windows/3 cpp/meson.build @@ -0,0 +1,4 @@ +project('wincpp', 'cpp', default_options : ['cpp_std=c++14']) + +exe = executable('prog', 'prog.cpp') +test('wincpp', exe) diff --git a/test cases/windows/3 cpp/prog.cpp b/test cases/windows/3 cpp/prog.cpp new file mode 100644 index 0000000..69092f7 --- /dev/null +++ b/test cases/windows/3 cpp/prog.cpp @@ -0,0 +1,7 @@ +#include<windows.h> + +class Foo; + +int main(void) { + return 0; +} diff --git a/test cases/windows/4 winmaincpp/meson.build b/test cases/windows/4 winmaincpp/meson.build new file mode 100644 index 0000000..4eda8ca --- /dev/null +++ b/test cases/windows/4 winmaincpp/meson.build @@ -0,0 +1,4 @@ +project('winmaincpp', 'cpp') + +exe = executable('prog', 'prog.cpp', gui_app : true) +test('winmaincpp', exe) diff --git a/test cases/windows/4 winmaincpp/prog.cpp b/test cases/windows/4 winmaincpp/prog.cpp new file mode 100644 index 0000000..6182257 --- /dev/null +++ b/test cases/windows/4 winmaincpp/prog.cpp @@ -0,0 +1,17 @@ +#include<windows.h> + +class Foo; + +int APIENTRY +WinMain( + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpszCmdLine, + int nCmdShow) { +// avoid unused argument error while matching template + ((void)hInstance); + ((void)hPrevInstance); + ((void)lpszCmdLine); + ((void)nCmdShow); + return 0; +} 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 diff --git a/test cases/windows/6 vs module defs/meson.build b/test cases/windows/6 vs module defs/meson.build new file mode 100644 index 0000000..fb59028 --- /dev/null +++ b/test cases/windows/6 vs module defs/meson.build @@ -0,0 +1,5 @@ +project('dll_module_defs', 'c') + +subdir('subdir') +exe = executable('prog', 'prog.c', link_with : shlib) +test('runtest', exe) diff --git a/test cases/windows/6 vs module defs/prog.c b/test cases/windows/6 vs module defs/prog.c new file mode 100644 index 0000000..066ac22 --- /dev/null +++ b/test cases/windows/6 vs module defs/prog.c @@ -0,0 +1,5 @@ +int somedllfunc(void); + +int main(void) { + return somedllfunc() == 42 ? 0 : 1; +} diff --git a/test cases/windows/6 vs module defs/subdir/meson.build b/test cases/windows/6 vs module defs/subdir/meson.build new file mode 100644 index 0000000..60633c3 --- /dev/null +++ b/test cases/windows/6 vs module defs/subdir/meson.build @@ -0,0 +1 @@ +shlib = shared_library('somedll', 'somedll.c', vs_module_defs : 'somedll.def') diff --git a/test cases/windows/6 vs module defs/subdir/somedll.c b/test cases/windows/6 vs module defs/subdir/somedll.c new file mode 100644 index 0000000..f095b18 --- /dev/null +++ b/test cases/windows/6 vs module defs/subdir/somedll.c @@ -0,0 +1,3 @@ +int somedllfunc(void) { + return 42; +} diff --git a/test cases/windows/6 vs module defs/subdir/somedll.def b/test cases/windows/6 vs module defs/subdir/somedll.def new file mode 100644 index 0000000..60fd1a1 --- /dev/null +++ b/test cases/windows/6 vs module defs/subdir/somedll.def @@ -0,0 +1,2 @@ +EXPORTS + somedllfunc diff --git a/test cases/windows/7 dll versioning/copyfile.py b/test cases/windows/7 dll versioning/copyfile.py new file mode 100644 index 0000000..ff42ac3 --- /dev/null +++ b/test cases/windows/7 dll versioning/copyfile.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 + +import sys +import shutil + +shutil.copyfile(sys.argv[1], sys.argv[2]) diff --git a/test cases/windows/7 dll versioning/exe.orig.c b/test cases/windows/7 dll versioning/exe.orig.c new file mode 100644 index 0000000..1e8e90e --- /dev/null +++ b/test cases/windows/7 dll versioning/exe.orig.c @@ -0,0 +1,8 @@ +int myFunc (void); + +int main(void) +{ + if (myFunc() == 55) + return 0; + return 1; +} diff --git a/test cases/windows/7 dll versioning/lib.c b/test cases/windows/7 dll versioning/lib.c new file mode 100644 index 0000000..37e0d1d --- /dev/null +++ b/test cases/windows/7 dll versioning/lib.c @@ -0,0 +1,6 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int myFunc(void) { + return 55; +} diff --git a/test cases/windows/7 dll versioning/meson.build b/test cases/windows/7 dll versioning/meson.build new file mode 100644 index 0000000..983c2c4 --- /dev/null +++ b/test cases/windows/7 dll versioning/meson.build @@ -0,0 +1,54 @@ +project('msvc dll versioning', 'c') + +cc = meson.get_compiler('c') + +# Test that we create correctly-named dll and import lib files, +# and also install them in the right place +some = shared_library('some', 'lib.c', + version : '1.2.3', + soversion : '0', + install : true) + +noversion = shared_library('noversion', 'lib.c', + install : true) + +onlyversion = shared_library('onlyversion', 'lib.c', + version : '1.4.5', + install : true) + +onlysoversion = shared_library('onlysoversion', 'lib.c', + # Also test that int soversion is acceptable + soversion : 5, + install : true) + +# Hack to make the executables below depend on the shared libraries above +# without actually adding them as `link_with` dependencies since we want to try +# linking to them with -lfoo linker arguments. +cp = find_program('copyfile.py') +out = custom_target('library-dependency-hack', + input : 'exe.orig.c', + output : 'exe.c', + depends : [some, noversion, onlyversion, onlysoversion], + command : [cp, '@INPUT@', '@OUTPUT@']) + +# Manually test if the linker can find the above libraries +# i.e., whether they were generated with the right naming scheme +test('manually linked 1', executable('manuallink1', out, + link_args : ['-L.', '-lsome'])) + +test('manually linked 2', executable('manuallink2', out, + link_args : ['-L.', '-lnoversion'])) + +test('manually linked 3', executable('manuallink3', out, + link_args : ['-L.', '-lonlyversion'])) + +test('manually linked 4', executable('manuallink4', out, + link_args : ['-L.', '-lonlysoversion'])) + +shared_library('customdir', 'lib.c', + install : true, + install_dir : get_option('libexecdir')) + +shared_module('module', 'lib.c', + install : true, + install_dir: join_paths(get_option('libdir'), 'modules')) diff --git a/test cases/windows/7 dll versioning/test.json b/test cases/windows/7 dll versioning/test.json new file mode 100644 index 0000000..1402925 --- /dev/null +++ b/test cases/windows/7 dll versioning/test.json @@ -0,0 +1,34 @@ +{ + "installed": [ + {"type": "file", "platform": "msvc", "file": "usr/bin/some-0.dll"}, + {"type": "pdb", "file": "usr/bin/some-0"}, + {"type": "file", "platform": "msvc", "file": "usr/lib/some.lib"}, + {"type": "file", "platform": "msvc", "file": "usr/bin/noversion.dll"}, + {"type": "pdb", "file": "usr/bin/noversion"}, + {"type": "file", "platform": "msvc", "file": "usr/lib/noversion.lib"}, + {"type": "file", "platform": "msvc", "file": "usr/bin/onlyversion-1.dll"}, + {"type": "pdb", "file": "usr/bin/onlyversion-1"}, + {"type": "file", "platform": "msvc", "file": "usr/lib/onlyversion.lib"}, + {"type": "file", "platform": "msvc", "file": "usr/bin/onlysoversion-5.dll"}, + {"type": "pdb", "file": "usr/bin/onlysoversion-5"}, + {"type": "file", "platform": "msvc", "file": "usr/lib/onlysoversion.lib"}, + {"type": "file", "platform": "msvc", "file": "usr/libexec/customdir.dll"}, + {"type": "file", "platform": "msvc", "file": "usr/libexec/customdir.lib"}, + {"type": "pdb", "file": "usr/libexec/customdir"}, + {"type": "file", "platform": "msvc", "file": "usr/lib/modules/module.dll"}, + {"type": "file", "platform": "msvc", "file": "usr/lib/modules/module.lib"}, + {"type": "pdb", "file": "usr/lib/modules/module"}, + {"type": "expr", "platform": "gcc", "file": "usr/bin/?libsome-0.dll"}, + {"type": "file", "platform": "gcc", "file": "usr/lib/libsome.dll.a"}, + {"type": "expr", "platform": "gcc", "file": "usr/bin/?libnoversion.dll"}, + {"type": "file", "platform": "gcc", "file": "usr/lib/libnoversion.dll.a"}, + {"type": "expr", "platform": "gcc", "file": "usr/bin/?libonlyversion-1.dll"}, + {"type": "file", "platform": "gcc", "file": "usr/lib/libonlyversion.dll.a"}, + {"type": "expr", "platform": "gcc", "file": "usr/bin/?libonlysoversion-5.dll"}, + {"type": "file", "platform": "gcc", "file": "usr/lib/libonlysoversion.dll.a"}, + {"type": "expr", "platform": "gcc", "file": "usr/libexec/?libcustomdir.dll"}, + {"type": "file", "platform": "gcc", "file": "usr/libexec/libcustomdir.dll.a"}, + {"type": "expr", "platform": "gcc", "file": "usr/lib/modules/?libmodule.dll"}, + {"type": "file", "platform": "gcc", "file": "usr/lib/modules/libmodule.dll.a"} + ] +} diff --git a/test cases/windows/8 find program/meson.build b/test cases/windows/8 find program/meson.build new file mode 100644 index 0000000..565fb62 --- /dev/null +++ b/test cases/windows/8 find program/meson.build @@ -0,0 +1,12 @@ +project('find program', 'c') + +# Test that we can find native windows executables +find_program('cmd') +find_program('cmd.exe') + +# Test that a script file with an extension can be found +ext = find_program('test-script-ext.py') +test('ext', ext) +# Test that a script file without an extension can be found +prog = find_program('test-script') +test('script', prog) diff --git a/test cases/windows/8 find program/test-script b/test cases/windows/8 find program/test-script new file mode 100644 index 0000000..e764165 --- /dev/null +++ b/test cases/windows/8 find program/test-script @@ -0,0 +1,3 @@ +#!/usr/bin/env python3 + +print('1') diff --git a/test cases/windows/8 find program/test-script-ext.py b/test cases/windows/8 find program/test-script-ext.py new file mode 100644 index 0000000..ae9adfb --- /dev/null +++ b/test cases/windows/8 find program/test-script-ext.py @@ -0,0 +1,3 @@ +#!/usr/bin/env python3 + +print('ext/noext') diff --git a/test cases/windows/9 vs module defs generated/meson.build b/test cases/windows/9 vs module defs generated/meson.build new file mode 100644 index 0000000..7728ca7 --- /dev/null +++ b/test cases/windows/9 vs module defs generated/meson.build @@ -0,0 +1,5 @@ +project('generated_dll_module_defs', 'c') + +subdir('subdir') +exe = executable('prog', 'prog.c', link_with : shlib) +test('runtest', exe) diff --git a/test cases/windows/9 vs module defs generated/prog.c b/test cases/windows/9 vs module defs generated/prog.c new file mode 100644 index 0000000..066ac22 --- /dev/null +++ b/test cases/windows/9 vs module defs generated/prog.c @@ -0,0 +1,5 @@ +int somedllfunc(void); + +int main(void) { + return somedllfunc() == 42 ? 0 : 1; +} diff --git a/test cases/windows/9 vs module defs generated/subdir/meson.build b/test cases/windows/9 vs module defs generated/subdir/meson.build new file mode 100644 index 0000000..356f83a --- /dev/null +++ b/test cases/windows/9 vs module defs generated/subdir/meson.build @@ -0,0 +1,10 @@ +conf = configuration_data() +conf.set('func', 'somedllfunc') +def_file = configure_file( + input: 'somedll.def.in', + output: 'somedll.def', + configuration : conf, +) + +shlib = shared_library('somedll', 'somedll.c', vs_module_defs : def_file) +shmod = shared_module('somemod', 'somedll.c', vs_module_defs : def_file) diff --git a/test cases/windows/9 vs module defs generated/subdir/somedll.c b/test cases/windows/9 vs module defs generated/subdir/somedll.c new file mode 100644 index 0000000..f095b18 --- /dev/null +++ b/test cases/windows/9 vs module defs generated/subdir/somedll.c @@ -0,0 +1,3 @@ +int somedllfunc(void) { + return 42; +} diff --git a/test cases/windows/9 vs module defs generated/subdir/somedll.def.in b/test cases/windows/9 vs module defs generated/subdir/somedll.def.in new file mode 100644 index 0000000..c29207c --- /dev/null +++ b/test cases/windows/9 vs module defs generated/subdir/somedll.def.in @@ -0,0 +1,2 @@ +EXPORTS + @func@ |