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(
diff --git a/meson.options b/meson.options
index ff0b0e6..a3fa5b4 100644
--- a/meson.options
+++ b/meson.options
@@ -1,4 +1,3 @@
-option('tests', type: 'feature', value: 'enabled', description: 'Build tests')
option(
'bindings',
type: 'array',
@@ -7,17 +6,11 @@
value: ['serial', 'astlpc', 'i2c'],
)
option(
- 'default_alloc',
- type: 'feature',
- description: 'Use libc malloc and free for heap memory',
+ 'control',
+ type: 'boolean',
+ value: true,
+ description: 'Include MCTP control protocol handler',
)
-option('stdio', type: 'feature', description: 'Support logging to stdio')
-option(
- 'fileio',
- type: 'feature',
- description: 'Support interfaces based on file-descriptors',
-)
-option('syslog', type: 'feature', description: 'Support logging to syslog')
option(
'custom_alloc',
type: 'boolean',
@@ -25,14 +18,56 @@
description: 'Use fixed application-provided allocators',
)
option(
+ 'default_alloc',
+ type: 'feature',
+ description: 'Use libc malloc and free for heap memory',
+)
+option(
+ 'default_clock_gettime',
+ type: 'boolean',
+ value: true,
+ description: 'Use clock_gettime() for time',
+)
+option(
+ 'fileio',
+ type: 'feature',
+ description: 'Support interfaces based on file-descriptors',
+)
+option(
'nolog',
type: 'boolean',
value: false,
description: 'Don\'t include any logging functionality',
)
+option('stdio', type: 'feature', description: 'Support logging to stdio')
+option('syslog', type: 'feature', description: 'Support logging to syslog')
+option('tests', type: 'feature', value: 'enabled', description: 'Build tests')
+
+
option(
- 'control',
- type: 'boolean',
- value: true,
- description: 'Include MCTP control protocol handler',
+ 'max_message_size',
+ type: 'integer',
+ value: 65536,
+ description: 'Maximum message size',
+)
+option(
+ 'reassembly_contexts',
+ type: 'integer',
+ value: 16,
+ description: 'Number of concurrent reassembly contexts',
+)
+option(
+ 'request_tags',
+ type: 'integer',
+ value: 16,
+ description: 'Number of outbound request tags',
+)
+
+
+option('i2c_mtu', type: 'integer', value: 64, description: 'I2C packet MTU')
+option(
+ 'i2c_neigh_count',
+ type: 'integer',
+ value: 4,
+ description: 'I2C neighbour table size',
)