From 3be01a7e7b13f2bb759b32c77f35db576c3cff9a Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Fri, 23 Sep 2016 08:02:11 +0530 Subject: [PATCH] Add a test for generated header deps of generated sources --- test cases/common/95 dep fallback/gensrc.py | 6 ++++++ test cases/common/95 dep fallback/meson.build | 11 ++++++++++- .../common/95 dep fallback/subprojects/boblib/bob.c | 3 +++ .../common/95 dep fallback/subprojects/boblib/bob.h | 3 +++ .../95 dep fallback/subprojects/boblib/genbob.py | 7 +++++++ .../95 dep fallback/subprojects/boblib/meson.build | 11 ++++++++++- test cases/common/95 dep fallback/tester.c | 1 + 7 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 test cases/common/95 dep fallback/gensrc.py create mode 100644 test cases/common/95 dep fallback/subprojects/boblib/genbob.py diff --git a/test cases/common/95 dep fallback/gensrc.py b/test cases/common/95 dep fallback/gensrc.py new file mode 100644 index 000000000..da503e27c --- /dev/null +++ b/test cases/common/95 dep fallback/gensrc.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python + +import sys +import shutil + +shutil.copyfile(sys.argv[1], sys.argv[2]) diff --git a/test cases/common/95 dep fallback/meson.build b/test cases/common/95 dep fallback/meson.build index 4cf0577ae..13541f2af 100644 --- a/test cases/common/95 dep fallback/meson.build +++ b/test cases/common/95 dep fallback/meson.build @@ -6,5 +6,14 @@ if not bob.found() endif jimmy = dependency('jimmylib', fallback : ['jimmylib', 'jimmy_dep'], required: false) -exe = executable('bobtester', 'tester.c', dependencies : bob) +gensrc_py = find_program('gensrc.py') +gensrc = custom_target('gensrc.c', + input : 'tester.c', + output : 'gensrc.c', + command : [gensrc_py, '@INPUT@', '@OUTPUT@']) + +exe = executable('bobtester', + [gensrc], + dependencies : bob) + test('bobtester', exe) diff --git a/test cases/common/95 dep fallback/subprojects/boblib/bob.c b/test cases/common/95 dep fallback/subprojects/boblib/bob.c index b483a555a..ae0f394d5 100644 --- a/test cases/common/95 dep fallback/subprojects/boblib/bob.c +++ b/test cases/common/95 dep fallback/subprojects/boblib/bob.c @@ -1,5 +1,8 @@ #include"bob.h" +#ifdef _MSC_VER +__declspec(dllexport) +#endif const char* get_bob() { return "bob"; } diff --git a/test cases/common/95 dep fallback/subprojects/boblib/bob.h b/test cases/common/95 dep fallback/subprojects/boblib/bob.h index bc170efca..f874ae7c1 100644 --- a/test cases/common/95 dep fallback/subprojects/boblib/bob.h +++ b/test cases/common/95 dep fallback/subprojects/boblib/bob.h @@ -1,3 +1,6 @@ #pragma once +#ifdef _MSC_VER +__declspec(dllimport) +#endif const char* get_bob(); diff --git a/test cases/common/95 dep fallback/subprojects/boblib/genbob.py b/test cases/common/95 dep fallback/subprojects/boblib/genbob.py new file mode 100644 index 000000000..824194b0d --- /dev/null +++ b/test cases/common/95 dep fallback/subprojects/boblib/genbob.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python + +import os +import sys + +with open(sys.argv[1], 'w') as f: + f.write('') diff --git a/test cases/common/95 dep fallback/subprojects/boblib/meson.build b/test cases/common/95 dep fallback/subprojects/boblib/meson.build index 8dc1f3a1b..bb250e42f 100644 --- a/test cases/common/95 dep fallback/subprojects/boblib/meson.build +++ b/test cases/common/95 dep fallback/subprojects/boblib/meson.build @@ -1,7 +1,16 @@ project('bob', 'c') -boblib = static_library('bob', 'bob.c') +gensrc_py = find_program('genbob.py') +genbob_h = custom_target('genbob.h', + output : 'genbob.h', + command : [gensrc_py, '@OUTPUT@']) +genbob_c = custom_target('genbob.c', + output : 'genbob.c', + command : [gensrc_py, '@OUTPUT@']) + +boblib = library('bob', ['bob.c', genbob_c]) bobinc = include_directories('.') bob_dep = declare_dependency(link_with : boblib, + sources : [genbob_h], include_directories : bobinc) diff --git a/test cases/common/95 dep fallback/tester.c b/test cases/common/95 dep fallback/tester.c index 59e16352b..e6651d961 100644 --- a/test cases/common/95 dep fallback/tester.c +++ b/test cases/common/95 dep fallback/tester.c @@ -1,4 +1,5 @@ #include"bob.h" +#include"genbob.h" #include #include