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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
From ef66d86f81e5ae5895bae5d60c6023bd128d6119 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= <tim@centricular.com>
Date: Wed, 28 Dec 2022 16:14:12 +0100
Subject: [PATCH 2/3] meson: add build options for 8/16/32 bit libs and disable
16/32 variant by default
... same as in autotools build.
---
meson.build | 168 +++++++++++++++++++++++++++-------------------
meson_options.txt | 14 +++-
2 files changed, 113 insertions(+), 69 deletions(-)
diff --git a/meson.build b/meson.build
index 1df43c5..9bcb557 100644
--- a/meson.build
+++ b/meson.build
@@ -2,7 +2,7 @@ project(
'pcre2',
'c',
license: 'BSD-3',
- meson_version: '>=0.49.0',
+ meson_version: '>= 0.52.0',
version: '10.42',
)
@@ -93,6 +93,7 @@ foreach f : check_funs
endif
endforeach
+# TODO: also define SUPPORT_PCRE2_16 and SUPPORT_PCRE2_32 if available?
config_h_defs += [
'-DSTDC_HEADERS',
'-DSUPPORT_PCRE2_8',
@@ -106,61 +107,86 @@ else
static_defs = []
endif
-pcre2_8_lib = library(
- 'pcre2-8',
- sources,
- include_directories: includes,
- c_args: [config_h_defs, '-DHAVE_CONFIG_H', '-DPCRE2_CODE_UNIT_WIDTH=8'],
- install: true,
-)
+pcre2_deps = []
-libpcre2_8 = declare_dependency(
- link_with: pcre2_8_lib,
- include_directories: includes,
- compile_args: static_defs,
-)
+if not get_option('pcre2-8').disabled() # enable on auto
+ pcre2_8_lib = library(
+ 'pcre2-8',
+ sources,
+ include_directories: includes,
+ c_args: [config_h_defs, '-DHAVE_CONFIG_H', '-DPCRE2_CODE_UNIT_WIDTH=8'],
+ install: true,
+ )
-pcre2_posix_lib = library(
- 'pcre2-posix',
- 'src/pcre2posix.c',
- dependencies: libpcre2_8,
- c_args: [config_h_defs, '-DHAVE_CONFIG_H', '-DPCRE2_CODE_UNIT_WIDTH=8'],
- install: true,
-)
+ libpcre2_8 = declare_dependency(
+ link_with: pcre2_8_lib,
+ include_directories: includes,
+ compile_args: static_defs,
+ )
-libpcre2_posix = declare_dependency(
- link_with: pcre2_posix_lib,
- include_directories: includes,
- compile_args: static_defs,
-)
+ pcre2_posix_lib = library(
+ 'pcre2-posix',
+ 'src/pcre2posix.c',
+ dependencies: libpcre2_8,
+ c_args: [config_h_defs, '-DHAVE_CONFIG_H', '-DPCRE2_CODE_UNIT_WIDTH=8'],
+ install: true,
+ )
-pcre2_16_lib = library(
- 'pcre2-16',
- sources,
- include_directories: includes,
- c_args: [config_h_defs, '-DHAVE_CONFIG_H', '-DPCRE2_CODE_UNIT_WIDTH=16'],
- install: true,
-)
+ libpcre2_posix = declare_dependency(
+ link_with: pcre2_posix_lib,
+ include_directories: includes,
+ compile_args: static_defs,
+ )
-libpcre2_16 = declare_dependency(
- link_with: pcre2_16_lib,
- include_directories: includes,
- compile_args: static_defs,
-)
+ pcre2_deps += [libpcre2_8, libpcre2_posix]
+else
+ libpcre2_8 = disabler()
+ libpcre2_posix = disabler()
+endif
-pcre2_32_lib = library(
- 'pcre2-32',
- sources,
- include_directories: includes,
- c_args: [config_h_defs, '-DHAVE_CONFIG_H', '-DPCRE2_CODE_UNIT_WIDTH=32'],
- install: true,
-)
+if get_option('pcre2-16').enabled() # disable on auto
+ pcre2_16_lib = library(
+ 'pcre2-16',
+ sources,
+ include_directories: includes,
+ c_args: [config_h_defs, '-DHAVE_CONFIG_H', '-DPCRE2_CODE_UNIT_WIDTH=16'],
+ install: true,
+ )
-libpcre2_32 = declare_dependency(
- link_with: pcre2_32_lib,
- include_directories: includes,
- compile_args: static_defs,
-)
+ libpcre2_16 = declare_dependency(
+ link_with: pcre2_16_lib,
+ include_directories: includes,
+ compile_args: static_defs,
+ )
+
+ pcre2_deps += [libpcre2_16]
+else
+ libpcre2_16 = disabler()
+endif
+
+if get_option('pcre2-32').enabled() # disable on auto
+ pcre2_32_lib = library(
+ 'pcre2-32',
+ sources,
+ include_directories: includes,
+ c_args: [config_h_defs, '-DHAVE_CONFIG_H', '-DPCRE2_CODE_UNIT_WIDTH=32'],
+ install: true,
+ )
+
+ libpcre2_32 = declare_dependency(
+ link_with: pcre2_32_lib,
+ include_directories: includes,
+ compile_args: static_defs,
+ )
+
+ pcre2_deps += [libpcre2_32]
+else
+ libpcre2_32 = disabler()
+endif
+
+if pcre2_deps.length() == 0
+ error('At least one of the 8, 16 or 32 bit libraries must be enabled')
+endif
if get_option('grep')
pcre2grep = executable(
@@ -178,26 +204,32 @@ install_headers(pcre2_h, 'src/pcre2posix.h')
pkg = import('pkgconfig')
-pkg.generate(
- pcre2_8_lib,
- name: 'libpcre2-8',
- description: 'PCRE2 - Perl compatible regular expressions C library (2nd API) with 8 bit character support',
- version: meson.project_version(),
-)
+if not is_disabler(libpcre2_8)
+ pkg.generate(
+ pcre2_8_lib,
+ name: 'libpcre2-8',
+ description: 'PCRE2 - Perl compatible regular expressions C library (2nd API) with 8 bit character support',
+ version: meson.project_version(),
+ )
+endif
-pkg.generate(
- pcre2_16_lib,
- name: 'libpcre2-16',
- description: 'PCRE2 - Perl compatible regular expressions C library (2nd API) with 16 bit character support',
- version: meson.project_version(),
-)
+if not is_disabler(libpcre2_16)
+ pkg.generate(
+ pcre2_16_lib,
+ name: 'libpcre2-16',
+ description: 'PCRE2 - Perl compatible regular expressions C library (2nd API) with 16 bit character support',
+ version: meson.project_version(),
+ )
+endif
-pkg.generate(
- pcre2_32_lib,
- name: 'libpcre2-32',
- description: 'PCRE2 - Perl compatible regular expressions C library (2nd API) with 32 bit character support',
- version: meson.project_version(),
-)
+if not is_disabler(libpcre2_32)
+ pkg.generate(
+ pcre2_32_lib,
+ name: 'libpcre2-32',
+ description: 'PCRE2 - Perl compatible regular expressions C library (2nd API) with 32 bit character support',
+ version: meson.project_version(),
+ )
+endif
#### tests
@@ -213,7 +245,7 @@ if (
pcre2test = executable(
'pcre2test',
'src/pcre2test.c',
- dependencies: [libpcre2_8, libpcre2_posix, libpcre2_16, libpcre2_32],
+ dependencies: pcre2_deps,
c_args: [config_h_defs, '-DHAVE_CONFIG_H'],
link_args: link_args,
)
diff --git a/meson_options.txt b/meson_options.txt
index f80d19d..6454d70 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -5,4 +5,16 @@ option(
option(
'test', type: 'boolean', value: true,
description: 'Compile the test executable and enable tests'
-)
\ No newline at end of file
+)
+option(
+ 'pcre2-8', type: 'feature', value: 'enabled',
+ description: '8 bit character support'
+)
+option(
+ 'pcre2-16', type: 'feature', value: 'disabled',
+ description: '16 bit character support'
+)
+option(
+ 'pcre2-32', type: 'feature', value: 'disabled',
+ description: '32 bit character support'
+)
--
2.38.1
|