diff options
author | Daniel Eklöf <daniel@ekloef.se> | 2019-05-09 21:43:10 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-05-09 22:43:10 +0300 |
commit | c2ee82cc418d896935d4a96651ba9fa49a53b636 (patch) | |
tree | 84e86282e6e3f7550e6c7177739b978415d499c8 | |
parent | b0f90a793f5ef3e08aa51549773581dff862ddb7 (diff) | |
download | meson-c2ee82cc418d896935d4a96651ba9fa49a53b636.tar.gz |
add support for "target_type: 'shared_module'" in build_target()
-rw-r--r-- | docs/markdown/Reference-manual.md | 14 | ||||
-rw-r--r-- | docs/markdown/snippets/target-type-shared-module.md | 16 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 4 | ||||
-rw-r--r-- | test cases/common/122 shared module/meson.build | 4 | ||||
-rw-r--r-- | test cases/common/184 bothlibraries/meson.build | 13 | ||||
-rw-r--r-- | test cases/common/4 shared/meson.build | 1 | ||||
-rw-r--r-- | test cases/common/93 default library/meson.build | 5 |
7 files changed, 56 insertions, 1 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index d86d825d4..01fa3c38d 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -158,7 +158,19 @@ library. In addition it supports the following extra methods: ### build_target() Creates a build target whose type can be set dynamically with the -`target_type` keyword argument. This declaration: +`target_type` keyword argument. + +`target_type` may be set to one of: + +- `executable` +- `shared_library` +- `shared_module` +- `static_library` +- `both_libraries` +- `library` +- `jar` + +This declaration: ```meson executable(<arguments and keyword arguments>) diff --git a/docs/markdown/snippets/target-type-shared-module.md b/docs/markdown/snippets/target-type-shared-module.md new file mode 100644 index 000000000..e9364a1e9 --- /dev/null +++ b/docs/markdown/snippets/target-type-shared-module.md @@ -0,0 +1,16 @@ +## `target_type` in `build_targets` accepts the value 'shared_module' + +The `target_type` keyword argument in `build_target()` now accepts the +value `'shared_module'`. + +The statement + +```meson +build_target(..., target_type: 'shared_module') +``` + +is equivalent to this: + +```meson +shared_module(...) +``` diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 3f9d46408..fe12a7b58 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -3116,6 +3116,10 @@ external dependencies (including libraries) must go to "dependencies".''') return self.build_target(node, args, kwargs, ExecutableHolder) elif target_type == 'shared_library': return self.build_target(node, args, kwargs, SharedLibraryHolder) + elif target_type == 'shared_module': + FeatureNew('build_target(target_type: \'shared_module\')', + '0.51.0').use(self.subproject) + return self.build_target(node, args, kwargs, SharedModuleHolder) elif target_type == 'static_library': return self.build_target(node, args, kwargs, StaticLibraryHolder) elif target_type == 'both_libraries': diff --git a/test cases/common/122 shared module/meson.build b/test cases/common/122 shared module/meson.build index 3d5230046..5d7fed9a5 100644 --- a/test cases/common/122 shared module/meson.build +++ b/test cases/common/122 shared module/meson.build @@ -12,6 +12,10 @@ e = executable('prog', 'prog.c', link_with : l, export_dynamic : true, dependencies : dl) test('import test', e, args : m) +# Same as above, but module created with build_target() +m2 = build_target('mymodule2', 'module.c', target_type: 'shared_module') +test('import test 2', e, args : m2) + # Shared module that does not export any symbols shared_module('nosyms', 'nosyms.c', install : true, diff --git a/test cases/common/184 bothlibraries/meson.build b/test cases/common/184 bothlibraries/meson.build index 3a13d6259..0bfba76ed 100644 --- a/test cases/common/184 bothlibraries/meson.build +++ b/test cases/common/184 bothlibraries/meson.build @@ -10,3 +10,16 @@ exe_both = executable('prog-both', 'main.c', link_with : both_libs) test('runtest-shared', exe_shared) test('runtest-static', exe_static) test('runtest-both', exe_both) + +# Same as above, but using build_target() +both_libs2 = build_target('mylib2', 'libfile.c', target_type: 'both_libraries') +exe_shared2 = executable('prog-shared2', 'main.c', + link_with : both_libs2.get_shared_lib()) +exe_static2 = executable('prog-static2', 'main.c', + c_args : ['-DSTATIC_COMPILATION'], + link_with : both_libs2.get_static_lib()) +exe_both2 = executable('prog-both2', 'main.c', link_with : both_libs2) + +test('runtest-shared-2', exe_shared2) +test('runtest-static-2', exe_static2) +test('runtest-both-2', exe_both2) diff --git a/test cases/common/4 shared/meson.build b/test cases/common/4 shared/meson.build index a148272f2..b2c8fa34d 100644 --- a/test cases/common/4 shared/meson.build +++ b/test cases/common/4 shared/meson.build @@ -1,2 +1,3 @@ project('shared library test', 'c') lib = shared_library('mylib', 'libfile.c') +build_target('mylib2', 'libfile.c', target_type: 'shared_library') diff --git a/test cases/common/93 default library/meson.build b/test cases/common/93 default library/meson.build index 903cfe40a..508f25f5b 100644 --- a/test cases/common/93 default library/meson.build +++ b/test cases/common/93 default library/meson.build @@ -3,3 +3,8 @@ project('default library', 'cpp') flib = library('ef', 'ef.cpp') exe = executable('eftest', 'eftest.cpp', link_with : flib) test('eftest', exe) + +# Same as above, but using build_target() +flib2 = build_target('ef2', 'ef.cpp', target_type: 'library') +exe2 = executable('eftest2', 'eftest.cpp', link_with : flib2) +test('eftest2', exe2) |