diff options
author | Andrei Alexeyev <0x416b617269@gmail.com> | 2017-12-21 22:36:30 +0200 |
---|---|---|
committer | Andrei Alexeyev <0x416b617269@gmail.com> | 2018-01-12 23:36:48 +0200 |
commit | ef7cb9f280175d026b16e8e02ecda9ec87d7fd6d (patch) | |
tree | 6688b12076610f9276fc198ee49d39df581dbb52 /test cases | |
parent | 81100f0695c595f4c0020034284846cea7e8e6aa (diff) | |
download | meson-ef7cb9f280175d026b16e8e02ecda9ec87d7fd6d.zip meson-ef7cb9f280175d026b16e8e02ecda9ec87d7fd6d.tar.gz meson-ef7cb9f280175d026b16e8e02ecda9ec87d7fd6d.tar.bz2 |
[windows] make compile_resources use custom targets instead of generators
Diffstat (limited to 'test cases')
8 files changed, 108 insertions, 0 deletions
diff --git a/test cases/windows/13 resources with custom targets/inc/meson.build b/test cases/windows/13 resources with custom targets/inc/meson.build new file mode 100644 index 0000000..b8b511a --- /dev/null +++ b/test cases/windows/13 resources with custom targets/inc/meson.build @@ -0,0 +1 @@ +inc = include_directories('resource') diff --git a/test cases/windows/13 resources with custom targets/inc/resource/resource.h b/test cases/windows/13 resources with custom targets/inc/resource/resource.h new file mode 100644 index 0000000..dbdd509 --- /dev/null +++ b/test cases/windows/13 resources with custom targets/inc/resource/resource.h @@ -0,0 +1 @@ +#define ICON_ID 1 diff --git a/test cases/windows/13 resources with custom targets/meson.build b/test cases/windows/13 resources with custom targets/meson.build new file mode 100644 index 0000000..ddb7d6e --- /dev/null +++ b/test cases/windows/13 resources with custom targets/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('inc') +subdir('res') + +exe = executable('prog', 'prog.c', + res, + gui_app : true) + +test('winmain', exe) diff --git a/test cases/windows/13 resources with custom targets/prog.c b/test cases/windows/13 resources with custom targets/prog.c new file mode 100644 index 0000000..2c6f153 --- /dev/null +++ b/test cases/windows/13 resources with custom targets/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(NULL, IDI_APPLICATION); + return hIcon ? 0 : 1; +} diff --git a/test cases/windows/13 resources with custom targets/res/gen-res.py b/test cases/windows/13 resources with custom targets/res/gen-res.py new file mode 100755 index 0000000..2feb02f --- /dev/null +++ b/test cases/windows/13 resources with custom targets/res/gen-res.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 + +import sys + +with open(sys.argv[1], 'r') as infile, open(sys.argv[2], 'w') as outfile: + outfile.write(infile.read().format(icon=sys.argv[3])) diff --git a/test cases/windows/13 resources with custom targets/res/meson.build b/test cases/windows/13 resources with custom targets/res/meson.build new file mode 100644 index 0000000..266e380 --- /dev/null +++ b/test cases/windows/13 resources with custom targets/res/meson.build @@ -0,0 +1,13 @@ +win = import('windows') + +rc_writer = find_program('./gen-res.py') + +rc_target = custom_target('RC source file', + input : 'myres.rc.in', + output : 'myres.rc', + command : [rc_writer, '@INPUT@', '@OUTPUT@', files('sample.ico')], + install : false, + build_always : true) + +res = win.compile_resources(rc_target, + include_directories : inc) diff --git a/test cases/windows/13 resources with custom targets/res/myres.rc.in b/test cases/windows/13 resources with custom targets/res/myres.rc.in new file mode 100644 index 0000000..9bb045d --- /dev/null +++ b/test cases/windows/13 resources with custom targets/res/myres.rc.in @@ -0,0 +1,4 @@ +#include<windows.h> +#include"resource.h" + +ICON_ID ICON "{icon}" diff --git a/test cases/windows/13 resources with custom targets/res/sample.ico b/test cases/windows/13 resources with custom targets/res/sample.ico Binary files differnew file mode 100644 index 0000000..24bd3d9 --- /dev/null +++ b/test cases/windows/13 resources with custom targets/res/sample.ico |