Search for static dependencies/libraries when static_runtime is set (#473)

Do not search for static windows-specific libraries, they will be
handled by /MT.
This commit is contained in:
Riccardo Schirone
2021-01-29 16:54:18 +08:00
committed by GitHub
parent 0ebcd523e3
commit 11ed71244c
6 changed files with 31 additions and 24 deletions
+1 -1
View File
@@ -82,7 +82,7 @@ if host_machine.system() == 'darwin'
endif
if ['netbsd', 'openbsd', 'freebsd', 'dragonfly'].contains(host_machine.system())
rz_debug_deps += cc.find_library('kvm', required: true)
rz_debug_deps += cc.find_library('kvm', required: true, static: is_static_build)
rz_debug_sources += [
'p/native/bsd/bsd_debug.c',
]
+1 -1
View File
@@ -89,7 +89,7 @@ rz_util_sources = [
rz_util_deps = [ldl, lrt, mth, spp_dep, pth, utl, sdb_dep, zlib_dep, platform_deps]
if host_machine.system().startswith('freebsd') or host_machine.system().startswith('netbsd') or host_machine.system().startswith('haiku')
# backtrace_symbols_fd requires -lexecinfo
rz_util_deps += [cc.find_library('execinfo')]
rz_util_deps += [cc.find_library('execinfo', static: is_static_build)]
endif
if use_sys_openssl
+23 -16
View File
@@ -13,6 +13,11 @@ create_tags_rz_py = files('sys/create_tags_rz.py')
syscall_preprocessing_py = files('sys/syscall_preprocessing.py')
git_exe_repo_py = files('sys/meson_git_wrapper.py')
is_static_build = get_option('static_runtime')
if is_static_build and get_option('default_library') != 'static'
error('Cannot use `static_runtime` when libraries are dynamically built. Set `--default-library=true` if you want to build statically.')
endif
# Get rizin version and compute various version parts
rizin_version = meson.project_version().split('v')[1]
if host_machine.system() == 'darwin'
@@ -84,27 +89,29 @@ message('rizin lib version: ' + rizin_libversion)
# system dependencies
cc = meson.get_compiler('c')
# required for linux
ldl = cc.find_library('dl', required: false)
pth = dependency('threads', required: false)
utl = cc.find_library('util', required: false)
ldl = cc.find_library('dl', required: false, static: is_static_build)
pth = dependency('threads', required: false, static: is_static_build)
utl = cc.find_library('util', required: false, static: is_static_build)
if host_machine.system() == 'sunos'
# workaround for Solaris until https://github.com/mesonbuild/meson/issues/4328 is fixed
mth = declare_dependency(link_args: '-lm')
else
mth = cc.find_library('m', required: false)
mth = cc.find_library('m', required: false, static: is_static_build)
endif
platform_deps = []
platform_inc = ['.', 'librz/include']
if host_machine.system() == 'windows'
platform_deps = [cc.find_library('ws2_32'), cc.find_library('wininet'), cc.find_library('psapi')]
platform_deps = [
cc.find_library('ws2_32'),
cc.find_library('wininet'),
cc.find_library('psapi'),
]
endif
platform_inc = include_directories(platform_inc)
if get_option('static_runtime')
if cc.get_id() == 'msvc'
add_project_arguments('/MT', language: 'c')
endif
if is_static_build and cc.get_id() == 'msvc'
add_project_arguments('/MT', language: 'c')
endif
if cc.has_argument('--std=gnu99')
@@ -203,7 +210,7 @@ config_h = configure_file(
)
# handle magic library
sys_magic = cc.find_library('magic', required: false)
sys_magic = cc.find_library('magic', required: false, static: is_static_build)
use_syslib_magic = false
if sys_magic.found() and get_option('use_sys_magic')
@@ -211,20 +218,20 @@ if sys_magic.found() and get_option('use_sys_magic')
endif
# handle xxhash library
sys_xxhash = dependency('xxhash', required: false)
sys_xxhash = dependency('xxhash', required: false, static: is_static_build)
use_sys_xxhash = false
if not sys_xxhash.found()
sys_xxhash = cc.find_library('xxhash', required: false)
sys_xxhash = cc.find_library('xxhash', required: false, static: is_static_build)
endif
use_sys_xxhash = sys_xxhash.found() and get_option('use_sys_xxhash')
# handle openssl library
sys_openssl = dependency('openssl', required: false)
sys_openssl = dependency('openssl', required: false, static: is_static_build)
use_sys_openssl = sys_openssl.found() and get_option('use_sys_openssl')
# handle libuv library
if get_option('use_libuv')
libuv_dep = dependency('libuv', version: '>=1.0.0', required: false, static: get_option('default_library') == 'static')
libuv_dep = dependency('libuv', version: '>=1.0.0', required: false, static: is_static_build)
use_libuv = libuv_dep.found()
if not libuv_dep.found()
warning('use_libuv option was set to true, but libuv was not found.')
@@ -299,7 +306,7 @@ endif
lrt = []
if not cc.has_function('clock_gettime', prefix: '#include <time.h>') and cc.has_header_symbol('features.h', '__GLIBC__')
lrt = cc.find_library('rt', required: true)
lrt = cc.find_library('rt', required: true, static: is_static_build)
endif
foreach item : [
@@ -378,7 +385,7 @@ libr_pc = configure_file(
)
# handle zlib dependency
zlib_dep = dependency('zlib', required: false)
zlib_dep = dependency('zlib', required: false, static: is_static_build)
if not zlib_dep.found() or not get_option('use_sys_zlib')
zlib_files = [
'shlr/zip/zlib/adler32.c',
+1 -1
View File
@@ -1,7 +1,7 @@
option('packager', type: 'string', value: '', description: 'Extra packager name')
option('packager_version', type: 'string', value: '', description: 'Extra packager version')
option('cli', type: 'feature', value: 'auto', description: 'Build CLI programs (“auto” means they will be built when not a subproject)')
option('static_runtime', type: 'boolean', value: false)
option('static_runtime', type: 'boolean', value: false, description: 'Set to true when building a static version of Rizin')
option('local', type: 'feature', value: 'auto', description: 'Adds support for local/side-by-side installation (sets rpath if needed)')
option('blob', type: 'boolean', value: false, description: 'Compile just one binary which dispatch to the right handlers based on the name used to call it')
+4 -4
View File
@@ -1,5 +1,5 @@
# handle capstone dependency
capstone_dep = dependency('capstone', version: '>=3.0.4', required: false)
capstone_dep = dependency('capstone', version: '>=3.0.4', required: false, static: is_static_build)
if not capstone_dep.found() or not get_option('use_sys_capstone')
if get_option('capstone_in_builddir')
capstone_path = join_paths(meson.current_build_dir(), 'capstone')
@@ -183,7 +183,7 @@ elif cc.has_argument('-std=c99')
tree_sitter_cflags = '-std=c99'
endif
tree_sitter_dep = dependency('tree-sitter', required: false)
tree_sitter_dep = dependency('tree-sitter', required: false, static: is_static_build)
if not tree_sitter_dep.found() or not get_option('use_sys_tree_sitter')
message('Use bundled tree-sitter')
tree_sitter_path = 'tree-sitter'
@@ -317,7 +317,7 @@ tcc_dep = declare_dependency(
# handle lz4 dependency
lz4_dep = dependency('liblz4', required: false)
lz4_dep = dependency('liblz4', required: false, static: is_static_build)
if not lz4_dep.found() or not get_option('use_sys_lz4')
message('Use bundled lz4')
lz4_files = [
@@ -341,7 +341,7 @@ endif
# handle zip dependency
zip_dep = dependency('libzip', required: false)
zip_dep = dependency('libzip', required: false, static: is_static_build)
if not zip_dep.found() or not get_option('use_sys_zip')
message('Use bundled zip')
+1 -1
View File
@@ -1,7 +1,7 @@
# project('ptrace-wrap', 'c')
thread_dep = dependency('threads')
thread_dep = dependency('threads', static: is_static_build)
ptrace_wrap_inc = include_directories('include')