meson: Format build files with `meson format`
Additionally, add the formatting command to `scripts/pre-submit` so it's
run by OpenBMC's CI (via `scripts/run-ci`).
Change-Id: Ifb8fc06106b8cfa9155e986528b769a5ca450b4c
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
diff --git a/include/libpldm/meson.build b/include/libpldm/meson.build
index 014c969..e811f28 100644
--- a/include/libpldm/meson.build
+++ b/include/libpldm/meson.build
@@ -1,39 +1,37 @@
libpldm_headers = files(
- 'base.h',
- 'bios.h',
- 'bios_table.h',
- 'compiler.h',
- 'entity.h',
- 'firmware_update.h',
- 'fru.h',
- 'instance-id.h',
- 'pdr.h',
- 'platform.h',
- 'pldm_types.h',
- 'pldm.h',
- 'state_set.h',
- 'states.h',
- 'transport.h',
- 'transport/af-mctp.h',
- 'transport/mctp-demux.h',
- 'utils.h',
- )
+ 'base.h',
+ 'bios.h',
+ 'bios_table.h',
+ 'compiler.h',
+ 'entity.h',
+ 'firmware_update.h',
+ 'fru.h',
+ 'instance-id.h',
+ 'pdr.h',
+ 'platform.h',
+ 'pldm.h',
+ 'pldm_types.h',
+ 'state_set.h',
+ 'states.h',
+ 'transport.h',
+ 'transport/af-mctp.h',
+ 'transport/mctp-demux.h',
+ 'utils.h',
+)
if get_option('oem-ibm').allowed()
- libpldm_headers += files(
- 'oem/ibm/entity.h',
- 'oem/ibm/file_io.h',
- 'oem/ibm/fru.h',
- 'oem/ibm/host.h',
- 'oem/ibm/platform.h',
- 'oem/ibm/state_set.h'
- )
+ libpldm_headers += files(
+ 'oem/ibm/entity.h',
+ 'oem/ibm/file_io.h',
+ 'oem/ibm/fru.h',
+ 'oem/ibm/host.h',
+ 'oem/ibm/platform.h',
+ 'oem/ibm/state_set.h',
+ )
endif
if get_option('oem-meta').allowed()
- libpldm_headers += files(
- 'oem/meta/file_io.h',
- )
+ libpldm_headers += files('oem/meta/file_io.h')
endif
diff --git a/meson.build b/meson.build
index d9720ca..40f8207 100644
--- a/meson.build
+++ b/meson.build
@@ -1,20 +1,22 @@
-project('libpldm', 'c',
+project(
+ 'libpldm',
+ 'c',
default_options: [
- 'debug=true',
- 'optimization=g',
- 'warning_level=3',
- 'werror=true',
- 'cpp_std=c++23',
- 'c_std=c17',
- 'b_ndebug=if-release',
- 'tests=' + (meson.is_subproject() ? 'disabled' : 'enabled'),
+ 'debug=true',
+ 'optimization=g',
+ 'warning_level=3',
+ 'werror=true',
+ 'cpp_std=c++23',
+ 'c_std=c17',
+ 'b_ndebug=if-release',
+ 'tests=' + (meson.is_subproject() ? 'disabled' : 'enabled'),
],
version: '0.9.0',
meson_version: '>=1.1.1',
)
if get_option('tests').allowed()
- add_languages('cpp')
+ add_languages('cpp')
endif
# For memmem() in src/msgbuf.h
@@ -23,49 +25,92 @@
compiler = meson.get_compiler('c')
conf = configuration_data()
if compiler.has_header('poll.h')
- conf.set('PLDM_HAS_POLL', 1)
+ conf.set('PLDM_HAS_POLL', 1)
endif
# ABI control
-visible = '__attribute__((visibility("default")))'
+visible = '__attribute__((visibility("default")))'
libpldm_deprecated_aliases = []
if get_option('abi').contains('deprecated')
- conf.set('LIBPLDM_ABI_DEPRECATED', visible)
- add_project_arguments('-DLIBPLDM_API_DEPRECATED', language: ['c', 'cpp'])
- libpldm_deprecated_aliases += [
- ['get_fru_record_by_option_check', 'get_fru_record_by_option'],
- ['pldm_bios_table_append_pad_checksum_check', 'pldm_bios_table_append_pad_checksum'],
- ['pldm_bios_table_attr_entry_enum_decode_def_num_check', 'pldm_bios_table_attr_entry_enum_decode_def_num'],
- ['pldm_bios_table_attr_entry_enum_decode_pv_hdls_check', 'pldm_bios_table_attr_entry_enum_decode_pv_hdls'],
- ['pldm_bios_table_attr_entry_enum_decode_pv_num_check', 'pldm_bios_table_attr_entry_enum_decode_pv_num'],
- ['pldm_bios_table_attr_entry_enum_encode_check', 'pldm_bios_table_attr_entry_enum_encode'],
- ['pldm_bios_table_attr_entry_integer_encode_check', 'pldm_bios_table_attr_entry_integer_encode'],
- ['pldm_bios_table_attr_entry_string_decode_def_string_length_check', 'pldm_bios_table_attr_entry_string_decode_def_string_length'],
- ['pldm_bios_table_attr_entry_string_encode_check', 'pldm_bios_table_attr_entry_string_encode'],
- ['pldm_bios_table_attr_value_entry_encode_enum_check', 'pldm_bios_table_attr_value_entry_encode_enum'],
- ['pldm_bios_table_attr_value_entry_encode_integer_check', 'pldm_bios_table_attr_value_entry_encode_integer'],
- ['pldm_bios_table_attr_value_entry_encode_string_check', 'pldm_bios_table_attr_value_entry_encode_string'],
- ['pldm_bios_table_string_entry_decode_string_check', 'pldm_bios_table_string_entry_decode_string'],
- ['pldm_bios_table_string_entry_encode_check', 'pldm_bios_table_string_entry_encode'],
- ['pldm_entity_association_pdr_add_check', 'pldm_entity_association_pdr_add'],
- ['pldm_entity_association_pdr_add_from_node_check', 'pldm_entity_association_pdr_add_from_node'],
- ['pldm_pdr_add_check', 'pldm_pdr_add'],
- ['pldm_pdr_add_fru_record_set_check', 'pldm_pdr_add_fru_record_set'],
- ]
+ conf.set('LIBPLDM_ABI_DEPRECATED', visible)
+ add_project_arguments('-DLIBPLDM_API_DEPRECATED', language: ['c', 'cpp'])
+ libpldm_deprecated_aliases += [
+ ['get_fru_record_by_option_check', 'get_fru_record_by_option'],
+ [
+ 'pldm_bios_table_append_pad_checksum_check',
+ 'pldm_bios_table_append_pad_checksum',
+ ],
+ [
+ 'pldm_bios_table_attr_entry_enum_decode_def_num_check',
+ 'pldm_bios_table_attr_entry_enum_decode_def_num',
+ ],
+ [
+ 'pldm_bios_table_attr_entry_enum_decode_pv_hdls_check',
+ 'pldm_bios_table_attr_entry_enum_decode_pv_hdls',
+ ],
+ [
+ 'pldm_bios_table_attr_entry_enum_decode_pv_num_check',
+ 'pldm_bios_table_attr_entry_enum_decode_pv_num',
+ ],
+ [
+ 'pldm_bios_table_attr_entry_enum_encode_check',
+ 'pldm_bios_table_attr_entry_enum_encode',
+ ],
+ [
+ 'pldm_bios_table_attr_entry_integer_encode_check',
+ 'pldm_bios_table_attr_entry_integer_encode',
+ ],
+ [
+ 'pldm_bios_table_attr_entry_string_decode_def_string_length_check',
+ 'pldm_bios_table_attr_entry_string_decode_def_string_length',
+ ],
+ [
+ 'pldm_bios_table_attr_entry_string_encode_check',
+ 'pldm_bios_table_attr_entry_string_encode',
+ ],
+ [
+ 'pldm_bios_table_attr_value_entry_encode_enum_check',
+ 'pldm_bios_table_attr_value_entry_encode_enum',
+ ],
+ [
+ 'pldm_bios_table_attr_value_entry_encode_integer_check',
+ 'pldm_bios_table_attr_value_entry_encode_integer',
+ ],
+ [
+ 'pldm_bios_table_attr_value_entry_encode_string_check',
+ 'pldm_bios_table_attr_value_entry_encode_string',
+ ],
+ [
+ 'pldm_bios_table_string_entry_decode_string_check',
+ 'pldm_bios_table_string_entry_decode_string',
+ ],
+ [
+ 'pldm_bios_table_string_entry_encode_check',
+ 'pldm_bios_table_string_entry_encode',
+ ],
+ [
+ 'pldm_entity_association_pdr_add_check',
+ 'pldm_entity_association_pdr_add',
+ ],
+ [
+ 'pldm_entity_association_pdr_add_from_node_check',
+ 'pldm_entity_association_pdr_add_from_node',
+ ],
+ ['pldm_pdr_add_check', 'pldm_pdr_add'],
+ ['pldm_pdr_add_fru_record_set_check', 'pldm_pdr_add_fru_record_set'],
+ ]
else
- conf.set('LIBPLDM_ABI_DEPRECATED', '')
+ conf.set('LIBPLDM_ABI_DEPRECATED', '')
endif
-conf.set('LIBPLDM_ABI_STABLE', visible) # Always expose the stable symbols
+conf.set('LIBPLDM_ABI_STABLE', visible) # Always expose the stable symbols
if get_option('abi').contains('testing')
- conf.set('LIBPLDM_ABI_TESTING', visible)
- add_project_arguments('-DLIBPLDM_API_TESTING', language: ['c', 'cpp'])
+ conf.set('LIBPLDM_ABI_TESTING', visible)
+ add_project_arguments('-DLIBPLDM_API_TESTING', language: ['c', 'cpp'])
else
- conf.set('LIBPLDM_ABI_TESTING', '')
+ conf.set('LIBPLDM_ABI_TESTING', '')
endif
-config = configure_file(output: 'config.h',
- configuration: conf
-)
+config = configure_file(output: 'config.h', configuration: conf)
add_project_arguments('-include', '@0@'.format(config), language: 'c')
@@ -75,9 +120,11 @@
subdir('src')
if get_option('tests').allowed()
- subdir('tests')
+ subdir('tests')
endif
-install_subdir('instance-db',
- install_mode: 'r--r--r--',
- install_dir: get_option('datadir') / meson.project_name())
+install_subdir(
+ 'instance-db',
+ install_mode: 'r--r--r--',
+ install_dir: get_option('datadir') / meson.project_name(),
+)
diff --git a/scripts/pre-submit b/scripts/pre-submit
index a06accf..69f76e1 100755
--- a/scripts/pre-submit
+++ b/scripts/pre-submit
@@ -4,6 +4,9 @@
BUILD="$(mktemp --directory --tmpdir=.)"
trap 'rm -rf "$BUILD"' EXIT
+meson format --recursive --inplace || true
+git diff --quiet
+
# Ensure the test suite passes in the default configuration. Note
# that we don't specify -Dabi=... - the default is equivalent to
# -Dabi=deprecated,stable,testing.
diff --git a/src/dsp/meson.build b/src/dsp/meson.build
index 39f4db8..b81e533 100644
--- a/src/dsp/meson.build
+++ b/src/dsp/meson.build
@@ -1,9 +1,9 @@
libpldm_sources += files(
- 'base.c',
- 'bios.c',
- 'bios_table.c',
- 'firmware_update.c',
- 'fru.c',
- 'pdr.c',
- 'platform.c',
+ 'base.c',
+ 'bios.c',
+ 'bios_table.c',
+ 'firmware_update.c',
+ 'fru.c',
+ 'pdr.c',
+ 'platform.c',
)
diff --git a/src/meson.build b/src/meson.build
index 5242eed..a4c8609 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,95 +1,105 @@
-libpldm_sources = files(
- 'responder.c',
- 'utils.c'
-)
+libpldm_sources = files('responder.c', 'utils.c')
subdir('dsp')
subdir('requester')
subdir('transport')
if get_option('oem-ibm').allowed()
- subdir('oem/ibm')
+ subdir('oem/ibm')
endif
if get_option('oem-meta').allowed()
- subdir('oem/meta')
+ subdir('oem/meta')
endif
libpldm_link_args = []
foreach alias : libpldm_deprecated_aliases
- libpldm_link_args += '-Wl,--defsym=@0@=@1@'.format(alias[0], alias[1])
+ libpldm_link_args += '-Wl,--defsym=@0@=@1@'.format(alias[0], alias[1])
endforeach
libpldm = library(
- 'pldm',
- libpldm_sources,
- implicit_include_directories: false,
- include_directories: [
- libpldm_include_dir,
- include_directories('.')
- ],
- link_args: libpldm_link_args,
- version: meson.project_version(),
- gnu_symbol_visibility: 'hidden',
- install: true
- )
+ 'pldm',
+ libpldm_sources,
+ implicit_include_directories: false,
+ include_directories: [libpldm_include_dir, include_directories('.')],
+ link_args: libpldm_link_args,
+ version: meson.project_version(),
+ gnu_symbol_visibility: 'hidden',
+ install: true,
+)
libpldm_dep = declare_dependency(
- include_directories: libpldm_include_dir,
- link_with: libpldm)
+ include_directories: libpldm_include_dir,
+ link_with: libpldm,
+)
import('pkgconfig').generate(
- name: 'libpldm',
- description: 'PLDM protocol encode/decode C lib',
- version: meson.project_version(),
- libraries: libpldm)
+ name: 'libpldm',
+ description: 'PLDM protocol encode/decode C lib',
+ version: meson.project_version(),
+ libraries: libpldm,
+)
if get_option('tests').allowed()
- c_suite = meson.get_compiler('c').get_id()
- cpp_suite = meson.get_compiler('cpp').get_id()
+ c_suite = meson.get_compiler('c').get_id()
+ cpp_suite = meson.get_compiler('cpp').get_id()
- if get_option('abi-compliance-check').allowed() and c_suite == cpp_suite and c_suite == 'gcc'
- host = host_machine.cpu_family()
- baseline_dump = meson.project_source_root() / 'abi' / host / '@0@.dump'.format(c_suite)
+ if get_option('abi-compliance-check').allowed() and c_suite == cpp_suite and c_suite == 'gcc'
+ host = host_machine.cpu_family()
+ baseline_dump = meson.project_source_root() / 'abi' / host / '@0@.dump'.format(
+ c_suite,
+ )
- abi_dumper = find_program('abi-dumper',
- native: true,
- required: get_option('abi-compliance-check'))
- abi_compliance_checker = find_program('abi-compliance-checker',
- native: true,
- required: get_option('abi-compliance-check'))
+ abi_dumper = find_program(
+ 'abi-dumper',
+ native: true,
+ required: get_option('abi-compliance-check'),
+ )
+ abi_compliance_checker = find_program(
+ 'abi-compliance-checker',
+ native: true,
+ required: get_option('abi-compliance-check'),
+ )
- test_abi_compliance = abi_dumper.found() and \
- abi_compliance_checker.found() and \
- import('fs').is_file(baseline_dump)
+ test_abi_compliance = abi_dumper.found() and\
+abi_compliance_checker.found() and\
+import('fs').is_file(baseline_dump)
- if test_abi_compliance
- current_dump = custom_target('abi-dump',
- input: libpldm,
- output: 'current.dump',
- command: [ abi_dumper,
- '-mixed-headers',
- '-include-paths',
- meson.project_source_root() / 'src',
- '-public-headers',
- meson.project_source_root() / 'include',
- '-sort',
- '@INPUT@',
- '-o',
- '@OUTPUT@',
- '-lver',
- meson.project_version()])
- abi_compliance = custom_target('abi-compliance',
- input: [baseline_dump, current_dump],
- output: 'abi-compliance',
- command: [ abi_compliance_checker,
- '-l',
- meson.project_name(),
- '-old',
- '@INPUT0@',
- '-new',
- '@INPUT1@' ],
- build_by_default: true)
+ if test_abi_compliance
+ current_dump = custom_target(
+ 'abi-dump',
+ input: libpldm,
+ output: 'current.dump',
+ command: [
+ abi_dumper,
+ '-mixed-headers',
+ '-include-paths',
+ meson.project_source_root() / 'src',
+ '-public-headers',
+ meson.project_source_root() / 'include',
+ '-sort',
+ '@INPUT@',
+ '-o',
+ '@OUTPUT@',
+ '-lver',
+ meson.project_version(),
+ ],
+ )
+ abi_compliance = custom_target(
+ 'abi-compliance',
+ input: [baseline_dump, current_dump],
+ output: 'abi-compliance',
+ command: [
+ abi_compliance_checker,
+ '-l',
+ meson.project_name(),
+ '-old',
+ '@INPUT0@',
+ '-new',
+ '@INPUT1@',
+ ],
+ build_by_default: true,
+ )
+ endif
endif
- endif
endif
diff --git a/src/oem/ibm/meson.build b/src/oem/ibm/meson.build
index 04bb24f..cc52f1e 100644
--- a/src/oem/ibm/meson.build
+++ b/src/oem/ibm/meson.build
@@ -1,5 +1 @@
-libpldm_sources += files(
- 'file_io.c',
- 'host.c',
- 'platform.c'
- )
+libpldm_sources += files('file_io.c', 'host.c', 'platform.c')
diff --git a/src/oem/meta/meson.build b/src/oem/meta/meson.build
index 6c89286..c618ac7 100644
--- a/src/oem/meta/meson.build
+++ b/src/oem/meta/meson.build
@@ -1,3 +1 @@
-libpldm_sources += files(
- 'file_io.c'
- )
+libpldm_sources += files('file_io.c')
diff --git a/src/requester/meson.build b/src/requester/meson.build
index 663b607..77945f9 100644
--- a/src/requester/meson.build
+++ b/src/requester/meson.build
@@ -1,4 +1 @@
-libpldm_sources += files(
- 'instance-id.c',
- 'pldm.c'
- )
+libpldm_sources += files('instance-id.c', 'pldm.c')
diff --git a/src/transport/meson.build b/src/transport/meson.build
index b0ef1ca..adc1300 100644
--- a/src/transport/meson.build
+++ b/src/transport/meson.build
@@ -1,7 +1,2 @@
-libpldm_sources += files(
- 'af-mctp.c',
- 'mctp-demux.c',
- 'socket.c',
- 'transport.c',
- 'test.c'
-)
+libpldm_sources += files('af-mctp.c', 'mctp-demux.c', 'socket.c', 'test.c'
+, 'transport.c')
diff --git a/tests/dsp/meson.build b/tests/dsp/meson.build
index c457260..dd2b5b0 100644
--- a/tests/dsp/meson.build
+++ b/tests/dsp/meson.build
@@ -1,15 +1,19 @@
tests += [
- 'dsp/base',
- 'dsp/bios_table',
- 'dsp/bios',
- 'dsp/firmware_update',
- 'dsp/fru',
- 'dsp/pdr',
- 'dsp/platform',
+ 'dsp/base',
+ 'dsp/bios_table',
+ 'dsp/bios',
+ 'dsp/firmware_update',
+ 'dsp/fru',
+ 'dsp/pdr',
+ 'dsp/platform',
]
-test('dsp/bios_table_iter',
- executable('bios_table_iter',
- 'bios_table_iter.c',
- implicit_include_directories: false,
- include_directories: test_include_dirs))
+test(
+ 'dsp/bios_table_iter',
+ executable(
+ 'bios_table_iter',
+ 'bios_table_iter.c',
+ implicit_include_directories: false,
+ include_directories: test_include_dirs,
+ ),
+)
diff --git a/tests/meson.build b/tests/meson.build
index 0a2e811..a32cf8d 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -3,52 +3,55 @@
if not gtest_dep.found() or not gmock_dep.found()
gtest_proj = import('cmake').subproject('googletest', required: true)
gtest_dep = declare_dependency(
- dependencies: [
- dependency('threads'),
- gtest_proj.dependency('gtest'),
- gtest_proj.dependency('gtest_main'),
- ]
- )
- gmock_dep = gtest_proj.dependency('gmock')
+ dependencies: [
+ dependency('threads'),
+ gtest_proj.dependency('gtest'),
+ gtest_proj.dependency('gtest_main'),
+ ],
+ )
+ gmock_dep = gtest_proj.dependency('gmock')
endif
-test_include_dirs = [ libpldm_include_dir, include_directories('../src') ]
+test_include_dirs = [libpldm_include_dir, include_directories('../src')]
-tests = [
- 'instance-id',
- 'msgbuf',
- 'responder',
- 'utils',
-]
+tests = ['instance-id', 'msgbuf', 'responder', 'utils']
subdir('dsp')
# The 'test' transport APIs will never be marked stable as they are just for
# testing.
if get_option('abi').contains('testing')
- subdir('transport')
+ subdir('transport')
endif
if get_option('oem-ibm').allowed()
- subdir('oem/ibm')
+ subdir('oem/ibm')
endif
if get_option('oem-meta').allowed()
- subdir('oem/meta')
+ subdir('oem/meta')
endif
foreach t : tests
- test(t, executable(t.underscorify(), t + '.cpp',
- implicit_include_directories: false,
- include_directories: test_include_dirs,
- dependencies: [
- libpldm_dep,
- gtest_dep,
- gmock_dep]),
- workdir: meson.current_source_dir())
+ test(
+ t,
+ executable(
+ t.underscorify(),
+ t + '.cpp',
+ implicit_include_directories: false,
+ include_directories: test_include_dirs,
+ dependencies: [libpldm_dep, gtest_dep, gmock_dep],
+ ),
+ workdir: meson.current_source_dir(),
+ )
endforeach
-test('msgbuf_generic', executable('msgbuf_generic',
- 'msgbuf_generic.c',
- implicit_include_directories: false,
- include_directories: test_include_dirs))
+test(
+ 'msgbuf_generic',
+ executable(
+ 'msgbuf_generic',
+ 'msgbuf_generic.c',
+ implicit_include_directories: false,
+ include_directories: test_include_dirs,
+ ),
+)
diff --git a/tests/oem/ibm/meson.build b/tests/oem/ibm/meson.build
index 389f83b..c38b644 100644
--- a/tests/oem/ibm/meson.build
+++ b/tests/oem/ibm/meson.build
@@ -1,4 +1 @@
-tests += [
- 'oem/ibm/fileio',
- 'oem/ibm/host',
-]
+tests += ['oem/ibm/fileio', 'oem/ibm/host']
diff --git a/tests/oem/meta/meson.build b/tests/oem/meta/meson.build
index 03c33f5..fc9d183 100644
--- a/tests/oem/meta/meson.build
+++ b/tests/oem/meta/meson.build
@@ -1,3 +1 @@
-tests += [
- 'oem/meta/fileio',
-]
+tests += ['oem/meta/fileio']
diff --git a/tests/transport/meson.build b/tests/transport/meson.build
index d4c27ee..6fb2b98 100644
--- a/tests/transport/meson.build
+++ b/tests/transport/meson.build
@@ -1,8 +1,8 @@
tests += [
- 'transport/transport',
- 'transport/send_recv_one',
- 'transport/send_recv_timeout',
- 'transport/send_recv_unwanted',
- 'transport/send_recv_wrong_command_code',
- 'transport/send_recv_wrong_pldm_type',
+ 'transport/transport',
+ 'transport/send_recv_one',
+ 'transport/send_recv_timeout',
+ 'transport/send_recv_unwanted',
+ 'transport/send_recv_wrong_command_code',
+ 'transport/send_recv_wrong_pldm_type',
]