aboutsummaryrefslogtreecommitdiff
path: root/test cases/windows
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2018-05-15 10:05:32 +0100
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-06-18 10:52:21 +0000
commit09c03a409b057ed269b1e1671a5b8c857015ce5a (patch)
treeab81e4b12986230812d60c6ba8ce8a2da5c43d01 /test cases/windows
parent7c4b8591b0f556bb58b380c6199fb018481380be (diff)
downloadmeson-09c03a409b057ed269b1e1671a5b8c857015ce5a.zip
meson-09c03a409b057ed269b1e1671a5b8c857015ce5a.tar.gz
meson-09c03a409b057ed269b1e1671a5b8c857015ce5a.tar.bz2
Test windows.compile_resource() when depends: is a custom_target
This test covers the case where the resource script references a file which is created by a custom_target (in this case, an icon). Put icon in a separate directory to ensure we excercise setting the include path to the directory which contains it.
Diffstat (limited to 'test cases/windows')
-rwxr-xr-xtest cases/windows/15 resources with custom target depend_files/ico/gen-ico.py6
-rw-r--r--test cases/windows/15 resources with custom target depend_files/ico/meson.build8
-rw-r--r--test cases/windows/15 resources with custom target depend_files/ico/sample.ico.inbin0 -> 9662 bytes
-rw-r--r--test cases/windows/15 resources with custom target depend_files/meson.build69
-rw-r--r--test cases/windows/15 resources with custom target depend_files/prog.c14
-rw-r--r--test cases/windows/15 resources with custom target depend_files/res/meson.build4
-rw-r--r--test cases/windows/15 resources with custom target depend_files/res/myres.rc3
7 files changed, 104 insertions, 0 deletions
diff --git a/test cases/windows/15 resources with custom target depend_files/ico/gen-ico.py b/test cases/windows/15 resources with custom target depend_files/ico/gen-ico.py
new file mode 100755
index 0000000..c49e0dd
--- /dev/null
+++ b/test cases/windows/15 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/15 resources with custom target depend_files/ico/meson.build b/test cases/windows/15 resources with custom target depend_files/ico/meson.build
new file mode 100644
index 0000000..3fae9e8
--- /dev/null
+++ b/test cases/windows/15 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/15 resources with custom target depend_files/ico/sample.ico.in b/test cases/windows/15 resources with custom target depend_files/ico/sample.ico.in
new file mode 100644
index 0000000..24bd3d9
--- /dev/null
+++ b/test cases/windows/15 resources with custom target depend_files/ico/sample.ico.in
Binary files differ
diff --git a/test cases/windows/15 resources with custom target depend_files/meson.build b/test cases/windows/15 resources with custom target depend_files/meson.build
new file mode 100644
index 0000000..85ba06f
--- /dev/null
+++ b/test cases/windows/15 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/15 resources with custom target depend_files/prog.c b/test cases/windows/15 resources with custom target depend_files/prog.c
new file mode 100644
index 0000000..2bef6a2
--- /dev/null
+++ b/test cases/windows/15 resources with custom target depend_files/prog.c
@@ -0,0 +1,14 @@
+#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));
+ return hIcon ? 0 : 1;
+}
diff --git a/test cases/windows/15 resources with custom target depend_files/res/meson.build b/test cases/windows/15 resources with custom target depend_files/res/meson.build
new file mode 100644
index 0000000..3d43b3f
--- /dev/null
+++ b/test cases/windows/15 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/15 resources with custom target depend_files/res/myres.rc b/test cases/windows/15 resources with custom target depend_files/res/myres.rc
new file mode 100644
index 0000000..12838ae
--- /dev/null
+++ b/test cases/windows/15 resources with custom target depend_files/res/myres.rc
@@ -0,0 +1,3 @@
+#include<windows.h>
+
+1 ICON "sample.ico"