From 3a960023d3e78d04651850178db96c7d742725e6 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 29 Mar 2022 13:52:03 +0200 Subject: interpreter: new function add_project_dependencies() This function can be used to add fundamental dependencies such as glib to all build products in one fell swoop. This can be useful whenever, due to a project's coding conventions, it is not really possible to compile any source file without including the dependency. Signed-off-by: Paolo Bonzini --- .../common/251 add_project_dependencies/inc/lib.h | 2 ++ .../common/251 add_project_dependencies/lib.c | 14 ++++++++++++++ .../common/251 add_project_dependencies/main.c | 5 +++++ .../251 add_project_dependencies/meson.build | 22 ++++++++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 test cases/common/251 add_project_dependencies/inc/lib.h create mode 100644 test cases/common/251 add_project_dependencies/lib.c create mode 100644 test cases/common/251 add_project_dependencies/main.c create mode 100644 test cases/common/251 add_project_dependencies/meson.build (limited to 'test cases') diff --git a/test cases/common/251 add_project_dependencies/inc/lib.h b/test cases/common/251 add_project_dependencies/inc/lib.h new file mode 100644 index 0000000..ceca99f --- /dev/null +++ b/test cases/common/251 add_project_dependencies/inc/lib.h @@ -0,0 +1,2 @@ +#pragma once +extern int ok(void); diff --git a/test cases/common/251 add_project_dependencies/lib.c b/test cases/common/251 add_project_dependencies/lib.c new file mode 100644 index 0000000..ac46bfc --- /dev/null +++ b/test cases/common/251 add_project_dependencies/lib.c @@ -0,0 +1,14 @@ +#include +#include + +#ifndef DEFINED +#error expected compile_arg not found +#endif + +double zero; +int ok(void) { + void * something = deflate; + if(something != 0) + return 0; + return (int)cos(zero); +} diff --git a/test cases/common/251 add_project_dependencies/main.c b/test cases/common/251 add_project_dependencies/main.c new file mode 100644 index 0000000..93b7f72 --- /dev/null +++ b/test cases/common/251 add_project_dependencies/main.c @@ -0,0 +1,5 @@ +#include "lib.h" + +int main(void) { + return ok(); +} diff --git a/test cases/common/251 add_project_dependencies/meson.build b/test cases/common/251 add_project_dependencies/meson.build new file mode 100644 index 0000000..4047e6d --- /dev/null +++ b/test cases/common/251 add_project_dependencies/meson.build @@ -0,0 +1,22 @@ +project('zlib system dependency', 'c') + +cc = meson.get_compiler('c') + +m = cc.find_library('m', required: false) +add_project_dependencies(m, language: ['c']) + +z = dependency('zlib', method: 'system', required: false) +if not z.found() + error('MESON_SKIP_TEST zlib not present') +endif + +z_c_args = z.partial_dependency(compile_args: true, includes: true) +add_project_dependencies(z_c_args, language: 'c', native: false) + +global_dep = declare_dependency(include_directories: include_directories('inc'), + compile_args: '-DDEFINED') +add_project_dependencies(global_dep, language: 'c', native: false) + +lib = static_library('rary', 'lib.c') +exe = executable('prog', 'main.c', link_with: lib, dependencies: z) +test('test', exe) -- cgit v1.1