Specify customization with meson options
Meson options can now be used to pass custom parameters. The default
values are still used if unset for other build systems.
Previously -D arguments were not being used by Meson when determining
sizeof for libmctp-sizes.h, since arguments are ignored for compiler
flags. Instead the options are now passed explicitly.
Change-Id: I04cfff40fab03b8ccbca33acdf2b5abb30723e5b
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
diff --git a/meson.build b/meson.build
index 7f55a2e..b8897a5 100644
--- a/meson.build
+++ b/meson.build
@@ -74,6 +74,20 @@
libmctp_sources += ['log.c']
endif
+option_args = [
+ '-DMCTP_MAX_MESSAGE_SIZE=@0@'.format(get_option('max_message_size')),
+ '-DMCTP_REASSEMBLY_CTXS=@0@'.format(get_option('reassembly_contexts')),
+ '-DMCTP_REQ_TAGS=@0@'.format(get_option('request_tags')),
+ '-DMCTP_DEFAULT_CLOCK_GETTIME=@0@'.format(
+ get_option('default_clock_gettime').to_int(),
+ ),
+ '-DMCTP_CONTROL_HANDLER=@0@'.format(get_option('control').to_int()),
+ '-DI2C_BTU=@0@'.format(get_option('i2c_mtu')),
+ '-DMCTP_I2C_NEIGH_COUNT=@0@'.format(get_option('i2c_neigh_count')),
+]
+
+add_project_arguments(option_args, language: 'c')
+
feat_fileio = get_option('fileio').require(
compiler.links(
'''
@@ -173,11 +187,13 @@
sizeof_mctp = compiler.sizeof(
'struct mctp',
include_directories: libmctp_include_dir,
+ args: option_args,
prefix: '#include "core-internal.h"',
)
sizeof_binding_i2c = compiler.sizeof(
'struct mctp_binding_i2c',
include_directories: libmctp_include_dir,
+ args: option_args,
prefix: '#include "i2c-internal.h"',
)
sizes_h = configure_file(