diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2015-12-28 18:39:21 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2015-12-28 18:39:21 +0200 |
commit | 23b1ac795b6699d4ca6d5a2c1244664f7fc511f6 (patch) | |
tree | 78456bd9e43ea0bdbfa2edc9b367ffa6410a15ed /test cases | |
parent | 5e12c03db6c0bf7b266fc351dc24e13d4e6f737e (diff) | |
parent | 9bf641e545f163cd5e9e7e3b5e9aa1f9e002e5d9 (diff) | |
download | meson-23b1ac795b6699d4ca6d5a2c1244664f7fc511f6.zip meson-23b1ac795b6699d4ca6d5a2c1244664f7fc511f6.tar.gz meson-23b1ac795b6699d4ca6d5a2c1244664f7fc511f6.tar.bz2 |
Merge pull request #338 from mesonbuild/multigen
Custom target libgen
Diffstat (limited to 'test cases')
-rw-r--r-- | test cases/common/103 manygen/depuser.c | 8 | ||||
-rw-r--r-- | test cases/common/103 manygen/meson.build | 8 | ||||
-rw-r--r-- | test cases/common/103 manygen/subdir/funcinfo.def | 1 | ||||
-rwxr-xr-x | test cases/common/103 manygen/subdir/manygen.py | 69 | ||||
-rw-r--r-- | test cases/common/103 manygen/subdir/meson.build | 7 |
5 files changed, 93 insertions, 0 deletions
diff --git a/test cases/common/103 manygen/depuser.c b/test cases/common/103 manygen/depuser.c new file mode 100644 index 0000000..1a825e0 --- /dev/null +++ b/test cases/common/103 manygen/depuser.c @@ -0,0 +1,8 @@ +#include"gen_func.h" + +int main(int argc, char **argv) { + unsigned int i = (unsigned int) gen_func_in_lib(); + unsigned int j = (unsigned int) gen_func_in_obj(); + unsigned int k = (unsigned int) gen_func_in_src(); + return (int)(i + j + k); +} diff --git a/test cases/common/103 manygen/meson.build b/test cases/common/103 manygen/meson.build new file mode 100644 index 0000000..5079d1b --- /dev/null +++ b/test cases/common/103 manygen/meson.build @@ -0,0 +1,8 @@ +project('manygen', 'c') + +subdir('subdir') + +exe = executable('depuser', 'depuser.c', + generated) + +test('depuser test', exe) diff --git a/test cases/common/103 manygen/subdir/funcinfo.def b/test cases/common/103 manygen/subdir/funcinfo.def new file mode 100644 index 0000000..b074186 --- /dev/null +++ b/test cases/common/103 manygen/subdir/funcinfo.def @@ -0,0 +1 @@ +gen_func diff --git a/test cases/common/103 manygen/subdir/manygen.py b/test cases/common/103 manygen/subdir/manygen.py new file mode 100755 index 0000000..fbf2eae --- /dev/null +++ b/test cases/common/103 manygen/subdir/manygen.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 + +# Generates a static library, object file, source +# file and a header file. + +import sys, os +import shutil, subprocess + +funcname = open(sys.argv[1]).readline().strip() +outdir = sys.argv[2] + +if not os.path.isdir(outdir): + print('Outdir does not exist.') + sys.exit(1) + +if shutil.which('cl'): + print('VS support not yet added.') + sys.exit(1) + +objsuffix = '.o' +libsuffix = '.a' + +outo = os.path.join(outdir, funcname + objsuffix) +outa = os.path.join(outdir, funcname + libsuffix) +outh = os.path.join(outdir, funcname + '.h') +outc = os.path.join(outdir, funcname + '.c') + +compiler = shutil.which('gcc') +if compiler is None: + compiler = shutil.which('clang') +if compiler is None: + compiler = shutil.which('cc') +if compiler is None: + print('No known compilers found.') + sys.exit(1) +linker = 'ar' + +tmpc = 'diibadaaba.c' +tmpo = 'diibadaaba' + objsuffix + +open(outc, 'w').write('''#include"%s.h" +int %s_in_src() { + return 0; +} +''' % (funcname, funcname)) + +open(outh, 'w').write('''#pragma once +int %s_in_lib(); +int %s_in_obj(); +int %s_in_src(); +''' % (funcname, funcname, funcname)) + +open(tmpc, 'w').write('''int %s_in_obj() { + return 0; +} +''' % funcname) + +subprocess.check_call([compiler, '-c', '-o', outo, tmpc]) + +open(tmpc, 'w').write('''int %s_in_lib() { + return 0; +} +''' % funcname) + +subprocess.check_call([compiler, '-c', '-o', tmpo, tmpc]) +subprocess.check_call([linker, 'csr', outa, tmpo]) +os.unlink(tmpo) +os.unlink(tmpc) + diff --git a/test cases/common/103 manygen/subdir/meson.build b/test cases/common/103 manygen/subdir/meson.build new file mode 100644 index 0000000..4470d1a --- /dev/null +++ b/test cases/common/103 manygen/subdir/meson.build @@ -0,0 +1,7 @@ +gen = find_program('manygen.py') + +generated = custom_target('manygen', + output : ['gen_func.a', 'gen_func.c', 'gen_func.h', 'gen_func.o'], + input : ['funcinfo.def'], + command : [gen, '@INPUT@', '@OUTDIR@'], +) |