diff options
author | Nicolas Schneider <nioncode+git@gmail.com> | 2019-01-27 11:03:26 +0100 |
---|---|---|
committer | Nicolas Schneider <nioncode+git@gmail.com> | 2019-02-01 22:28:52 +0100 |
commit | 2044bc53b3534e0e91d75b5435792e4b4d342847 (patch) | |
tree | 3d27600fb681d9cd77ecc9bc16aed5c736c53882 /test cases/common/13 pch | |
parent | da7b9df16c696979b0f3860cbde1692e2ba5e0cc (diff) | |
download | meson-2044bc53b3534e0e91d75b5435792e4b4d342847.zip meson-2044bc53b3534e0e91d75b5435792e4b4d342847.tar.gz meson-2044bc53b3534e0e91d75b5435792e4b4d342847.tar.bz2 |
use same compiler args for pch as for regular target
Fixes #999, #1415, #2361.
Diffstat (limited to 'test cases/common/13 pch')
13 files changed, 70 insertions, 0 deletions
diff --git a/test cases/common/13 pch/generated/gen_custom.py b/test cases/common/13 pch/generated/gen_custom.py new file mode 100644 index 0000000..650e03c --- /dev/null +++ b/test cases/common/13 pch/generated/gen_custom.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python3 +import sys + +with open(sys.argv[1], 'w') as f: + f.write("#define FOO 0") diff --git a/test cases/common/13 pch/generated/gen_generator.py b/test cases/common/13 pch/generated/gen_generator.py new file mode 100644 index 0000000..a245e7a --- /dev/null +++ b/test cases/common/13 pch/generated/gen_generator.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 +import sys + +with open(sys.argv[1]) as f: + content = f.read() +with open(sys.argv[2], 'w') as f: + f.write(content) diff --git a/test cases/common/13 pch/generated/generated_generator.in b/test cases/common/13 pch/generated/generated_generator.in new file mode 100644 index 0000000..1a00ebd --- /dev/null +++ b/test cases/common/13 pch/generated/generated_generator.in @@ -0,0 +1 @@ +#define BAR 0 diff --git a/test cases/common/13 pch/generated/meson.build b/test cases/common/13 pch/generated/meson.build new file mode 100644 index 0000000..372a00e --- /dev/null +++ b/test cases/common/13 pch/generated/meson.build @@ -0,0 +1,16 @@ +cc = meson.get_compiler('c') +cc_id = cc.get_id() +if cc_id == 'lcc' + error('MESON_SKIP_TEST: Elbrus compiler does not support PCH.') +endif + +generated_customTarget = custom_target('makeheader', + output: 'generated_customTarget.h', + command : [find_program('gen_custom.py'), '@OUTPUT0@']) + +generated_generator = generator(find_program('gen_generator.py'), + output: '@BASENAME@.h', + arguments: ['@INPUT@', '@OUTPUT@']) + +exe = executable('prog', 'prog.c', generated_customTarget, generated_generator.process('generated_generator.in'), + c_pch: ['pch/prog_pch.c', 'pch/prog.h']) diff --git a/test cases/common/13 pch/generated/pch/prog.h b/test cases/common/13 pch/generated/pch/prog.h new file mode 100644 index 0000000..15fec38 --- /dev/null +++ b/test cases/common/13 pch/generated/pch/prog.h @@ -0,0 +1,2 @@ +#include "generated_customTarget.h" +#include "generated_generator.h" diff --git a/test cases/common/13 pch/generated/pch/prog_pch.c b/test cases/common/13 pch/generated/pch/prog_pch.c new file mode 100644 index 0000000..4960505 --- /dev/null +++ b/test cases/common/13 pch/generated/pch/prog_pch.c @@ -0,0 +1,5 @@ +#if !defined(_MSC_VER) +#error "This file is only for use with MSVC." +#endif + +#include "prog.h" diff --git a/test cases/common/13 pch/generated/prog.c b/test cases/common/13 pch/generated/prog.c new file mode 100644 index 0000000..9b2e2ef --- /dev/null +++ b/test cases/common/13 pch/generated/prog.c @@ -0,0 +1,6 @@ +// No includes here, they need to come from the PCH + +int main(int argc, char **argv) { + return FOO + BAR; +} + diff --git a/test cases/common/13 pch/meson.build b/test cases/common/13 pch/meson.build index d39527b..43129c9 100644 --- a/test cases/common/13 pch/meson.build +++ b/test cases/common/13 pch/meson.build @@ -2,6 +2,8 @@ project('pch test', 'c', 'cpp') subdir('c') subdir('cpp') +subdir('generated') +subdir('withIncludeDirectories') if meson.backend() == 'xcode' warning('Xcode backend only supports one precompiled header per target. Skipping "mixed" which has various precompiled headers.') diff --git a/test cases/common/13 pch/withIncludeDirectories/include/lib/lib.h b/test cases/common/13 pch/withIncludeDirectories/include/lib/lib.h new file mode 100644 index 0000000..53c5fdf --- /dev/null +++ b/test cases/common/13 pch/withIncludeDirectories/include/lib/lib.h @@ -0,0 +1 @@ +#include <stdio.h> diff --git a/test cases/common/13 pch/withIncludeDirectories/meson.build b/test cases/common/13 pch/withIncludeDirectories/meson.build new file mode 100644 index 0000000..2ab2cd8 --- /dev/null +++ b/test cases/common/13 pch/withIncludeDirectories/meson.build @@ -0,0 +1,9 @@ +cc = meson.get_compiler('c') +cc_id = cc.get_id() +if cc_id == 'lcc' + error('MESON_SKIP_TEST: Elbrus compiler does not support PCH.') +endif + +exe = executable('prog', 'prog.c', + include_directories: 'include', + c_pch : ['pch/prog_pch.c', 'pch/prog.h']) diff --git a/test cases/common/13 pch/withIncludeDirectories/pch/prog.h b/test cases/common/13 pch/withIncludeDirectories/pch/prog.h new file mode 100644 index 0000000..383b2c5 --- /dev/null +++ b/test cases/common/13 pch/withIncludeDirectories/pch/prog.h @@ -0,0 +1 @@ +#include<lib/lib.h> diff --git a/test cases/common/13 pch/withIncludeDirectories/pch/prog_pch.c b/test cases/common/13 pch/withIncludeDirectories/pch/prog_pch.c new file mode 100644 index 0000000..4960505 --- /dev/null +++ b/test cases/common/13 pch/withIncludeDirectories/pch/prog_pch.c @@ -0,0 +1,5 @@ +#if !defined(_MSC_VER) +#error "This file is only for use with MSVC." +#endif + +#include "prog.h" diff --git a/test cases/common/13 pch/withIncludeDirectories/prog.c b/test cases/common/13 pch/withIncludeDirectories/prog.c new file mode 100644 index 0000000..0ce3d0a --- /dev/null +++ b/test cases/common/13 pch/withIncludeDirectories/prog.c @@ -0,0 +1,10 @@ +// No includes here, they need to come from the PCH + +void func() { + fprintf(stdout, "This is a function that fails if stdio is not #included.\n"); +} + +int main(int argc, char **argv) { + return 0; +} + |