Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit f227086

Browse files
committed
meson: convert boolean options to feature option
Simpler. Seems like they're only disabled by minimum. Signed-off-by: Rosen Penev <rosenp@gmail.com>
1 parent ed3e53d commit f227086

4 files changed

Lines changed: 74 additions & 104 deletions

File tree

include/libxml/meson.build

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ xmlversion_h.set10('WITH_DEBUG', want_debug)
1010
xmlversion_h.set10('WITH_FTP', want_ftp)
1111
xmlversion_h.set10('WITH_HTML', want_html)
1212
xmlversion_h.set10('WITH_HTTP', want_http)
13-
xmlversion_h.set10('WITH_ICONV', want_iconv)
14-
xmlversion_h.set10('WITH_ICU', want_icu)
13+
xmlversion_h.set10('WITH_ICONV', iconv_dep.found())
14+
xmlversion_h.set10('WITH_ICU', icu_dep.found())
1515
xmlversion_h.set10('WITH_ISO8859X', want_iso8859x)
1616
xmlversion_h.set10('WITH_LEGACY', want_legacy)
17-
xmlversion_h.set10('WITH_LZMA', want_lzma)
18-
xmlversion_h.set10('WITH_MODULES', with_modules)
17+
xmlversion_h.set10('WITH_LZMA', lzma_dep.found())
18+
xmlversion_h.set10('WITH_MODULES', dl_dep.found())
1919
xmlversion_h.set('MODULE_EXTENSION', module_extension)
2020
xmlversion_h.set10('WITH_OUTPUT', want_output)
2121
xmlversion_h.set10('WITH_PATTERN', want_pattern)
@@ -25,7 +25,7 @@ xmlversion_h.set10('WITH_REGEXPS', want_regexps)
2525
xmlversion_h.set10('WITH_SAX1', want_sax1)
2626
xmlversion_h.set10('WITH_SCHEMAS', want_schemas)
2727
xmlversion_h.set10('WITH_SCHEMATRON', want_schematron)
28-
xmlversion_h.set10('WITH_THREADS', want_threads)
28+
xmlversion_h.set10('WITH_THREADS', threads_dep.found())
2929
xmlversion_h.set10('WITH_THREAD_ALLOC', want_thread_alloc)
3030
xmlversion_h.set10('WITH_TREE', want_tree)
3131
xmlversion_h.set10('WITH_VALID', want_valid)
@@ -34,7 +34,7 @@ xmlversion_h.set10('WITH_XINCLUDE', want_xinclude)
3434
xmlversion_h.set10('WITH_XPATH', want_xpath)
3535
xmlversion_h.set10('WITH_XPTR', want_xptr)
3636
xmlversion_h.set10('WITH_XPTR_LOCS', want_xptr_locs)
37-
xmlversion_h.set10('WITH_ZLIB', want_zlib)
37+
xmlversion_h.set10('WITH_ZLIB', zlib_dep.found())
3838

