Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rizin as subproject #4679

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions librz/include/rz_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
#include <inttypes.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

// TODO: fix this to make it crosscompile-friendly: RZ_SYS_OSTYPE ?
/* operating system */
#undef __BSD__
Expand Down Expand Up @@ -664,4 +668,8 @@ typedef int RzRef;

typedef struct rz_core_t RzCore;

#ifdef __cplusplus
}
#endif

#endif // RZ_TYPES_H
8 changes: 8 additions & 0 deletions librz/include/rz_util/rz_intervaltree.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include "rz_rbtree.h"
#include "../rz_types.h"

#ifdef __cplusplus
extern "C" {
#endif

/*
* RzIntervalTree is a special RBTree (augmented red-black tree)
* that holds its entries, each associated with a interval,
Expand Down Expand Up @@ -98,4 +102,8 @@ static inline bool rz_interval_tree_empty(RzIntervalTree *tree) {
#define rz_interval_tree_foreach_prev(tree, it, dat) \
for ((it) = rz_rbtree_last(&(tree)->root->node); rz_rbtree_iter_has(&it) && (dat = rz_rbtree_iter_get(&it, RzIntervalNode, node)->data); rz_rbtree_iter_prev(&(it)))

#ifdef __cplusplus
}
#endif

#endif // RZ_INTERVALTREE_H
34 changes: 19 additions & 15 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project('rizin', 'c',
version: 'v0.6.0',
license: 'LGPL3',
license: 'LGPL-3.0-only',
meson_version: '>=0.55.0',
default_options: [
'buildtype=debugoptimized',
Expand Down Expand Up @@ -80,14 +80,18 @@ if is_static_build
endif

if cc.has_argument('--std=gnu99')
add_global_arguments('--std=gnu99', language: ['c', 'cpp'])
add_project_arguments('--std=gnu99', language: ['c', 'cpp'])
lang_opt = ['c_std=gnu99']
elif cc.has_argument('--std=c99')
add_global_arguments('--std=c99', language: ['c', 'cpp'])
add_project_arguments('--std=c99', language: ['c', 'cpp'])
lang_opt = ['c_std=c99']
else
lang_opt = []
endif

# Sanitize correct usage of rz_strf()
if cc.has_argument('-Werror=sizeof-pointer-memaccess')
add_global_arguments('-Werror=sizeof-pointer-memaccess', language: ['c', 'cpp'])
add_project_arguments('-Werror=sizeof-pointer-memaccess', language: ['c', 'cpp'])
endif

if cc.has_argument('-Wimplicit-fallthrough=3')
Expand All @@ -106,17 +110,17 @@ endif

if get_option('default_library') == 'shared'
if cc.has_argument('-fvisibility=hidden')
add_global_arguments('-fvisibility=hidden', language: 'c')
add_project_arguments('-fvisibility=hidden', language: 'c')
endif
endif

add_project_arguments(['-DRZ_PLUGIN_INCORE=1'], language: 'c')
b_sanitize_opt = get_option('b_sanitize')
if (b_sanitize_opt.contains('address') or b_sanitize_opt.contains('undefined')) and cc.get_id() == 'clang'
add_global_arguments('-shared-libasan', language: 'c')
add_global_link_arguments('-shared-libasan', language: 'c')
add_global_arguments('-shared-libasan', language: 'c', native: true)
add_global_link_arguments('-shared-libasan', language: 'c', native: true)
add_project_arguments('-shared-libasan', language: 'c')
add_project_link_arguments('-shared-libasan', language: 'c')
add_project_arguments('-shared-libasan', language: 'c', native: true)
add_project_link_arguments('-shared-libasan', language: 'c', native: true)
endif

fs = import('fs')
Expand Down Expand Up @@ -173,15 +177,15 @@ endforeach
cmake_package_relative_path = run_command(py3_exe, cmake_package_prefix_dir_py, rizin_prefix, rizin_cmakedir / 'xxx', check: true).stdout().strip()

# handle capstone dependency
capstone_dep = dependency('capstone', version: '>=3.0.4', required: get_option('use_sys_capstone'), static: is_static_build)
capstone_dep = dependency('capstone', version: '>=3.0.4', required: get_option('use_sys_capstone'), static: is_static_build, default_options: lang_opt)
if not capstone_dep.found()
capstone_version = get_option('use_capstone_version')
if fs.is_file('subprojects/capstone-' + capstone_version + '.wrap')
r = run_command(py3_exe, check_meson_subproject_py, 'capstone-' + capstone_version, check: false)
if r.returncode() == 1 and get_option('subprojects_check')
error('Subprojects are not updated. Please run `git clean -dxff subprojects/` to delete all local subprojects directories. If you want to compile against current subprojects then set option `subprojects_check=false`.')
endif
capstone_proj = subproject('capstone-' + capstone_version, default_options: ['default_library=static'])
capstone_proj = subproject('capstone-' + capstone_version, default_options: ['default_library=static'] + lang_opt)
else
error('Wrong capstone version selected. Please use one of the supported versions.')
endif
Expand Down Expand Up @@ -313,7 +317,7 @@ foreach it : ccs
have_pthread = it_th.found() and it_machine.system() != 'windows'
if it_machine.system() == 'sunos'
# workaround for Solaris until https://github.com/mesonbuild/meson/issues/4328 is fixed
it_mth = declare_dependency(link_args: '-lm', native: it_native)
it_mth = declare_dependency(link_args: '-lm')
else
it_mth = it_cc.find_library('m', required: false, static: is_static_build)
endif
Expand Down Expand Up @@ -508,7 +512,7 @@ if git_exe.found() and fs.exists('.git')
build_always_stale: true,
build_by_default: true,
output: 'gittip',
command: [py3_exe, git_exe_repo_py, git_exe, repo, 'rev-parse', 'HEAD'],
command: [py3_exe, git_exe_repo_py, git_exe, repo, '@OUTPUT@', 'rev-parse', 'HEAD'],
install: true,
install_dir: rizin_datdir_rz
)
Expand Down Expand Up @@ -564,13 +568,13 @@ if r.returncode() == 1 and get_option('subprojects_check')
error('Subprojects are not updated. Please run `git clean -dxff subprojects/` to delete all local subprojects directories. If you want to compile against current subprojects then set option `subprojects_check=false`.')
endif

libzip_dep = dependency('libzip', required: get_option('use_sys_libzip'), static: is_static_build)
libzip_dep = dependency('libzip', required: get_option('use_sys_libzip'), static: is_static_build, default_options: lang_opt)
if not libzip_dep.found()
libzip_proj = subproject('libzip', default_options: [
'default_library=static',
'static_runtime=@0@'.format(is_static_build),
'use_sys_openssl=@0@'.format(get_option('use_sys_libzip_openssl')),
])
] + lang_opt)
libzip_dep = libzip_proj.get_variable('libzip_dep')
endif

Expand Down
2 changes: 1 addition & 1 deletion subprojects/nettle/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project('nettle', 'c',
license: [ 'LGPL'],
license: 'LGPL',
version: '3.7.3'
)
# https://git.lysator.liu.se/nettle/nettle
Expand Down
9 changes: 8 additions & 1 deletion subprojects/packagefiles/blake3/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
project('blake3', 'c', version: '1.3.1', license : ['CC0-1.0'], meson_version: '>=0.55.0')
project('blake3', 'c',
version: '1.3.1',
license: 'CC0-1.0',
meson_version: '>=0.55.0',
default_options: [
'c_std=c99',
]
)

cc = meson.get_compiler('c')

Expand Down
8 changes: 7 additions & 1 deletion subprojects/packagefiles/capstone-3.0.5/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
project('capstone', 'c', version: '3.0.5', meson_version: '>=0.55.0')
project('capstone', 'c',
version: '3.0.5',
meson_version: '>=0.55.0',
default_options: [
'c_std=c99',
]
)

cs_files = [
'arch/AArch64/AArch64BaseInfo.c',
Expand Down
8 changes: 7 additions & 1 deletion subprojects/packagefiles/capstone-4.0.2/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
project('capstone', 'c', version: '4.0.2', meson_version: '>=0.55.0')
project('capstone', 'c',
version: '4.0.2',
meson_version: '>=0.55.0',
default_options: [
'c_std=c99',
]
)

cs_files = [
'arch/AArch64/AArch64BaseInfo.c',
Expand Down
8 changes: 7 additions & 1 deletion subprojects/packagefiles/capstone-5.0-post1/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
project('capstone', 'c', version: '5.0-post1', meson_version: '>=0.55.0')
project('capstone', 'c',
version: '5.0-post1',
meson_version: '>=0.55.0',
default_options: [
'c_std=c99',
]
)

cs_files = [
'arch/AArch64/AArch64BaseInfo.c',
Expand Down
8 changes: 7 additions & 1 deletion subprojects/packagefiles/capstone-next/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
project('capstone', 'c', version: 'next', meson_version: '>=0.55.0')
project('capstone', 'c',
version: 'next',
meson_version: '>=0.55.0',
default_options: [
'c_std=c99',
]
)

cs_files = [
'arch/AArch64/AArch64BaseInfo.c',
Expand Down
9 changes: 8 additions & 1 deletion subprojects/packagefiles/libmspack/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
project('libmspack', 'c', version: '0.10.1alpha', license : ['LGPL2'], meson_version: '>=0.55.0')
project('libmspack', 'c',
version: '0.10.1alpha',
license : 'LGPL2',
meson_version: '>=0.55.0',
default_options: [
'c_std=c99',
]
)

cc = meson.get_compiler('c')

Expand Down
8 changes: 7 additions & 1 deletion subprojects/packagefiles/libzip-1.9.2/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
project('libzip', 'c',
version: '1.9.2')
version: '1.9.2',
license: 'BSD-3-clause',
meson_version: '>=0.55.0',
default_options: [
'c_std=c99',
]
)

py3_exe = import('python').find_installation()
cc = meson.get_compiler('c')
Expand Down
8 changes: 6 additions & 2 deletions subprojects/packagefiles/lz4-1.9.4/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
project('lz4', ['c'],
license: ['BSD', 'GPLv2'],
license: 'BSD-2-Clause-Patent AND GPL-2.0-or-later',
version: '1.9.4',
meson_version: '>=0.47.0')
meson_version: '>=0.55.0',
default_options: [
'c_std=c99',
]
)

lz4_files = [
'lib/lz4.c',
Expand Down
8 changes: 7 additions & 1 deletion subprojects/packagefiles/tree-sitter-0.20.7/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
project('tree-sitter', 'c')
project('tree-sitter', 'c',
license: 'MIT',
meson_version: '>=0.55.0',
default_options: [
'c_std=c99',
]
)

cc = meson.get_compiler('c')

Expand Down
9 changes: 8 additions & 1 deletion subprojects/packagefiles/tree-sitter-c/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
project('tree-sitter-c', 'c', default_options: ['werror=false'])
project('tree-sitter-c', 'c',
license: 'MIT',
meson_version: '>=0.55.0',
default_options: [
'c_std=c99',
'werror=false'
]
)

ts_c_files = [
'src/parser.c'
Expand Down
7 changes: 6 additions & 1 deletion subprojects/packagefiles/xz-5.4.3/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# liblzma is what upstream uses for their pkg-config name
project('liblzma', 'c',
version : '5.4.3',
license : 'pd/lgpl2/gpl2/gpl3',)
license : ['PD', 'LGPL2', 'GPL2', 'GPL3'],
meson_version: '>=0.55.0',
default_options: [
'c_std=c99',
]
)

cc = meson.get_compiler('c')

Expand Down
9 changes: 8 additions & 1 deletion subprojects/packagefiles/zlib-1.2.13/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
project('zlib', 'c', version : '1.2.13', license : 'zlib')
project('zlib', 'c',
version : '1.2.13',
license : 'zlib',
meson_version: '>=0.55.0',
default_options: [
'c_std=c99',
]
)

cc = meson.get_compiler('c')

Expand Down
6 changes: 5 additions & 1 deletion subprojects/rizin-shell-parser/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
project('rizin-shell-parser', 'c',
license : [ 'LGPL']
license: 'LGPL-3.0-only',
meson_version: '>=0.55.0',
default_options: [
'c_std=c99',
]
)

tree_sitter_dep = dependency('tree-sitter')
Expand Down
11 changes: 10 additions & 1 deletion subprojects/rzar/meson.build
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
project('rzar', 'c',
license : [ 'LGPL']
license: 'LGPL-3.0-only',
meson_version: '>=0.55.0',
)

# handle ar dependency
ar_files = [
'ar.c'
]

cc = meson.get_compiler('c')

if cc.has_argument('--std=gnu99')
add_project_arguments('--std=gnu99', language: ['c', 'cpp'])
elif cc.has_argument('--std=c99')
add_project_arguments('--std=c99', language: ['c', 'cpp'])
endif

rz_util_dep = dependency('rz_util')
ar_inc = [include_directories(['.'])]

Expand Down
6 changes: 5 additions & 1 deletion subprojects/rzqnx/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
project('rzqnx', 'c',
license : [ 'GPL']
license: 'GPL-2.0-only',
meson_version: '>=0.55.0',
default_options: [
'c_std=c99',
]
)

qnx_files = [
Expand Down
9 changes: 8 additions & 1 deletion subprojects/rzwinkd/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
project('rzwinkd', 'c',
license : [ 'LGPL']
license: 'LGPL-3.0-only',
meson_version: '>=0.55.0',
)

cc = meson.get_compiler('c')
Expand All @@ -12,6 +13,12 @@ winkd_files = [
'winkd.c',
]

if cc.has_argument('--std=gnu99')
add_project_arguments('--std=gnu99', language: ['c', 'cpp'])
else
add_project_arguments('--std=c99', language: ['c', 'cpp'])
endif

winkd_inc = [include_directories('.')]

rz_util_dep = dependency('rz_util')
Expand Down
13 changes: 9 additions & 4 deletions subprojects/xxhash/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
project('xxhash', 'c',
# library files are BSD licensed. xxhsum utility is GPL licensed.
license : [ 'BSD', 'GPL'],
version : '0.6.5')
# library files are BSD licensed. xxhsum utility is GPL licensed.
version : '0.6.5',
license: 'BSD-2-Clause AND GPL-2.0-or-later',
meson_version: '>=0.55.0',
default_options: [
'c_std=c99',
]
)

inc = include_directories('.')

Expand All @@ -13,4 +18,4 @@ libxxhash = library('xxhash',

xxhash_dep = declare_dependency(
include_directories : inc,
link_with : libxxhash)
link_with : libxxhash)
Loading
Loading