forked from libcsp/libcsp
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmeson.build
More file actions
129 lines (107 loc) · 4.21 KB
/
meson.build
File metadata and controls
129 lines (107 loc) · 4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
project('csp', 'c', version: '2.2', license: 'LGPL', meson_version : '>=0.61.2', default_options : [
'c_std=gnu11',
'optimization=s',
'warning_level=3',
'werror=true'])
cc = meson.get_compiler('c')
conf = configuration_data()
conf.set('CSP_QFIFO_LEN', get_option('qfifo_len'))
conf.set('CSP_PORT_MAX_BIND', get_option('port_max_bind'))
conf.set('CSP_CONN_RXQUEUE_LEN', get_option('conn_rxqueue_len'))
conf.set('CSP_CONN_MAX', get_option('conn_max'))
conf.set('CSP_BUFFER_SIZE', get_option('buffer_size'))
conf.set('CSP_BUFFER_COUNT', get_option('buffer_count'))
conf.set('CSP_PACKET_PADDING_BYTES', get_option('packet_padding_bytes'))
conf.set('CSP_RDP_MAX_WINDOW', get_option('rdp_max_window'))
conf.set('CSP_RTABLE_SIZE', get_option('rtable_size'))
conf.set10('CSP_REPRODUCIBLE_BUILDS', get_option('enable_reproducible_builds'))
conf.set10('CSP_USE_RDP', get_option('use_rdp'))
conf.set10('CSP_USE_HMAC', get_option('use_hmac'))
conf.set10('CSP_USE_PROMISC', get_option('use_promisc'))
conf.set10('CSP_HAVE_STDIO', get_option('have_stdio'))
conf.set10('CSP_ENABLE_CSP_PRINT', get_option('enable_csp_print'))
conf.set10('CSP_PRINT_STDIO', get_option('print_stdio'))
conf.set10('CSP_USE_RTABLE', get_option('use_rtable'))
conf.set10('CSP_BUFFER_ZERO_CLEAR', get_option('buffer_zero_clear'))
conf.set10('CSP_FIXUP_V1_ZMQ_LITTLE_ENDIAN', get_option('fixup_v1_zmq_little_endian'))
conf.set10('CSP_ENABLE_KISS_CRC', get_option('enable_kiss_crc'))
csp_deps = []
csp_sources = []
# First try libyaml from dynamic library (os)
yaml_dep = dependency('yaml-0.1', required : false)
# Second try to include libyaml as a cmake subproject (shared library)
if yaml_dep.found() == false
cmake = import('cmake')
# This feature is too new for github CI meson version
#yaml_opts = cmake.subproject_options()
#yaml_opts.add_cmake_defines({'BUILD_SHARED_LIBS': true})
#yaml_pro = cmake.subproject('yaml', required: false, options: yaml_opts)
yaml_pro = cmake.subproject('yaml', required: false)
if yaml_pro.found()
yaml_dep = yaml_pro.dependency('yaml')
endif
endif
csp_deps += yaml_dep
conf.set('CSP_HAVE_LIBYAML', yaml_dep.found())
clib_dep = dependency('libc', required: false)
if not clib_dep.found()
picolib_dep = dependency('', fallback : ['picolibc', 'picolibc_dep'], required : false)
if picolib_dep.found()
error('\n' +
'=======================================================================\n' +
'Libcsp no longer automatically fetches picolibc. \n' +
'If you intended to use picolibc, inject it from your main meson.build:\n\n' +
' picolibc_proj = subproject(\'picolibc\')\n' +
' meson.override_dependency(\'libc\', picolibc_proj.get_variable(\'picolibc_dep\'))\n' +
'=======================================================================')
endif
clib_dep = meson.get_compiler('c').find_library('c', required: true)
endif
csp_deps += clib_dep
# Include paths
csp_inc = include_directories('include', 'src')
# Default compile options
csp_c_args = ['-Wall',
'-Wcast-align',
'-Wextra',
'-Wmissing-prototypes',
'-Wpedantic',
'-Wpointer-arith',
'-Wshadow',
'-Wwrite-strings']
if cc.get_id() == 'clang'
csp_c_args += '-Wno-gnu-zero-variadic-macro-arguments'
endif
subdir('src')
subdir('include/csp')
if not meson.is_subproject()
install_subdir('include', install_dir : '', exclude_files : ['csp/meson.build'])
endif
csp_lib = library('csp',
sources: [csp_sources, csp_config_h],
include_directories : csp_inc,
dependencies : csp_deps,
c_args : csp_c_args,
install : true,
pic:true,
)
# The following dependency variable is for parent projects to link
# against libcsp. https://mesonbuild.com/Subprojects.html
csp_dep = declare_dependency(
include_directories : csp_inc,
link_with : csp_lib,
dependencies : csp_deps,
)
subdir('examples')
if get_option('enable_python3_bindings')
py = import('python').find_installation('python3')
# py.dependency() doesn't work with version constraint. Use plain
# dependency() instead
pydep = dependency('python3', version : '>=3.5', required : true)
py.extension_module('libcsp_py3', 'src/bindings/python/pycsp.c',
c_args : [csp_c_args,
'-Wno-missing-prototypes',
'-Wno-unused-parameter'],
dependencies : [csp_dep, pydep],
install : true)
endif