aboutsummaryrefslogtreecommitdiffstats
path: root/meson/test cases/windows
diff options
context:
space:
mode:
Diffstat (limited to 'meson/test cases/windows')
-rw-r--r--meson/test cases/windows/1 basic/meson.build4
-rw-r--r--meson/test cases/windows/1 basic/prog.c5
-rw-r--r--meson/test cases/windows/1 basic/test.json6
-rw-r--r--meson/test cases/windows/10 vs module defs generated custom target/meson.build10
-rw-r--r--meson/test cases/windows/10 vs module defs generated custom target/prog.c5
-rwxr-xr-xmeson/test cases/windows/10 vs module defs generated custom target/subdir/make_def.py6
-rw-r--r--meson/test cases/windows/10 vs module defs generated custom target/subdir/meson.build7
-rw-r--r--meson/test cases/windows/10 vs module defs generated custom target/subdir/somedll.c3
-rw-r--r--meson/test cases/windows/11 exe implib/meson.build7
-rw-r--r--meson/test cases/windows/11 exe implib/prog.c6
-rw-r--r--meson/test cases/windows/11 exe implib/test.json12
-rw-r--r--meson/test cases/windows/12 resources with custom targets/meson.build70
-rw-r--r--meson/test cases/windows/12 resources with custom targets/prog.c19
-rwxr-xr-xmeson/test cases/windows/12 resources with custom targets/res/gen-res.py6
-rw-r--r--meson/test cases/windows/12 resources with custom targets/res/meson.build19
-rw-r--r--meson/test cases/windows/12 resources with custom targets/res/myres.rc.in4
-rw-r--r--meson/test cases/windows/12 resources with custom targets/res/myres_static.rc3
-rw-r--r--meson/test cases/windows/12 resources with custom targets/res/resource.h0
-rw-r--r--meson/test cases/windows/12 resources with custom targets/res/sample.icobin0 -> 9662 bytes
-rw-r--r--meson/test cases/windows/13 test argument extra paths/exe/main.c5
-rw-r--r--meson/test cases/windows/13 test argument extra paths/exe/meson.build3
-rw-r--r--meson/test cases/windows/13 test argument extra paths/lib/foo.c6
-rw-r--r--meson/test cases/windows/13 test argument extra paths/lib/foo.h14
-rw-r--r--meson/test cases/windows/13 test argument extra paths/lib/meson.build3
-rw-r--r--meson/test cases/windows/13 test argument extra paths/meson.build5
-rw-r--r--meson/test cases/windows/13 test argument extra paths/test/meson.build3
-rw-r--r--meson/test cases/windows/13 test argument extra paths/test/test_run_exe.py12
-rwxr-xr-xmeson/test cases/windows/14 resources with custom target depend_files/ico/gen-ico.py6
-rw-r--r--meson/test cases/windows/14 resources with custom target depend_files/ico/meson.build8
-rw-r--r--meson/test cases/windows/14 resources with custom target depend_files/ico/sample.ico.inbin0 -> 9662 bytes
-rw-r--r--meson/test cases/windows/14 resources with custom target depend_files/meson.build69
-rw-r--r--meson/test cases/windows/14 resources with custom target depend_files/prog.c19
-rw-r--r--meson/test cases/windows/14 resources with custom target depend_files/res/meson.build4
-rw-r--r--meson/test cases/windows/14 resources with custom target depend_files/res/myres.rc3
-rw-r--r--meson/test cases/windows/15 resource scripts with duplicate filenames/a/meson.build1
-rw-r--r--meson/test cases/windows/15 resource scripts with duplicate filenames/a/rsrc.rc1
-rw-r--r--meson/test cases/windows/15 resource scripts with duplicate filenames/b/meson.build2
-rw-r--r--meson/test cases/windows/15 resource scripts with duplicate filenames/b/rsrc.rc1
-rw-r--r--meson/test cases/windows/15 resource scripts with duplicate filenames/c/meson.build2
-rw-r--r--meson/test cases/windows/15 resource scripts with duplicate filenames/c/rsrc.rc1
-rw-r--r--meson/test cases/windows/15 resource scripts with duplicate filenames/exe3/meson.build5
-rw-r--r--meson/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_dll/main.c10
-rw-r--r--meson/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_dll/version.rc11
-rw-r--r--meson/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_exe/main.c3
-rw-r--r--meson/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_exe/version.rc11
-rw-r--r--meson/test cases/windows/15 resource scripts with duplicate filenames/exe4/meson.build5
-rw-r--r--meson/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_dll/main.c10
-rw-r--r--meson/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_dll/version.rc11
-rw-r--r--meson/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_exe/main.c3
-rw-r--r--meson/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_exe/version.rc11
-rw-r--r--meson/test cases/windows/15 resource scripts with duplicate filenames/meson.build21
-rw-r--r--meson/test cases/windows/15 resource scripts with duplicate filenames/rsrc.rc1
-rw-r--r--meson/test cases/windows/15 resource scripts with duplicate filenames/verify.c25
-rw-r--r--meson/test cases/windows/16 gui app/console_prog.c3
-rw-r--r--meson/test cases/windows/16 gui app/dummy.c0
-rw-r--r--meson/test cases/windows/16 gui app/gui_app_tester.py19
-rw-r--r--meson/test cases/windows/16 gui app/gui_prog.c11
-rw-r--r--meson/test cases/windows/16 gui app/meson.build26
-rw-r--r--meson/test cases/windows/17 msvc ndebug/main.cpp9
-rw-r--r--meson/test cases/windows/17 msvc ndebug/meson.build7
-rw-r--r--meson/test cases/windows/2 winmain/meson.build4
-rw-r--r--meson/test cases/windows/2 winmain/prog.c15
-rw-r--r--meson/test cases/windows/3 cpp/meson.build4
-rw-r--r--meson/test cases/windows/3 cpp/prog.cpp7
-rw-r--r--meson/test cases/windows/4 winmaincpp/meson.build4
-rw-r--r--meson/test cases/windows/4 winmaincpp/prog.cpp17
-rw-r--r--meson/test cases/windows/5 resources/inc/meson.build1
-rw-r--r--meson/test cases/windows/5 resources/inc/resource/resource.h1
-rw-r--r--meson/test cases/windows/5 resources/meson.build69
-rw-r--r--meson/test cases/windows/5 resources/prog.c21
-rw-r--r--meson/test cases/windows/5 resources/res/dummy.c0
-rw-r--r--meson/test cases/windows/5 resources/res/meson.build10
-rw-r--r--meson/test cases/windows/5 resources/res/myres.rc4
-rw-r--r--meson/test cases/windows/5 resources/res/sample.icobin0 -> 9662 bytes
-rw-r--r--meson/test cases/windows/6 vs module defs/meson.build5
-rw-r--r--meson/test cases/windows/6 vs module defs/prog.c5
-rw-r--r--meson/test cases/windows/6 vs module defs/subdir/meson.build1
-rw-r--r--meson/test cases/windows/6 vs module defs/subdir/somedll.c3
-rw-r--r--meson/test cases/windows/6 vs module defs/subdir/somedll.def3
-rw-r--r--meson/test cases/windows/7 dll versioning/copyfile.py6
-rw-r--r--meson/test cases/windows/7 dll versioning/exe.orig.c8
-rw-r--r--meson/test cases/windows/7 dll versioning/lib.c6
-rw-r--r--meson/test cases/windows/7 dll versioning/meson.build54
-rw-r--r--meson/test cases/windows/7 dll versioning/test.json34
-rw-r--r--meson/test cases/windows/8 find program/meson.build12
-rw-r--r--meson/test cases/windows/8 find program/test-script3
-rw-r--r--meson/test cases/windows/8 find program/test-script-ext.py3
-rw-r--r--meson/test cases/windows/9 vs module defs generated/meson.build5
-rw-r--r--meson/test cases/windows/9 vs module defs generated/prog.c5
-rw-r--r--meson/test cases/windows/9 vs module defs generated/subdir/meson.build10
-rw-r--r--meson/test cases/windows/9 vs module defs generated/subdir/somedll.c3
-rw-r--r--meson/test cases/windows/9 vs module defs generated/subdir/somedll.def.in2
92 files changed, 887 insertions, 0 deletions
diff --git a/meson/test cases/windows/1 basic/meson.build b/meson/test cases/windows/1 basic/meson.build
new file mode 100644
index 000000000..03d5436a1
--- /dev/null
+++ b/meson/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/meson/test cases/windows/1 basic/prog.c b/meson/test cases/windows/1 basic/prog.c
new file mode 100644
index 000000000..f400e12ec
--- /dev/null
+++ b/meson/test cases/windows/1 basic/prog.c
@@ -0,0 +1,5 @@
+#include <windows.h>
+
+int main(void) {
+ return 0;
+}
diff --git a/meson/test cases/windows/1 basic/test.json b/meson/test cases/windows/1 basic/test.json
new file mode 100644
index 000000000..650a6e208
--- /dev/null
+++ b/meson/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/meson/test cases/windows/10 vs module defs generated custom target/meson.build b/meson/test cases/windows/10 vs module defs generated custom target/meson.build
new file mode 100644
index 000000000..fe594c878
--- /dev/null
+++ b/meson/test cases/windows/10 vs module defs generated custom target/meson.build
@@ -0,0 +1,10 @@
+project('generated_dll_module_defs', 'c')
+
+if meson.backend().startswith('vs')
+ # FIXME: Broken on the VS backends
+ error('MESON_SKIP_TEST see https://github.com/mesonbuild/meson/issues/1799')
+endif
+
+subdir('subdir')
+exe = executable('prog', 'prog.c', link_with : shlib)
+test('runtest', exe)
diff --git a/meson/test cases/windows/10 vs module defs generated custom target/prog.c b/meson/test cases/windows/10 vs module defs generated custom target/prog.c
new file mode 100644
index 000000000..066ac227a
--- /dev/null
+++ b/meson/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/meson/test cases/windows/10 vs module defs generated custom target/subdir/make_def.py b/meson/test cases/windows/10 vs module defs generated custom target/subdir/make_def.py
new file mode 100755
index 000000000..50acfb5ef
--- /dev/null
+++ b/meson/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/meson/test cases/windows/10 vs module defs generated custom target/subdir/meson.build b/meson/test cases/windows/10 vs module defs generated custom target/subdir/meson.build
new file mode 100644
index 000000000..c4ae33ae4
--- /dev/null
+++ b/meson/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/meson/test cases/windows/10 vs module defs generated custom target/subdir/somedll.c b/meson/test cases/windows/10 vs module defs generated custom target/subdir/somedll.c
new file mode 100644
index 000000000..f095b1839
--- /dev/null
+++ b/meson/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/meson/test cases/windows/11 exe implib/meson.build b/meson/test cases/windows/11 exe implib/meson.build
new file mode 100644
index 000000000..0a38ec13e
--- /dev/null
+++ b/meson/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/meson/test cases/windows/11 exe implib/prog.c b/meson/test cases/windows/11 exe implib/prog.c
new file mode 100644
index 000000000..aa3bc5c57
--- /dev/null
+++ b/meson/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/meson/test cases/windows/11 exe implib/test.json b/meson/test cases/windows/11 exe implib/test.json
new file mode 100644
index 000000000..f71956838
--- /dev/null
+++ b/meson/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/meson/test cases/windows/12 resources with custom targets/meson.build b/meson/test cases/windows/12 resources with custom targets/meson.build
new file mode 100644
index 000000000..282272d76
--- /dev/null
+++ b/meson/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/meson/test cases/windows/12 resources with custom targets/prog.c b/meson/test cases/windows/12 resources with custom targets/prog.c
new file mode 100644
index 000000000..cb6892d04
--- /dev/null
+++ b/meson/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/meson/test cases/windows/12 resources with custom targets/res/gen-res.py b/meson/test cases/windows/12 resources with custom targets/res/gen-res.py
new file mode 100755
index 000000000..e5ef6b108
--- /dev/null
+++ b/meson/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/meson/test cases/windows/12 resources with custom targets/res/meson.build b/meson/test cases/windows/12 resources with custom targets/res/meson.build
new file mode 100644
index 000000000..97976370b
--- /dev/null
+++ b/meson/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/meson/test cases/windows/12 resources with custom targets/res/myres.rc.in b/meson/test cases/windows/12 resources with custom targets/res/myres.rc.in
new file mode 100644
index 000000000..0cff642ba
--- /dev/null
+++ b/meson/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/meson/test cases/windows/12 resources with custom targets/res/myres_static.rc b/meson/test cases/windows/12 resources with custom targets/res/myres_static.rc
new file mode 100644
index 000000000..12838aee2
--- /dev/null
+++ b/meson/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/meson/test cases/windows/12 resources with custom targets/res/resource.h b/meson/test cases/windows/12 resources with custom targets/res/resource.h
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/meson/test cases/windows/12 resources with custom targets/res/resource.h
diff --git a/meson/test cases/windows/12 resources with custom targets/res/sample.ico b/meson/test cases/windows/12 resources with custom targets/res/sample.ico
new file mode 100644
index 000000000..24bd3d9e9
--- /dev/null
+++ b/meson/test cases/windows/12 resources with custom targets/res/sample.ico
Binary files differ
diff --git a/meson/test cases/windows/13 test argument extra paths/exe/main.c b/meson/test cases/windows/13 test argument extra paths/exe/main.c
new file mode 100644
index 000000000..1032ae20d
--- /dev/null
+++ b/meson/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/meson/test cases/windows/13 test argument extra paths/exe/meson.build b/meson/test cases/windows/13 test argument extra paths/exe/meson.build
new file mode 100644
index 000000000..138500a58
--- /dev/null
+++ b/meson/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/meson/test cases/windows/13 test argument extra paths/lib/foo.c b/meson/test cases/windows/13 test argument extra paths/lib/foo.c
new file mode 100644
index 000000000..86b1a03cd
--- /dev/null
+++ b/meson/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/meson/test cases/windows/13 test argument extra paths/lib/foo.h b/meson/test cases/windows/13 test argument extra paths/lib/foo.h
new file mode 100644
index 000000000..5078c583a
--- /dev/null
+++ b/meson/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/meson/test cases/windows/13 test argument extra paths/lib/meson.build b/meson/test cases/windows/13 test argument extra paths/lib/meson.build
new file mode 100644
index 000000000..aa0bf145c
--- /dev/null
+++ b/meson/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/meson/test cases/windows/13 test argument extra paths/meson.build b/meson/test cases/windows/13 test argument extra paths/meson.build
new file mode 100644
index 000000000..f105946e9
--- /dev/null
+++ b/meson/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/meson/test cases/windows/13 test argument extra paths/test/meson.build b/meson/test cases/windows/13 test argument extra paths/test/meson.build
new file mode 100644
index 000000000..2e608be5d
--- /dev/null
+++ b/meson/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/meson/test cases/windows/13 test argument extra paths/test/test_run_exe.py b/meson/test cases/windows/13 test argument extra paths/test/test_run_exe.py
new file mode 100644
index 000000000..77c7ddc59
--- /dev/null
+++ b/meson/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/meson/test cases/windows/14 resources with custom target depend_files/ico/gen-ico.py b/meson/test cases/windows/14 resources with custom target depend_files/ico/gen-ico.py
new file mode 100755
index 000000000..c49e0dd59
--- /dev/null
+++ b/meson/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/meson/test cases/windows/14 resources with custom target depend_files/ico/meson.build b/meson/test cases/windows/14 resources with custom target depend_files/ico/meson.build
new file mode 100644
index 000000000..3fae9e86c
--- /dev/null
+++ b/meson/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/meson/test cases/windows/14 resources with custom target depend_files/ico/sample.ico.in b/meson/test cases/windows/14 resources with custom target depend_files/ico/sample.ico.in
new file mode 100644
index 000000000..24bd3d9e9
--- /dev/null
+++ b/meson/test cases/windows/14 resources with custom target depend_files/ico/sample.ico.in
Binary files differ
diff --git a/meson/test cases/windows/14 resources with custom target depend_files/meson.build b/meson/test cases/windows/14 resources with custom target depend_files/meson.build
new file mode 100644
index 000000000..85ba06fa2
--- /dev/null
+++ b/meson/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/meson/test cases/windows/14 resources with custom target depend_files/prog.c b/meson/test cases/windows/14 resources with custom target depend_files/prog.c
new file mode 100644
index 000000000..cb6892d04
--- /dev/null
+++ b/meson/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/meson/test cases/windows/14 resources with custom target depend_files/res/meson.build b/meson/test cases/windows/14 resources with custom target depend_files/res/meson.build
new file mode 100644
index 000000000..3d43b3f51
--- /dev/null
+++ b/meson/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/meson/test cases/windows/14 resources with custom target depend_files/res/myres.rc b/meson/test cases/windows/14 resources with custom target depend_files/res/myres.rc
new file mode 100644
index 000000000..12838aee2
--- /dev/null
+++ b/meson/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/meson/test cases/windows/15 resource scripts with duplicate filenames/a/meson.build b/meson/test cases/windows/15 resource scripts with duplicate filenames/a/meson.build
new file mode 100644
index 000000000..73f18c8b6
--- /dev/null
+++ b/meson/test cases/windows/15 resource scripts with duplicate filenames/a/meson.build
@@ -0,0 +1 @@
+a = win.compile_resources('rsrc.rc')
diff --git a/meson/test cases/windows/15 resource scripts with duplicate filenames/a/rsrc.rc b/meson/test cases/windows/15 resource scripts with duplicate filenames/a/rsrc.rc
new file mode 100644
index 000000000..1997b8ecb
--- /dev/null
+++ b/meson/test cases/windows/15 resource scripts with duplicate filenames/a/rsrc.rc
@@ -0,0 +1 @@
+a RCDATA { "a" }
diff --git a/meson/test cases/windows/15 resource scripts with duplicate filenames/b/meson.build b/meson/test cases/windows/15 resource scripts with duplicate filenames/b/meson.build
new file mode 100644
index 000000000..d0b0aabb5
--- /dev/null
+++ b/meson/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/meson/test cases/windows/15 resource scripts with duplicate filenames/b/rsrc.rc b/meson/test cases/windows/15 resource scripts with duplicate filenames/b/rsrc.rc
new file mode 100644
index 000000000..a8e3b27b4
--- /dev/null
+++ b/meson/test cases/windows/15 resource scripts with duplicate filenames/b/rsrc.rc
@@ -0,0 +1 @@
+b RCDATA { "b" }
diff --git a/meson/test cases/windows/15 resource scripts with duplicate filenames/c/meson.build b/meson/test cases/windows/15 resource scripts with duplicate filenames/c/meson.build
new file mode 100644
index 000000000..a7b7e309c
--- /dev/null
+++ b/meson/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/meson/test cases/windows/15 resource scripts with duplicate filenames/c/rsrc.rc b/meson/test cases/windows/15 resource scripts with duplicate filenames/c/rsrc.rc
new file mode 100644
index 000000000..1fa2c1cfa
--- /dev/null
+++ b/meson/test cases/windows/15 resource scripts with duplicate filenames/c/rsrc.rc
@@ -0,0 +1 @@
+c RCDATA { "c" }
diff --git a/meson/test cases/windows/15 resource scripts with duplicate filenames/exe3/meson.build b/meson/test cases/windows/15 resource scripts with duplicate filenames/exe3/meson.build
new file mode 100644
index 000000000..1b97435e7
--- /dev/null
+++ b/meson/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/meson/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_dll/main.c b/meson/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_dll/main.c
new file mode 100644
index 000000000..2bd8cd297
--- /dev/null
+++ b/meson/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/meson/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_dll/version.rc b/meson/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_dll/version.rc
new file mode 100644
index 000000000..abdbaaa64
--- /dev/null
+++ b/meson/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/meson/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_exe/main.c b/meson/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_exe/main.c
new file mode 100644
index 000000000..9b6bdc2ec
--- /dev/null
+++ b/meson/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/meson/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_exe/version.rc b/meson/test cases/windows/15 resource scripts with duplicate filenames/exe3/src_exe/version.rc
new file mode 100644
index 000000000..abdbaaa64
--- /dev/null
+++ b/meson/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/meson/test cases/windows/15 resource scripts with duplicate filenames/exe4/meson.build b/meson/test cases/windows/15 resource scripts with duplicate filenames/exe4/meson.build
new file mode 100644
index 000000000..2ae3a7125
--- /dev/null
+++ b/meson/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/meson/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_dll/main.c b/meson/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_dll/main.c
new file mode 100644
index 000000000..2bd8cd297
--- /dev/null
+++ b/meson/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/meson/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_dll/version.rc b/meson/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_dll/version.rc
new file mode 100644
index 000000000..abdbaaa64
--- /dev/null
+++ b/meson/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/meson/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_exe/main.c b/meson/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_exe/main.c
new file mode 100644
index 000000000..9b6bdc2ec
--- /dev/null
+++ b/meson/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/meson/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_exe/version.rc b/meson/test cases/windows/15 resource scripts with duplicate filenames/exe4/src_exe/version.rc
new file mode 100644
index 000000000..abdbaaa64
--- /dev/null
+++ b/meson/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/meson/test cases/windows/15 resource scripts with duplicate filenames/meson.build b/meson/test cases/windows/15 resource scripts with duplicate filenames/meson.build
new file mode 100644
index 000000000..9fa352520
--- /dev/null
+++ b/meson/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/meson/test cases/windows/15 resource scripts with duplicate filenames/rsrc.rc b/meson/test cases/windows/15 resource scripts with duplicate filenames/rsrc.rc
new file mode 100644
index 000000000..8f6aa1f5c
--- /dev/null
+++ b/meson/test cases/windows/15 resource scripts with duplicate filenames/rsrc.rc
@@ -0,0 +1 @@
+main RCDATA { "main" }
diff --git a/meson/test cases/windows/15 resource scripts with duplicate filenames/verify.c b/meson/test cases/windows/15 resource scripts with duplicate filenames/verify.c
new file mode 100644
index 000000000..8f5b88e94
--- /dev/null
+++ b/meson/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/meson/test cases/windows/16 gui app/console_prog.c b/meson/test cases/windows/16 gui app/console_prog.c
new file mode 100644
index 000000000..9b6bdc2ec
--- /dev/null
+++ b/meson/test cases/windows/16 gui app/console_prog.c
@@ -0,0 +1,3 @@
+int main(void) {
+ return 0;
+}
diff --git a/meson/test cases/windows/16 gui app/dummy.c b/meson/test cases/windows/16 gui app/dummy.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/meson/test cases/windows/16 gui app/dummy.c
diff --git a/meson/test cases/windows/16 gui app/gui_app_tester.py b/meson/test cases/windows/16 gui app/gui_app_tester.py
new file mode 100644
index 000000000..53e76493f
--- /dev/null
+++ b/meson/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/meson/test cases/windows/16 gui app/gui_prog.c b/meson/test cases/windows/16 gui app/gui_prog.c
new file mode 100644
index 000000000..9cdf17023
--- /dev/null
+++ b/meson/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/meson/test cases/windows/16 gui app/meson.build b/meson/test cases/windows/16 gui app/meson.build
new file mode 100644
index 000000000..3021c43e7
--- /dev/null
+++ b/meson/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/meson/test cases/windows/17 msvc ndebug/main.cpp b/meson/test cases/windows/17 msvc ndebug/main.cpp
new file mode 100644
index 000000000..d647d719f
--- /dev/null
+++ b/meson/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/meson/test cases/windows/17 msvc ndebug/meson.build b/meson/test cases/windows/17 msvc ndebug/meson.build
new file mode 100644
index 000000000..78eaf896d
--- /dev/null
+++ b/meson/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/meson/test cases/windows/2 winmain/meson.build b/meson/test cases/windows/2 winmain/meson.build
new file mode 100644
index 000000000..ea0d23b00
--- /dev/null
+++ b/meson/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/meson/test cases/windows/2 winmain/prog.c b/meson/test cases/windows/2 winmain/prog.c
new file mode 100644
index 000000000..3bd4c9528
--- /dev/null
+++ b/meson/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/meson/test cases/windows/3 cpp/meson.build b/meson/test cases/windows/3 cpp/meson.build
new file mode 100644
index 000000000..7b8080e54
--- /dev/null
+++ b/meson/test cases/windows/3 cpp/meson.build
@@ -0,0 +1,4 @@
+project('wincpp', 'cpp')
+
+exe = executable('prog', 'prog.cpp')
+test('wincpp', exe)
diff --git a/meson/test cases/windows/3 cpp/prog.cpp b/meson/test cases/windows/3 cpp/prog.cpp
new file mode 100644
index 000000000..69092f7b7
--- /dev/null
+++ b/meson/test cases/windows/3 cpp/prog.cpp
@@ -0,0 +1,7 @@
+#include<windows.h>
+
+class Foo;
+
+int main(void) {
+ return 0;
+}
diff --git a/meson/test cases/windows/4 winmaincpp/meson.build b/meson/test cases/windows/4 winmaincpp/meson.build
new file mode 100644
index 000000000..4eda8ca01
--- /dev/null
+++ b/meson/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/meson/test cases/windows/4 winmaincpp/prog.cpp b/meson/test cases/windows/4 winmaincpp/prog.cpp
new file mode 100644
index 000000000..618225771
--- /dev/null
+++ b/meson/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/meson/test cases/windows/5 resources/inc/meson.build b/meson/test cases/windows/5 resources/inc/meson.build
new file mode 100644
index 000000000..b8b511a98
--- /dev/null
+++ b/meson/test cases/windows/5 resources/inc/meson.build
@@ -0,0 +1 @@
+inc = include_directories('resource')
diff --git a/meson/test cases/windows/5 resources/inc/resource/resource.h b/meson/test cases/windows/5 resources/inc/resource/resource.h
new file mode 100644
index 000000000..dbdd5094d
--- /dev/null
+++ b/meson/test cases/windows/5 resources/inc/resource/resource.h
@@ -0,0 +1 @@
+#define ICON_ID 1
diff --git a/meson/test cases/windows/5 resources/meson.build b/meson/test cases/windows/5 resources/meson.build
new file mode 100644
index 000000000..27b2fcc70
--- /dev/null
+++ b/meson/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/meson/test cases/windows/5 resources/prog.c b/meson/test cases/windows/5 resources/prog.c
new file mode 100644
index 000000000..3409c398c
--- /dev/null
+++ b/meson/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/meson/test cases/windows/5 resources/res/dummy.c b/meson/test cases/windows/5 resources/res/dummy.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/meson/test cases/windows/5 resources/res/dummy.c
diff --git a/meson/test cases/windows/5 resources/res/meson.build b/meson/test cases/windows/5 resources/res/meson.build
new file mode 100644
index 000000000..74e0778d2
--- /dev/null
+++ b/meson/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/meson/test cases/windows/5 resources/res/myres.rc b/meson/test cases/windows/5 resources/res/myres.rc
new file mode 100644
index 000000000..802bc7b45
--- /dev/null
+++ b/meson/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/meson/test cases/windows/5 resources/res/sample.ico b/meson/test cases/windows/5 resources/res/sample.ico
new file mode 100644
index 000000000..24bd3d9e9
--- /dev/null
+++ b/meson/test cases/windows/5 resources/res/sample.ico
Binary files differ
diff --git a/meson/test cases/windows/6 vs module defs/meson.build b/meson/test cases/windows/6 vs module defs/meson.build
new file mode 100644
index 000000000..fb59028fa
--- /dev/null
+++ b/meson/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/meson/test cases/windows/6 vs module defs/prog.c b/meson/test cases/windows/6 vs module defs/prog.c
new file mode 100644
index 000000000..066ac227a
--- /dev/null
+++ b/meson/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/meson/test cases/windows/6 vs module defs/subdir/meson.build b/meson/test cases/windows/6 vs module defs/subdir/meson.build
new file mode 100644
index 000000000..60633c323
--- /dev/null
+++ b/meson/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/meson/test cases/windows/6 vs module defs/subdir/somedll.c b/meson/test cases/windows/6 vs module defs/subdir/somedll.c
new file mode 100644
index 000000000..f095b1839
--- /dev/null
+++ b/meson/test cases/windows/6 vs module defs/subdir/somedll.c
@@ -0,0 +1,3 @@
+int somedllfunc(void) {
+ return 42;
+}
diff --git a/meson/test cases/windows/6 vs module defs/subdir/somedll.def b/meson/test cases/windows/6 vs module defs/subdir/somedll.def
new file mode 100644
index 000000000..217801bf5
--- /dev/null
+++ b/meson/test cases/windows/6 vs module defs/subdir/somedll.def
@@ -0,0 +1,3 @@
+EXPORTS
+ somedllfunc
+
diff --git a/meson/test cases/windows/7 dll versioning/copyfile.py b/meson/test cases/windows/7 dll versioning/copyfile.py
new file mode 100644
index 000000000..ff42ac359
--- /dev/null
+++ b/meson/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/meson/test cases/windows/7 dll versioning/exe.orig.c b/meson/test cases/windows/7 dll versioning/exe.orig.c
new file mode 100644
index 000000000..1e8e90e76
--- /dev/null
+++ b/meson/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/meson/test cases/windows/7 dll versioning/lib.c b/meson/test cases/windows/7 dll versioning/lib.c
new file mode 100644
index 000000000..37e0d1d7e
--- /dev/null
+++ b/meson/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/meson/test cases/windows/7 dll versioning/meson.build b/meson/test cases/windows/7 dll versioning/meson.build
new file mode 100644
index 000000000..983c2c492
--- /dev/null
+++ b/meson/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/meson/test cases/windows/7 dll versioning/test.json b/meson/test cases/windows/7 dll versioning/test.json
new file mode 100644
index 000000000..14029254f
--- /dev/null
+++ b/meson/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/meson/test cases/windows/8 find program/meson.build b/meson/test cases/windows/8 find program/meson.build
new file mode 100644
index 000000000..565fb626d
--- /dev/null
+++ b/meson/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/meson/test cases/windows/8 find program/test-script b/meson/test cases/windows/8 find program/test-script
new file mode 100644
index 000000000..e76416525
--- /dev/null
+++ b/meson/test cases/windows/8 find program/test-script
@@ -0,0 +1,3 @@
+#!/usr/bin/env python3
+
+print('1')
diff --git a/meson/test cases/windows/8 find program/test-script-ext.py b/meson/test cases/windows/8 find program/test-script-ext.py
new file mode 100644
index 000000000..ae9adfb8e
--- /dev/null
+++ b/meson/test cases/windows/8 find program/test-script-ext.py
@@ -0,0 +1,3 @@
+#!/usr/bin/env python3
+
+print('ext/noext')
diff --git a/meson/test cases/windows/9 vs module defs generated/meson.build b/meson/test cases/windows/9 vs module defs generated/meson.build
new file mode 100644
index 000000000..7728ca77a
--- /dev/null
+++ b/meson/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/meson/test cases/windows/9 vs module defs generated/prog.c b/meson/test cases/windows/9 vs module defs generated/prog.c
new file mode 100644
index 000000000..066ac227a
--- /dev/null
+++ b/meson/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/meson/test cases/windows/9 vs module defs generated/subdir/meson.build b/meson/test cases/windows/9 vs module defs generated/subdir/meson.build
new file mode 100644
index 000000000..356f83a36
--- /dev/null
+++ b/meson/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/meson/test cases/windows/9 vs module defs generated/subdir/somedll.c b/meson/test cases/windows/9 vs module defs generated/subdir/somedll.c
new file mode 100644
index 000000000..f095b1839
--- /dev/null
+++ b/meson/test cases/windows/9 vs module defs generated/subdir/somedll.c
@@ -0,0 +1,3 @@
+int somedllfunc(void) {
+ return 42;
+}
diff --git a/meson/test cases/windows/9 vs module defs generated/subdir/somedll.def.in b/meson/test cases/windows/9 vs module defs generated/subdir/somedll.def.in
new file mode 100644
index 000000000..c29207c71
--- /dev/null
+++ b/meson/test cases/windows/9 vs module defs generated/subdir/somedll.def.in
@@ -0,0 +1,2 @@
+EXPORTS
+ @func@