-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
1 parent
06b76f7
commit 3a96002
Showing
10 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## `add_project_dependencies()` function | ||
|
||
Dependencies can now be added to all build products using | ||
`add_project_dependencies()`. This can be useful in several | ||
cases: | ||
|
||
* with special dependencies such as `dependency('threads')` | ||
* with system libraries such as `find_library('m')` | ||
* with the `include_directories` keyword argument of | ||
`declare_dependency()`, to add both source and build | ||
directories to the include search path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: add_project_dependencies | ||
since: 0.63.0 | ||
returns: void | ||
description: | | ||
Adds arguments to the compiler and linker command line, so that the | ||
given set of dependencies is included in all build products for this | ||
project. | ||
varargs: | ||
type: dep | ||
name: dependencies | ||
description: The dependencies to add; if internal dependencies are included, | ||
they must not include any built object. | ||
|
||
kwargs_inherit: add_global_arguments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#pragma once | ||
extern int ok(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <zlib.h> | ||
#include <math.h> | ||
|
||
#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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "lib.h" | ||
|
||
int main(void) { | ||
return ok(); | ||
} |
22 changes: 22 additions & 0 deletions
22
test cases/common/251 add_project_dependencies/meson.build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |