tests: both_library test improvements
This switches some `shared_library()` calls to `library()` and adds one new CI matrix entries for -Ddefault_library={static, both}.
This commit is contained in:
parent
0c4dd81c4d
commit
c4b8e03895
|
@ -52,7 +52,11 @@ jobs:
|
|||
cfg:
|
||||
- CC: 'gcc'
|
||||
CXX: 'g++'
|
||||
- MESON_ARGS: '--unity=on'
|
||||
- MESON_ARGS: '--unity=on -Ddefault_library=static'
|
||||
RUN_TESTS_ARGS: '--no-unittests'
|
||||
CC: 'gcc'
|
||||
CXX: 'g++'
|
||||
- MESON_ARGS: '-Ddefault_library=both'
|
||||
RUN_TESTS_ARGS: '--no-unittests'
|
||||
CC: 'gcc'
|
||||
CXX: 'g++'
|
||||
|
|
|
@ -12,7 +12,7 @@ if meson.backend() == 'xcode'
|
|||
error('MESON_SKIP_TEST, Xcode can not extract objs when they would have the same filename.')
|
||||
endif
|
||||
|
||||
lib = shared_library('somelib', ['lib.c', 'src/lib.c'])
|
||||
lib = library('somelib', ['lib.c', 'src/lib.c'])
|
||||
# Also tests that the object list is flattened properly
|
||||
obj = lib.extract_objects(['lib.c', ['src/lib.c']])
|
||||
exe = executable('main', 'main.c', objects: obj)
|
||||
|
|
|
@ -14,7 +14,7 @@ copygen = generator(copy,
|
|||
arguments : ['@INPUT@', '@OUTPUT@'],
|
||||
output : '@BASENAME@')
|
||||
|
||||
l = shared_library('square-gen', copygen.process('square.ll.in'))
|
||||
l = library('square-gen', copygen.process('square.ll.in'))
|
||||
|
||||
test('square-gen-test', executable('square-gen-test', 'main.c', link_with : l))
|
||||
|
||||
|
@ -23,6 +23,6 @@ copyct = custom_target('square',
|
|||
output : 'square.ll',
|
||||
command : [copy, '@INPUT@', '@OUTPUT@'])
|
||||
|
||||
l = shared_library('square-ct', copyct)
|
||||
l = library('square-ct', copyct)
|
||||
|
||||
test('square-ct-test', executable('square-ct-test', 'main.c', link_with : l))
|
||||
|
|
|
@ -50,7 +50,7 @@ copygen = generator(copy,
|
|||
arguments : ['@INPUT@', '@OUTPUT@'],
|
||||
output : '@BASENAME@')
|
||||
|
||||
l = shared_library('square-gen', crt_workaround + [copygen.process(input)],
|
||||
l = library('square-gen', crt_workaround + [copygen.process(input)],
|
||||
vs_module_defs: 'square.def')
|
||||
|
||||
test('square-gen-test', executable('square-gen-test', 'main.c', link_with : l))
|
||||
|
@ -60,7 +60,7 @@ copyct = custom_target('square',
|
|||
output : output,
|
||||
command : [copy, '@INPUT@', '@OUTPUT@'])
|
||||
|
||||
l = shared_library('square-ct', crt_workaround + [copyct],
|
||||
l = library('square-ct', crt_workaround + [copyct],
|
||||
vs_module_defs: 'square.def')
|
||||
|
||||
test('square-ct-test', executable('square-ct-test', 'main.c', link_with : l))
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
project('lib@root', 'c')
|
||||
lib = shared_library('lib', 'lib.c')
|
||||
lib = library('lib', 'lib.c')
|
||||
subdir('main')
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
project('shared lib', 'c')
|
||||
shared_library('foo', 'foo.c')
|
||||
library('foo', 'foo.c')
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
project('B', 'c')
|
||||
C = subproject('C')
|
||||
c = C.get_variable('c')
|
||||
b = shared_library('b', 'b.c', link_with : c)
|
||||
b = library('b', 'b.c', link_with : c)
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
project('C', 'c')
|
||||
c = shared_library('c', 'c.c')
|
||||
c = library('c', 'c.c')
|
||||
|
|
|
@ -1 +1 @@
|
|||
other = shared_library('other', 'custom_subproject_dir/other.c')
|
||||
other = library('other', 'custom_subproject_dir/other.c')
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
project('alpha project', 'c', subproject_dir: 'var/subprojects')
|
||||
|
||||
b = subproject('beta')
|
||||
l = shared_library('a', 'a.c', link_with : b.get_variable('lb'))
|
||||
l = library('a', 'a.c', link_with : b.get_variable('lb'))
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
if __name__ == '__main__':
|
||||
Path(sys.argv[1]).write_text('Hello World\n')
|
||||
raise SystemExit(0)
|
|
@ -1,15 +1,29 @@
|
|||
project('both libraries linking test', 'c')
|
||||
|
||||
both_libs = both_libraries('mylib', 'libfile.c')
|
||||
dep = declare_dependency(link_with: both_libs)
|
||||
exe_shared = executable('prog-shared', 'main.c', link_with : both_libs.get_shared_lib())
|
||||
exe_static = executable('prog-static', 'main.c',
|
||||
c_args : ['-DSTATIC_COMPILATION'],
|
||||
link_with : both_libs.get_static_lib())
|
||||
exe_both = executable('prog-both', 'main.c', link_with : both_libs)
|
||||
exe_dep = executable('prog-dep', 'main.c', dependencies : [dep])
|
||||
|
||||
# Try using it in a custom_target
|
||||
custom_target('tgt_a',
|
||||
command: [
|
||||
find_program('./dummy.py'),
|
||||
'@OUTPUT@',
|
||||
both_libs,
|
||||
],
|
||||
output: ['hello1.txt'],
|
||||
input: [both_libs],
|
||||
)
|
||||
|
||||
test('runtest-shared', exe_shared)
|
||||
test('runtest-static', exe_static)
|
||||
test('runtest-both', exe_both)
|
||||
test('runtest-dep', exe_dep)
|
||||
|
||||
# Same as above, but using build_target()
|
||||
both_libs2 = build_target('mylib2', 'libfile.c', target_type: 'both_libraries')
|
||||
|
|
|
@ -3,8 +3,8 @@ project('object extraction', 'c')
|
|||
if meson.is_unity()
|
||||
message('Skipping extraction test because this is a Unity build.')
|
||||
else
|
||||
lib1 = shared_library('somelib', 'src/lib.c')
|
||||
lib2 = shared_library('somelib2', 'lib.c', 'header.h', 'lib2.c')
|
||||
lib1 = library('somelib', 'src/lib.c')
|
||||
lib2 = library('somelib2', 'lib.c', 'header.h', 'lib2.c')
|
||||
|
||||
obj1 = lib1.extract_objects('src/lib.c')
|
||||
obj2 = lib2.extract_objects(['lib.c'])
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
project('persubproject options', 'c',
|
||||
default_options : ['default_library=both',
|
||||
'werror=true',
|
||||
default_options : ['werror=true',
|
||||
'warning_level=3'])
|
||||
|
||||
assert(get_option('default_library') == 'both', 'Parent default_library should be "both"')
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"matrix": {
|
||||
"options": {
|
||||
"default_library": [ { "val": "both" } ]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
project('B', 'c')
|
||||
C = subproject('C')
|
||||
c = C.get_variable('c')
|
||||
b = shared_library('b', 'b.c', link_with : c)
|
||||
b = library('b', 'b.c', link_with : c)
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
project('C', 'c')
|
||||
c = shared_library('c', 'c.c')
|
||||
c = library('c', 'c.c')
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
project('B', 'c')
|
||||
C = subproject('C')
|
||||
c = C.get_variable('c')
|
||||
b = shared_library('b', 'b.c', link_with : c)
|
||||
b = library('b', 'b.c', link_with : c)
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
project('C', 'c')
|
||||
c = shared_library('c', 'c.c')
|
||||
c = library('c', 'c.c')
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
project('extract subproject object -- subproject', 'c')
|
||||
|
||||
lib = shared_library('sub_lib', 'sub_lib.c')
|
||||
lib = library('sub_lib', 'sub_lib.c')
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# - Is an install:true static library to trigger certain codepath (promotion to link_whole)
|
||||
# - Does fortran code 'generation' with configure_file
|
||||
# - Uses .F90 ext (capital F typically denotes a dependence on preprocessor treatment, which however is not used)
|
||||
project('try-static-subproject-dependency', 'fortran', default_options: ['default_library=static'])
|
||||
project('try-static-subproject-dependency', 'fortran')
|
||||
|
||||
static_dep = dependency('static_hello', fallback: ['static_hello', 'static_hello_dep'])
|
||||
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
{
|
||||
"installed": [
|
||||
{"file": "usr/lib/libmainstatic.a", "type": "file"}
|
||||
]
|
||||
}
|
||||
],
|
||||
"matrix": {
|
||||
"options": {
|
||||
"default_library": [ { "val": "static" } ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ endif
|
|||
|
||||
gobject = dependency('gobject-2.0')
|
||||
|
||||
libfoo = library('foo', 'foo.c',
|
||||
libfoo = shared_library('foo', 'foo.c',
|
||||
include_directories: inc,
|
||||
dependencies: gobject,
|
||||
)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Define version only in project, should get inherited by declare_dependency
|
||||
project('some', 'c', version : '0.1')
|
||||
|
||||
somelib = shared_library('some', 'lib.c')
|
||||
somelib = library('some', 'lib.c')
|
||||
someinc = include_directories('.')
|
||||
|
||||
some_dep = declare_dependency(link_with : somelib,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
project('some', 'c')
|
||||
|
||||
somelib = shared_library('some', 'lib.c')
|
||||
somelib = library('some', 'lib.c')
|
||||
someinc = include_directories('.')
|
||||
|
||||
# Define version only in declare_dependency
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
project('some', 'c')
|
||||
|
||||
somelib = shared_library('some', 'lib.c')
|
||||
somelib = library('some', 'lib.c')
|
||||
someinc = include_directories('.')
|
||||
|
||||
# Define version only in declare_dependency
|
||||
|
|
|
@ -4,6 +4,6 @@ if host_machine.system() == 'darwin'
|
|||
error('MESON_SKIP_TEST: doesnt work right on macos, please fix!')
|
||||
endif
|
||||
|
||||
l = library('stuff', 'stuff.rs', rust_crate_type: 'cdylib', install : true)
|
||||
l = shared_library('stuff', 'stuff.rs', rust_crate_type: 'cdylib', install : true)
|
||||
e = executable('prog', 'prog.c', link_with : l, install : true)
|
||||
test('polyglottest', e)
|
||||
|
|
Loading…
Reference in New Issue