Skip to content

Commit 8e6b764

Browse files
authored
build: Improved meson-build to use rizin as subproject (#4684)
* Setting GNU99/C99 standard for subprojects * Remove use of `add_global_arguments` * Added extern "C" linkage specification to some public headers of rizin * Changed the meson_git_wrapper.py-script to explicitly specify the output-path * Made the RIZIN_BUILD_PATH conditional in the integration-test meson-build Co-authored-by: amibranch <[email protected]>
1 parent 86d8953 commit 8e6b764

File tree

25 files changed

+228
-46
lines changed

25 files changed

+228
-46
lines changed

librz/include/rz_types.h

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
#include <inttypes.h>
1515
#endif
1616

17+
#ifdef __cplusplus
18+
extern "C" {
19+
#endif
20+
1721
// TODO: fix this to make it crosscompile-friendly: RZ_SYS_OSTYPE ?
1822
/* operating system */
1923
#undef __BSD__
@@ -729,4 +733,8 @@ static inline void *rz_asm_plugin_data_from_rz_analysis(RZ_NONNULL void /*<RzAna
729733
return rasm->plugin_data;
730734
}
731735

736+
#ifdef __cplusplus
737+
}
738+
#endif
739+
732740
#endif // RZ_TYPES_H

librz/include/rz_util/rz_intervaltree.h

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
#include "rz_rbtree.h"
88
#include "../rz_types.h"
99

10+
#ifdef __cplusplus
11+
extern "C" {
12+
#endif
13+
1014
/*
1115
* RzIntervalTree is a special RBTree (augmented red-black tree)
1216
* that holds its entries, each associated with a interval,
@@ -100,4 +104,8 @@ static inline bool rz_interval_tree_empty(RzIntervalTree *tree) {
100104
if ((tree)->root) \
101105
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)))
102106

107+
#ifdef __cplusplus
108+
}
109+
#endif
110+
103111
#endif // RZ_INTERVALTREE_H

meson.build

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
project('rizin', 'c',
22
version: 'v0.8.0',
3-
license: 'LGPL3',
3+
license: 'LGPL-3.0-only',
44
meson_version: '>=0.57.0',
55
default_options: [
66
'buildtype=debugoptimized',
@@ -91,14 +91,14 @@ if cc.has_argument('-Wenum-compare')
9191
endif
9292

9393
if cc.has_argument('--std=gnu99')
94-
add_global_arguments('--std=gnu99', language: ['c', 'cpp'])
94+
add_project_arguments('--std=gnu99', language: ['c', 'cpp'])
9595
elif cc.has_argument('--std=c99')
96-
add_global_arguments('--std=c99', language: ['c', 'cpp'])
96+
add_project_arguments('--std=c99', language: ['c', 'cpp'])
9797
endif
9898

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

104104
if cc.has_argument('-Wimplicit-fallthrough=3')
@@ -117,17 +117,17 @@ endif
117117

118118
if get_option('default_library') == 'shared'
119119
if cc.has_argument('-fvisibility=hidden')
120-
add_global_arguments('-fvisibility=hidden', language: 'c')
120+
add_project_arguments('-fvisibility=hidden', language: 'c')
121121
endif
122122
endif
123123

124124
add_project_arguments(['-DRZ_PLUGIN_INCORE=1'], language: 'c')
125125
b_sanitize_opt = get_option('b_sanitize')
126126
if (b_sanitize_opt.contains('address') or b_sanitize_opt.contains('undefined')) and cc.get_id() == 'clang'
127-
add_global_arguments('-shared-libasan', language: 'c')
128-
add_global_link_arguments('-shared-libasan', language: 'c')
129-
add_global_arguments('-shared-libasan', language: 'c', native: true)
130-
add_global_link_arguments('-shared-libasan', language: 'c', native: true)
127+
add_project_arguments('-shared-libasan', language: 'c')
128+
add_project_link_arguments('-shared-libasan', language: 'c')
129+
add_project_arguments('-shared-libasan', language: 'c', native: true)
130+
add_project_link_arguments('-shared-libasan', language: 'c', native: true)
131131
endif
132132

133133
fs = import('fs')
@@ -366,7 +366,7 @@ foreach it : ccs
366366
have_pthread = it_th.found() and it_machine.system() != 'windows'
367367
if it_machine.system() == 'sunos'
368368
# workaround for Solaris until https://github.com/mesonbuild/meson/issues/4328 is fixed
369-
it_mth = declare_dependency(link_args: '-lm', native: it_native)
369+
it_mth = declare_dependency(link_args: '-lm')
370370
else
371371
it_mth = it_cc.find_library('m', required: false, static: is_static_build)
372372
endif
@@ -569,7 +569,7 @@ if git_exe.found() and fs.exists('.git')
569569
build_always_stale: true,
570570
build_by_default: true,
571571
output: 'gittip',
572-
command: [py3_exe, git_exe_repo_py, git_exe, repo, 'rev-parse', 'HEAD'],
572+
command: [py3_exe, git_exe_repo_py, git_exe, repo, '@OUTPUT@', 'rev-parse', 'HEAD'],
573573
install: true,
574574
install_dir: rizin_datdir_rz
575575
)

subprojects/nettle/meson.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project('nettle', 'c',
2-
license: [ 'LGPL'],
2+
license: 'LGPL',
33
version: '3.7.3'
44
)
55
# https://git.lysator.liu.se/nettle/nettle

subprojects/packagefiles/blake3/meson.build

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
project('blake3', 'c', version: '1.3.1', license : ['CC0-1.0'], meson_version: '>=0.55.0')
1+
project('blake3', 'c',
2+
version: '1.3.1',
3+
license: 'CC0-1.0',
4+
meson_version: '>=0.55.0',
5+
default_options: [
6+
'c_std=c99',
7+
]
8+
)
29

310
cc = meson.get_compiler('c')
411

subprojects/packagefiles/capstone-4.0.2/meson.build

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
project('capstone', 'c', version: '4.0.2', meson_version: '>=0.55.0')
1+
project('capstone', 'c',
2+
version: '4.0.2',
3+
meson_version: '>=0.55.0',
4+
)
5+
6+
cc = meson.get_compiler('c')
7+
8+
if cc.has_argument('--std=gnu99')
9+
add_project_arguments('--std=gnu99', language: ['c'])
10+
elif cc.has_argument('--std=c99')
11+
add_project_arguments('--std=c99', language: ['c'])
12+
endif
213

314
cs_files = [
415
'arch/AArch64/AArch64BaseInfo.c',

subprojects/packagefiles/capstone-5.0.1/meson.build

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
project('capstone', 'c', version: '5.0.1', meson_version: '>=0.55.0')
1+
project('capstone', 'c',
2+
version: '5.0.1',
3+
meson_version: '>=0.55.0',
4+
)
5+
6+
cc = meson.get_compiler('c')
7+
8+
if cc.has_argument('--std=gnu99')
9+
add_project_arguments('--std=gnu99', language: ['c'])
10+
elif cc.has_argument('--std=c99')
11+
add_project_arguments('--std=c99', language: ['c'])
12+
endif
213

314
cs_files = [
415
'arch/AArch64/AArch64BaseInfo.c',

subprojects/packagefiles/capstone-6.0.0-alpha1/meson.build

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
project('capstone', 'c', version: 'next', meson_version: '>=0.55.0')
1+
project('capstone', 'c',
2+
version: 'next',
3+
meson_version: '>=0.55.0',
4+
)
5+
6+
cc = meson.get_compiler('c')
7+
8+
if cc.has_argument('--std=gnu99')
9+
add_project_arguments('--std=gnu99', language: ['c'])
10+
elif cc.has_argument('--std=c99')
11+
add_project_arguments('--std=c99', language: ['c'])
12+
endif
213

314
cs_files = [
415
'arch/Alpha/AlphaDisassembler.c',

subprojects/packagefiles/capstone-next/meson.build

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
project('capstone', 'c', version: 'next', meson_version: '>=0.55.0')
1+
project('capstone', 'c',
2+
version: 'next',
3+
meson_version: '>=0.55.0',
4+
)
5+
6+
cc = meson.get_compiler('c')
7+
8+
if cc.has_argument('--std=gnu99')
9+
add_project_arguments('--std=gnu99', language: ['c'])
10+
elif cc.has_argument('--std=c99')
11+
add_project_arguments('--std=c99', language: ['c'])
12+
endif
213

314
cs_files = [
415
'arch/Alpha/AlphaDisassembler.c',

subprojects/packagefiles/libmspack/meson.build

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
project('libmspack', 'c', version: '0.10.1alpha', license : ['LGPL2'], meson_version: '>=0.55.0')
1+
project('libmspack', 'c',
2+
version: '0.10.1alpha',
3+
license : 'LGPL2',
4+
meson_version: '>=0.55.0',
5+
)
26

37
cc = meson.get_compiler('c')
48

9+
if cc.has_argument('--std=c99')
10+
add_project_arguments('--std=c99', language: ['c'])
11+
endif
12+
513
# handle libmspack dependency
614
libmspack_files = [
715
'libmspack' / 'mspack' / 'cabc.c',

subprojects/packagefiles/libzip-1.9.2/meson.build

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
project('libzip', 'c',
2-
version: '1.9.2')
2+
version: '1.9.2',
3+
license: 'BSD-3-clause',
4+
meson_version: '>=0.55.0',
5+
)
36

47
py3_exe = import('python').find_installation()
58
cc = meson.get_compiler('c')
69
is_static_build = get_option('static_runtime')
710

11+
if cc.has_argument('--std=gnu99')
12+
add_project_arguments('--std=gnu99', language: ['c'])
13+
elif cc.has_argument('--std=c99')
14+
add_project_arguments('--std=c99', language: ['c'])
15+
endif
16+
817
# Create config.h file
918
conf_data = configuration_data()
1019
zlib_dep = dependency('zlib', required: get_option('use_sys_zlib'), static: is_static_build)

subprojects/packagefiles/lz4-1.9.4/meson.build

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
project('lz4', ['c'],
2-
license: ['BSD', 'GPLv2'],
2+
license: 'BSD-2-Clause-Patent AND GPL-2.0-or-later',
33
version: '1.9.4',
4-
meson_version: '>=0.47.0')
4+
meson_version: '>=0.55.0',
5+
)
6+
7+
cc = meson.get_compiler('c')
8+
9+
if cc.has_argument('--std=c99')
10+
add_project_arguments('--std=c99', language: ['c'])
11+
endif
512

613
lz4_files = [
714
'lib/lz4.c',

subprojects/packagefiles/pcre2/meson.build

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ project('pcre2', 'c', version: '10.44')
22

33
cc = meson.get_compiler('c')
44

5+
if cc.has_argument('--std=c99')
6+
add_project_arguments('--std=c99', language: ['c'])
7+
endif
8+
59
conf_data = configuration_data()
610

711
pcre2_chartables = configure_file(input : 'src/pcre2_chartables.c.dist',

subprojects/packagefiles/rizin-grammar-c/meson.build

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
project('rizin-grammar-c', 'c', default_options: ['werror=false'])
1+
project('rizin-grammar-c', 'c',
2+
license: 'MIT',
3+
meson_version: '>=0.55.0',
4+
default_options: [
5+
'werror=false'
6+
]
7+
)
8+
9+
cc = meson.get_compiler('c')
10+
11+
if cc.has_argument('--std=c99')
12+
add_project_arguments('--std=c99', language: ['c'])
13+
endif
214

315
ts_c_files = [
416
'src/parser.c'

subprojects/packagefiles/tree-sitter-0.21.0/meson.build

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
project('tree-sitter', 'c')
1+
project('tree-sitter', 'c',
2+
license: 'MIT',
3+
meson_version: '>=0.55.0',
4+
)
25

36
cc = meson.get_compiler('c')
47

8+
if cc.has_argument('--std=gnu99')
9+
add_project_arguments('--std=gnu99', language: ['c'])
10+
elif cc.has_argument('--std=c99')
11+
add_project_arguments('--std=c99', language: ['c'])
12+
endif
13+
514
tree_sitter_path = 'tree-sitter'
615

716
tree_sitter_files = ['lib/src/lib.c']

subprojects/packagefiles/xz-5.2.9/meson.build

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
# liblzma is what upstream uses for their pkg-config name
22
project('liblzma', 'c',
3-
version : '5.2.9',
4-
license : 'pd/lgpl2/gpl2/gpl3',)
3+
version : '5.4.3',
4+
license : ['PD', 'LGPL2', 'GPL2', 'GPL3'],
5+
meson_version: '>=0.55.0',
6+
)
57

68
cc = meson.get_compiler('c')
79

10+
if cc.has_argument('--std=gnu99')
11+
add_project_arguments('--std=gnu99', language: ['c'])
12+
elif cc.has_argument('--std=c99')
13+
add_project_arguments('--std=c99', language: ['c'])
14+
endif
15+
816
lzma_cflags = ['-DHAVE_CONFIG_H', '-DTUKLIB_SYMBOL_PREFIX=lzma_', '-DLZMA_API_STATIC']
917

1018
cdata = configuration_data()

subprojects/packagefiles/zlib-1.3.1/meson.build

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
project('zlib', 'c', version : '1.3.1', license : 'zlib')
1+
project('zlib', 'c',
2+
version : '1.3.1',
3+
license : 'zlib',
4+
meson_version: '>=0.55.0',
5+
)
26

37
cc = meson.get_compiler('c')
48

9+
if cc.has_argument('--std=c99')
10+
add_project_arguments('--std=c99', language: ['c'])
11+
endif
12+
513
link_args = []
614
compile_args = []
715
if cc.get_argument_syntax() == 'msvc'

subprojects/rizin-shell-parser/meson.build

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
project('rizin-shell-parser', 'c',
2-
license : [ 'LGPL']
2+
license: 'LGPL-3.0-only',
3+
meson_version: '>=0.55.0',
34
)
45

6+
cc = meson.get_compiler('c')
7+
8+
if cc.has_argument('--std=c99')
9+
add_project_arguments('--std=c99', language: ['c'])
10+
endif
11+
512
tree_sitter_dep = dependency('tree-sitter')
613
grammar_js = files('grammar.js')
714
tree_sitter_wrap_py = files('meson_tree_sitter_generate.py')

subprojects/rzar/meson.build

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
project('rzar', 'c',
2-
license : [ 'LGPL']
2+
license: 'LGPL-3.0-only',
3+
meson_version: '>=0.55.0',
34
)
45

56
# handle ar dependency
67
ar_files = [
78
'ar.c'
89
]
910

11+
cc = meson.get_compiler('c')
12+
13+
if cc.has_argument('--std=gnu99')
14+
add_project_arguments('--std=gnu99', language: ['c'])
15+
elif cc.has_argument('--std=c99')
16+
add_project_arguments('--std=c99', language: ['c'])
17+
endif
18+
1019
rz_util_dep = dependency('rz_util')
1120
ar_inc = [include_directories(['.'])]
1221

subprojects/rzgdb/meson.build

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
project('rzw32dbg_wrap', 'c')
22

3+
cc = meson.get_compiler('c')
4+
5+
if cc.has_argument('--std=gnu99')
6+
add_project_arguments('--std=gnu99', language: ['c'])
7+
elif cc.has_argument('--std=c99')
8+
add_project_arguments('--std=c99', language: ['c'])
9+
endif
310

411
gdb_files = [
512
'src/arch.c',

0 commit comments

Comments
 (0)