-
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.
Select static or shared from both_libraries in dep
Add `.as_static()` and `.as_shared()` methods to internal dependencies. Add `prefer_static` keyword to `internal_dependency()`. Internal dependencies can now choose between static and shared version of a `both_libraries` linked library. This allows to use the same dependency objects for building either a static or a shared library from the same hierarchy of dependecies.
- Loading branch information
Showing
20 changed files
with
204 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## `dep.as_static()` and `dep.as_shared()` functions | ||
|
||
Internal dependencies can now choose between static and shared version | ||
of a `both_libraries` linked library. This allows to use the same | ||
dependency objects for building either a static or a shared library from | ||
the same hierarchy of dependecies. | ||
|
||
`internal_depencency` now have `.as_static()` and `.as_shared()` methods, to | ||
convert it to a dependency that prefer either version of the linked targets. | ||
|
||
Add `prefer_static` keyword to `internal_dependency()`, to set the default | ||
prefered version. Otherwise, uses the `prefer_static` option to select the | ||
prefered version. |
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
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
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,4 @@ | ||
int libfunc1(void) | ||
{ | ||
return 1; | ||
} |
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,3 @@ | ||
EXPORTS | ||
|
||
libfunc1 @1 |
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,4 @@ | ||
int libfunc2(void) | ||
{ | ||
return 2; | ||
} |
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,3 @@ | ||
EXPORTS | ||
|
||
libfunc2 @2 |
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,4 @@ | ||
int libfunc3(void) | ||
{ | ||
return 3; | ||
} |
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,3 @@ | ||
EXPORTS | ||
|
||
libfunc3 @3 |
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,4 @@ | ||
int libfunc4(void) | ||
{ | ||
return 4; | ||
} |
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,9 @@ | ||
int libfunc1(void); | ||
int libfunc2(void); | ||
int libfunc3(void); | ||
int libfunc4(void); | ||
|
||
int main(void) | ||
{ | ||
return libfunc1() + libfunc2() + libfunc3() + libfunc4() == 10 ? 0 : 1; | ||
} |
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,37 @@ | ||
project( | ||
'as_static', | ||
['c'], | ||
meson_version: '>= 1.3.0', | ||
) | ||
|
||
lib1 = library('lib1', 'lib1.c', vs_module_defs: 'lib1.def') | ||
dep1 = declare_dependency(link_with: lib1) | ||
|
||
lib2 = both_libraries('lib2', 'lib2.c', vs_module_defs: 'lib2.def') | ||
dep2 = declare_dependency(link_with: lib2) | ||
dep2_static = declare_dependency(link_with: lib2, prefer_static: true) | ||
dep2_shared = declare_dependency(link_with: lib2, prefer_static: false) | ||
|
||
lib3 = shared_library('lib3', 'lib3.c', vs_module_defs: 'lib3.def') | ||
dep3 = declare_dependency(link_with: lib3) | ||
|
||
lib4 = static_library('lib4', 'lib4.c') | ||
dep4 = declare_dependency(link_with: lib4) | ||
|
||
|
||
dep_default = declare_dependency(dependencies: [dep1, dep2, dep3, dep4]) | ||
main_default = executable('main_default', 'main.c', dependencies: [dep_default]) | ||
test('default', main_default) | ||
|
||
dep_static = declare_dependency(dependencies: [dep1, dep2, dep3, dep4]).as_static(recursive: true) | ||
main_static = executable('main_static', 'main.c', dependencies: [dep_static]) | ||
test('static', main_static) | ||
|
||
dep_shared = declare_dependency(dependencies: [dep1, dep2, dep3, dep4]).as_shared(recursive: true) | ||
main_shared = executable('main_shared', 'main.c', dependencies: [dep_shared]) | ||
test('shared', main_shared) | ||
|
||
|
||
# FIXME: this doesn't really test that expected lib versions are linked, | ||
# but I don't know how I could test this... | ||
# Maybe should I write a unit test for that? |
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,15 @@ | ||
{ | ||
"matrix": { | ||
"options": { | ||
"default_library": [ | ||
{ "val": "shared" }, | ||
{ "val": "static" }, | ||
{ "val": "both" } | ||
], | ||
"prefer_static": [ | ||
{ "val": true }, | ||
{ "val": false } | ||
] | ||
} | ||
} | ||
} |