3939
configure_file(
4040
input: 'xmlversion.h.in',

meson.build

Lines changed: 57 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,9 @@ want_ftp = get_option('ftp')
6060
want_history = get_option('history')
6161
want_html = get_option('html')
6262
want_http = get_option('http')
63-
want_iconv = get_option('iconv')
64-
want_icu = get_option('icu')
6563
want_ipv6 = get_option('ipv6')
6664
want_iso8859x = get_option('iso8859x')
6765
want_legacy = get_option('legacy')
68-
want_lzma = get_option('lzma')
69-
want_modules = get_option('modules')
7066
want_output = get_option('output')
7167
want_pattern = get_option('pattern')
7268
want_push = get_option('push')
@@ -77,7 +73,6 @@ want_regexps = get_option('regexps')
7773
want_sax1 = get_option('sax1')
7874
want_schemas = get_option('schemas')
7975
want_schematron = get_option('schematron')
80-
want_threads = get_option('threads')
8176
want_thread_alloc = get_option('thread-alloc')
8277
want_tls = get_option('tls')
8378
want_tree = get_option('tree')
@@ -87,7 +82,6 @@ want_xinclude = get_option('xinclude')
8782
want_xpath = get_option('xpath')
8883
want_xptr = get_option('xptr')
8984
want_xptr_locs = get_option('xptr-locs')
90-
want_zlib = get_option('zlib')
9185

9286
# TODO: Options should be three-valued: "yes", "no", default
9387

@@ -185,11 +179,8 @@ if get_option('minimum')
185179
want_history = false
186180
want_html = false
187181
want_http = false
188-
want_iconv = false
189182
want_ipv6 = false
190183
want_iso8859x = false
191-
want_lzma = false
192-
want_modules = false
193184
want_output = false
194185
want_pattern = false
195186
want_push = false
@@ -200,7 +191,6 @@ if get_option('minimum')
200191
want_sax1 = false
201192
want_schemas = false
202193
want_schematron = false
203-
want_threads = false
204194
want_thread_alloc = false
205195
want_tree = false
206196
want_valid = false
@@ -209,7 +199,6 @@ if get_option('minimum')
209199
want_xpath = false
210200
want_xptr = false
211201
want_xptr_locs = false
212-
want_zlib = false
213202
else
214203
# Disable dependent modules
215204
if want_output == false
@@ -402,49 +391,46 @@ if cc.has_function_attribute('destructor')
402391
endif
403392

404393
### DSO support
405-
with_modules = false
406-
if want_modules == true
407-
if sys_cygwin == true
408-
module_extension = '.dll'
409-
elif sys_windows == true
410-
module_extension = '.dll'
411-
with_modules = true
412-
else
413-
module_extension = '.so'
414-
endif
394+
if sys_cygwin == true
395+
module_extension = '.dll'
396+
elif sys_windows == true
397+
module_extension = '.dll'
398+
else
399+
module_extension = '.so'
400+
endif
415401

416-
if with_modules == false
402+
dl_dep = dependency('', required: false)
403+
if not get_option('minimum')
404+
if host_machine.system() != 'windows'
417405
if meson.version().version_compare('>=0.62')
418-
dl_dep = dependency('dl', required: false)
406+
dl_dep = dependency('dl', required: get_option('modules'))
419407
else
420-
dl_dep = cc.find_library('dl', required: false)
408+
dl_dep = cc.find_library('dl', required: get_option('modules'))
421409
endif
422410
if dl_dep.found()
423411
config_h.set10('HAVE_DLOPEN', true)
424412
xml_deps += dl_dep
425-
with_modules = true
426413
endif
414+
elif get_option('modules').allowed()
415+
dl_dep = declare_dependency()
427416
endif
428417
endif
429418

430419
### threads
431-
if want_threads == true
432-
if sys_windows == false
433-
threads_dep = dependency('threads')
420+
threads_dep = dependency('', required: false)
421+
if not get_option('minimum')
422+
if host_machine.system() != 'windows'
423+
threads_dep = dependency('threads', required: get_option('threads'))
434424
if threads_dep.found()
435425
config_h.set10('HAVE_PTHREAD_H', true)
436426
xml_deps += threads_dep
437-
else
438-
want_threads = false
439427
endif
440-
else
441-
threads_dep = dependency('', required: false)
428+
elif get_option('threads').allowed()
429+
threads_dep = declare_dependency()
442430
endif
443431
endif
444432

445-
want_thread_alloc = (
446-
(want_threads == true and want_threads == true) ? true : false
447-
)
433+
want_thread_alloc = threads_dep.found()
448434

449435
### xmllint shell history
450436
xmllint_deps = []
@@ -582,51 +568,41 @@ int main()
582568
endif
583569

584570
### zlib
585-
if want_zlib == true
586-
zlib_dep = dependency('zlib', required: false)
587-
if zlib_dep.found()
588-
xml_deps += zlib_dep
589-
else
590-
want_zlib = false
591-
endif
571+
if not get_option('minimum')
572+
zlib_dep = dependency('zlib', required: get_option('zlib'))
573+
else
574+
zlib_dep = dependency('', required: false)
592575
endif
576+
xml_deps += zlib_dep
593577

594578
### lzma
595-
if want_lzma == true
596-
lzma_dep = dependency('liblzma', required: false)
597-
if lzma_dep.found()
598-
xml_deps += lzma_dep
599-
else
600-
want_lzma = false
601-
endif
579+
if not get_option('minimum')
580+
lzma_dep = dependency('liblzma', required: get_option('lzma'))
581+
else
582+
lzma_dep = dependency('', required: false)
602583
endif
584+
xml_deps += lzma_dep
603585

604586
### iconv
605-
if want_iconv == true
606-
iconv_dep = dependency('iconv', required: false)
607-
if iconv_dep.found()
608-
xml_deps += iconv_dep
609-
else
610-
want_iconv = false
611-
endif
587+
if not get_option('minimum')
588+
iconv_dep = dependency('iconv', required: get_option('iconv'))
589+
else
590+
iconv_dep = dependency('', required: false)
612591
endif
592+
xml_deps += iconv_dep
613593

614-
if want_iconv == false and want_iso8859x == false
594+
if not iconv_dep.found() and want_iso8859x == false
615595
want_iso8859x = false
616596
else
617597
want_iso8859x = true
618598
endif
619599

620600
# icu
621-
if want_icu == true
622-
icu_dep = dependency('icu-i18n', method: 'pkg-config', required: false)
623-
if icu_dep.found()
624-
def_var = icu_dep.get_variable(pkgconfig: 'DEFS')
625-
config_dir += include_directories(def_var)
626-
xml_deps += icu_dep
627-
else
628-
want_icu = false
629-
endif
601+
icu_dep = dependency('icu-i18n', method: 'pkg-config', required: get_option('icu'))
602+
if icu_dep.found()
603+
def_var = icu_dep.get_variable(pkgconfig: 'DEFS')
604+
config_dir += include_directories(def_var)
605+
xml_deps += icu_dep
630606
endif
631607

632608
subdir('include/libxml')
@@ -667,8 +643,8 @@ xml_opt_src = [
667643
[want_html, ['HTMLparser.c', 'HTMLtree.c']],
668644
[want_http, ['nanohttp.c']],
669645
[want_legacy, ['legacy.c']],
670-
[want_lzma, ['xzlib.c']],
671-
[with_modules, ['xmlmodule.c']],
646+
[lzma_dep.found(), ['xzlib.c']],
647+
[dl_dep.found(), ['xmlmodule.c']],
672648
[want_output, ['xmlsave.c']],
673649
[want_pattern, ['pattern.c']],
674650
[want_reader, ['xmlreader.c']],
@@ -787,7 +763,7 @@ pkgmod.generate(
787763
description: 'libXML library version2.',
788764
filebase: 'libxml-2.0',
789765
name: 'libXML',
790-
variables: 'modules=' + with_modules.to_string('1', '0'),
766+
variables: 'modules=' + dl_dep.found().to_string('1', '0'),
791767
)
792768

793769
## libxml2-config.cmake file
@@ -797,12 +773,12 @@ config_cmake.set('LIBXML_MAJOR_VERSION', v_maj)
797773
config_cmake.set('LIBXML_MINOR_VERSION', v_min)
798774
config_cmake.set('LIBXML_MICRO_VERSION', v_mic)
799775
config_cmake.set('VERSION', meson.project_version())
800-
config_cmake.set('WITH_ICONV', want_iconv.to_int().to_string())
801-
config_cmake.set('WITH_ICU', want_icu.to_int().to_string())
802-
config_cmake.set('WITH_LZMA', want_lzma.to_int().to_string())
803-
config_cmake.set('WITH_MODULES', want_modules.to_int().to_string())
804-
config_cmake.set('WITH_THREADS', want_threads.to_int().to_string())
805-
config_cmake.set('WITH_ZLIB', want_zlib.to_int().to_string())
776+
config_cmake.set('WITH_ICONV', iconv_dep.found().to_int().to_string())
777+
config_cmake.set('WITH_ICU', icu_dep.found().to_int().to_string())
778+
config_cmake.set('WITH_LZMA', lzma_dep.found().to_int().to_string())
779+
config_cmake.set('WITH_MODULES', dl_dep.found().to_int().to_string())
780+
config_cmake.set('WITH_THREADS', threads_dep.found().to_int().to_string())
781+
config_cmake.set('WITH_ZLIB', zlib_dep.found().to_int().to_string())
806782
config_cmake.set('XML_CFLAGS', xml_cflags)
807783
configure_file(
808784
input: 'libxml2-config.cmake.in',
@@ -834,13 +810,13 @@ summary(
834810
'history': want_history,
835811
'html': want_html,
836812
'http': want_http,
837-
'iconv': want_iconv,
838-
'icu': want_icu,
813+
'iconv': iconv_dep.found(),
814+
'icu': icu_dep.found(),
839815
'ipv6': want_ipv6,
840816
'iso8859x': want_iso8859x,
841817
'legacy': want_legacy,
842-
'lzma': want_lzma,
843-
'modules': want_modules,
818+
'lzma': lzma_dep.found(),
819+
'modules': dl_dep.found(),
844820
'output': want_output,
845821
'pattern': want_pattern,
846822
'push': want_push,
@@ -851,7 +827,7 @@ summary(
851827
'sax1': want_sax1,
852828
'schemas': want_schemas,
853829
'schematron': want_schematron,
854-
'threads': want_threads,
830+
'threads': threads_dep.found(),
855831
'thread-alloc': want_thread_alloc,
856832
'tls': want_tls,
857833
'tree': want_tree,
@@ -861,7 +837,7 @@ summary(
861837
'xpath': want_xpath,
862838
'xptr': want_xptr,
863839
'xptr-locs': want_xptr_locs,
864-
'zlib': want_zlib,
840+
'zlib': zlib_dep.found(),
865841
},
866842
section: 'Configuration Options Summary:',
867843
)

meson_options.txt

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,12 @@ option('http',
8585

8686
# TODO meson custom dependency
8787
option('iconv',
88-
type: 'boolean',
89-
value: true,
88+
type: 'feature',
9089
description: 'iconv support'
9190
)
9291

9392
option('icu',
94-
type: 'boolean',
95-
value: false,
93+
type: 'feature',
9694
description: 'ICU support'
9795
)
9896

@@ -115,14 +113,12 @@ option('legacy',
115113
)
116114

117115
option('lzma',
118-
type: 'boolean',
119-
value: false,
116+
type: 'feature',
120117
description: 'LZMA support'
121118
)
122119

123120
option('modules',
124-
type: 'boolean',
125-
value: true,
121+
type: 'feature',
126122
description: 'Dynamic modules support'
127123
)
128124

@@ -187,8 +183,7 @@ option('schematron',
187183
)
188184

189185
option('threads',
190-
type: 'boolean',
191-
value: true,
186+
type: 'feature',
192187
description: 'Multithreading support'
193188
)
194189

@@ -247,8 +242,7 @@ option('xptr-locs',
247242
)
248243

249244
option('zlib',
250-
type: 'boolean',
251-
value: false,
245+
type: 'feature',
252246
description: 'ZLIB support'
253247
)
254248

python/meson.build

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ if py.found() == true
2020
setup_py = configuration_data()
2121
setup_py.set('prefix', get_option('prefix'))
2222
setup_py.set('LIBXML_VERSION', meson.project_version())
23-
setup_py.set('WITH_ICONV', want_iconv.to_int())
24-
setup_py.set('WITH_ICU', want_icu.to_int())
25-
setup_py.set('WITH_LZMA', want_lzma.to_int())
26-
setup_py.set('WITH_ZLIB', want_zlib.to_int())
27-
setup_py.set('WITH_THREADS', want_threads.to_int())
23+
setup_py.set('WITH_ICONV', iconv_dep.found().to_int())
24+
setup_py.set('WITH_ICU', icu_dep.found().to_int())
25+
setup_py.set('WITH_LZMA', lzma_dep.found().to_int())
26+
setup_py.set('WITH_ZLIB', zlib_dep.found().to_int())
27+
setup_py.set('WITH_THREADS', threads_dep.found().to_int())
2828
configure_file(
2929
input: 'setup.py.in',
3030
output: 'setup.py',

0 commit comments

Comments
 (0)