parent
faf3581df6
commit
dd2c44cdf6
12 changed files with 93 additions and 30 deletions
@ -0,0 +1,6 @@ |
||||
## Add keyword `static` to `find_library` |
||||
|
||||
`find_library` has learned the `static` keyword. They keyword must be a boolean, |
||||
where `true` only searches for static libraries and `false` only searches for |
||||
dynamic/shared. Leaving the keyword unset will keep the old behavior of first |
||||
searching for dynamic and then falling back to static. |
@ -0,0 +1,7 @@ |
||||
#include "stdio.h" |
||||
#include "zlib.h" |
||||
|
||||
int main() { |
||||
printf("%s\n", zlibVersion()); |
||||
return 0; |
||||
} |
@ -0,0 +1,20 @@ |
||||
project('static dynamic', 'c') |
||||
|
||||
|
||||
cc = meson.get_compiler('c') |
||||
|
||||
z_default = cc.find_library('z') |
||||
z_static = cc.find_library('z', static: true) |
||||
z_dynamic = cc.find_library('z', static: false) |
||||
|
||||
exe_default = executable('main_default', 'main.c', dependencies: [z_default]) |
||||
exe_static = executable('main_static', 'main.c', dependencies: [z_static]) |
||||
exe_dynamic = executable('main_dynamic', 'main.c', dependencies: [z_dynamic]) |
||||
|
||||
test('test default', exe_default) |
||||
test('test static', exe_static) |
||||
test('test dynamic', exe_dynamic) |
||||
|
||||
test('verify static linking', find_program('verify_static.py'), args:exe_static.full_path()) |
||||
test('verify dynamic linking', find_program('verify_static.py'), args:exe_dynamic.full_path(), |
||||
should_fail: true) |
@ -0,0 +1,16 @@ |
||||
#!/usr/bin/env python |
||||
"""Test script that checks if zlib was statically linked to executable""" |
||||
import subprocess |
||||
import sys |
||||
|
||||
def main(): |
||||
"""Main function""" |
||||
output = subprocess.check_output(['nm', sys.argv[1]]).decode('utf-8') |
||||
|
||||
if 'T zlibVersion' in output: |
||||
sys.exit(0) |
||||
|
||||
sys.exit(1) |
||||
|
||||
if __name__ == '__main__': |
||||
main() |
Loading…
Reference in new issue