2020-02-25 23:59:18 +01:00
|
|
|
project('inih',
|
2021-01-10 21:56:56 +01:00
|
|
|
['c'],
|
2020-02-25 23:59:18 +01:00
|
|
|
license : 'BSD-3-Clause',
|
2024-01-25 05:58:14 +13:00
|
|
|
version : '58',
|
2024-06-11 17:47:53 -04:00
|
|
|
default_options : ['cpp_std=c++11'],
|
|
|
|
meson_version: '>=0.56.0'
|
2020-02-25 23:59:18 +01:00
|
|
|
)
|
|
|
|
|
2020-04-22 04:49:24 +02:00
|
|
|
#### options ####
|
|
|
|
arg_static = []
|
|
|
|
distro_install = get_option('distro_install')
|
2022-03-23 20:30:27 +01:00
|
|
|
extra_args = []
|
2020-04-22 04:49:24 +02:00
|
|
|
|
|
|
|
if distro_install
|
|
|
|
pkg = import('pkgconfig')
|
|
|
|
else
|
|
|
|
if not get_option('multi-line_entries')
|
|
|
|
arg_static += ['-DINI_ALLOW_MULTILINE=0']
|
|
|
|
endif
|
|
|
|
if not get_option('utf-8_bom')
|
|
|
|
arg_static += ['-DINI_ALLOW_BOM=0']
|
|
|
|
endif
|
|
|
|
if not get_option('inline_comments')
|
|
|
|
arg_static += ['-DINI_ALLOW_INLINE_COMMENTS=0']
|
|
|
|
endif
|
|
|
|
inline_comment_prefix = get_option('inline_comment_prefix')
|
|
|
|
if inline_comment_prefix != ';'
|
|
|
|
arg_static += ['-DINI_INLINE_COMMENT_PREFIXES="' + inline_comment_prefix + '"']
|
|
|
|
endif
|
|
|
|
sol_comment_prefix = get_option('start-of-line_comment_prefix')
|
|
|
|
if sol_comment_prefix != ';#'
|
2022-12-02 16:39:43 -05:00
|
|
|
arg_static += ['-DINI_START_COMMENT_PREFIXES="' + sol_comment_prefix + '"']
|
2020-04-22 04:49:24 +02:00
|
|
|
endif
|
|
|
|
if get_option('allow_no_value')
|
|
|
|
arg_static += ['-DINI_ALLOW_NO_VALUE=1']
|
|
|
|
endif
|
|
|
|
if get_option('stop_on_first_error')
|
|
|
|
arg_static += ['-DINI_STOP_ON_FIRST_ERROR=1']
|
|
|
|
endif
|
|
|
|
if get_option('report_line_numbers')
|
|
|
|
arg_static += ['-DINI_HANDLER_LINENO=1']
|
|
|
|
endif
|
|
|
|
if get_option('call_handler_on_new_section')
|
|
|
|
arg_static += ['-DINI_CALL_HANDLER_ON_NEW_SECTION=1']
|
|
|
|
endif
|
|
|
|
if get_option('use_heap')
|
|
|
|
arg_static += ['-DINI_USE_STACK=0']
|
|
|
|
endif
|
|
|
|
max_line_length = get_option('max_line_length')
|
|
|
|
if max_line_length != 200
|
2020-08-03 23:03:26 +02:00
|
|
|
arg_static += ['-DINI_MAX_LINE=' + max_line_length.to_string()]
|
2020-04-22 04:49:24 +02:00
|
|
|
endif
|
|
|
|
initial_malloc_size = get_option('initial_malloc_size')
|
|
|
|
if initial_malloc_size != 200
|
2020-08-03 23:03:26 +02:00
|
|
|
arg_static += ['-DINI_INITIAL_ALLOC=' + initial_malloc_size.to_string()]
|
2020-04-22 04:49:24 +02:00
|
|
|
endif
|
|
|
|
if get_option('allow_realloc')
|
|
|
|
arg_static += ['-DINI_ALLOW_REALLOC=1']
|
|
|
|
endif
|
|
|
|
endif
|
2020-02-25 23:59:18 +01:00
|
|
|
|
2022-03-23 20:30:27 +01:00
|
|
|
if host_machine.system() == 'windows'
|
|
|
|
lib = get_option('default_library')
|
|
|
|
if lib == 'both'
|
|
|
|
error('default_library=both is not supported on Windows')
|
|
|
|
elif lib == 'shared'
|
|
|
|
extra_args += '-DINI_SHARED_LIB'
|
|
|
|
add_project_arguments('-DINI_SHARED_LIB_BUILDING', language: ['c', 'cpp'])
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2020-04-22 04:49:24 +02:00
|
|
|
#### inih ####
|
2020-02-27 21:28:12 +01:00
|
|
|
inc_inih = include_directories('.')
|
|
|
|
|
2024-06-11 17:47:53 -04:00
|
|
|
src_inih = files('ini.c')
|
|
|
|
|
2020-02-25 23:59:18 +01:00
|
|
|
lib_inih = library('inih',
|
2024-06-11 17:47:53 -04:00
|
|
|
[src_inih],
|
2020-02-27 21:28:12 +01:00
|
|
|
include_directories : inc_inih,
|
2022-03-23 20:30:27 +01:00
|
|
|
c_args : [arg_static, extra_args],
|
2020-04-22 04:49:24 +02:00
|
|
|
install : distro_install,
|
2022-03-23 20:30:27 +01:00
|
|
|
soversion : '0',
|
|
|
|
gnu_symbol_visibility: 'hidden'
|
2020-02-25 23:59:18 +01:00
|
|
|
)
|
|
|
|
|
2020-04-22 04:49:24 +02:00
|
|
|
if distro_install
|
|
|
|
install_headers('ini.h')
|
|
|
|
|
|
|
|
pkg.generate(lib_inih,
|
|
|
|
name : 'inih',
|
|
|
|
description : 'simple .INI file parser',
|
2022-03-23 20:30:27 +01:00
|
|
|
extra_cflags : extra_args,
|
2020-04-22 04:49:24 +02:00
|
|
|
)
|
|
|
|
endif
|
2020-02-25 23:59:18 +01:00
|
|
|
|
2020-02-27 21:28:12 +01:00
|
|
|
inih_dep = declare_dependency(
|
|
|
|
link_with : lib_inih,
|
2022-03-23 20:30:27 +01:00
|
|
|
compile_args : arg_static + extra_args,
|
2020-02-27 21:28:12 +01:00
|
|
|
include_directories : inc_inih
|
|
|
|
)
|
2020-02-26 21:02:16 +01:00
|
|
|
|
2024-06-11 17:47:53 -04:00
|
|
|
subdir('tests')
|
|
|
|
|
2020-02-25 23:59:18 +01:00
|
|
|
#### INIReader ####
|
2020-04-22 04:49:24 +02:00
|
|
|
if get_option('with_INIReader')
|
2021-01-10 21:56:56 +01:00
|
|
|
add_languages('cpp')
|
2020-04-22 04:49:24 +02:00
|
|
|
inc_INIReader = include_directories('cpp')
|
2020-02-25 23:59:18 +01:00
|
|
|
|
2024-06-11 17:47:53 -04:00
|
|
|
src_INIReader = files(join_paths('cpp', 'INIReader.cpp'))
|
|
|
|
|
2020-04-22 04:49:24 +02:00
|
|
|
lib_INIReader = library('INIReader',
|
2024-06-11 17:47:53 -04:00
|
|
|
src_INIReader,
|
2022-03-23 20:30:27 +01:00
|
|
|
cpp_args : extra_args,
|
2020-04-22 04:49:24 +02:00
|
|
|
include_directories : inc_INIReader,
|
|
|
|
dependencies : inih_dep,
|
|
|
|
install : distro_install,
|
2022-03-23 20:30:27 +01:00
|
|
|
soversion : '0',
|
|
|
|
gnu_symbol_visibility: 'hidden'
|
2020-04-22 04:49:24 +02:00
|
|
|
)
|
2020-02-27 21:28:12 +01:00
|
|
|
|
2020-04-22 04:49:24 +02:00
|
|
|
if distro_install
|
|
|
|
install_headers('cpp/INIReader.h')
|
2020-02-25 23:59:18 +01:00
|
|
|
|
2020-04-22 04:49:24 +02:00
|
|
|
pkg.generate(lib_INIReader,
|
|
|
|
name : 'INIReader',
|
|
|
|
description : 'simple .INI file parser for C++',
|
2022-03-23 20:30:27 +01:00
|
|
|
extra_cflags : extra_args,
|
2020-04-22 04:49:24 +02:00
|
|
|
)
|
|
|
|
endif
|
2020-02-26 21:02:16 +01:00
|
|
|
|
2020-04-22 04:49:24 +02:00
|
|
|
INIReader_dep = declare_dependency(
|
|
|
|
link_with : lib_INIReader,
|
2022-03-23 20:30:27 +01:00
|
|
|
include_directories : inc_INIReader,
|
|
|
|
compile_args : extra_args
|
2020-04-22 04:49:24 +02:00
|
|
|
)
|
2024-06-11 17:47:53 -04:00
|
|
|
|
|
|
|
subdir('examples')
|
2020-04-22 04:49:24 +02:00
|
|
|
endif
|