Add support for building with meson
Follow the OpenBMC herd and support a modern, comprehensible build
framework.
To build with meson:
meson build
ninja -C build
Add -Dtests to match de-facto OpenBMC meson usage conventions.
After this patch existing unit tests continue to pass.
One noteable omission is support for subprojects or vendoring. Cmake
support, with subproject vendoring remains.
The OpenBMC CI scripts look for meson.build before looking for
CMakelists so approval of this patch would change the build system
during CI to meson.
Change-Id: I3d08e37d8c39ed2eecc4245671fb84ce6e3bc279
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..076d00f
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,101 @@
+project(
+ 'entity-manager',
+ 'cpp',
+ default_options: [
+ 'warning_level=3',
+ 'werror=true',
+ 'cpp_std=c++17'
+ ],
+ license: 'Apache-2.0',
+ version: '0.1',
+)
+
+boost_args = [
+ '-DBOOST_SYSTEM_NO_DEPRECATED',
+ '-DBOOST_ERROR_CODE_HEADER_ONLY',
+ '-DBOOST_NO_RTTI',
+ '-DBOOST_NO_TYPEID',
+ '-DBOOST_ALL_NO_LIB',
+]
+build_tests = get_option('tests')
+boost = dependency('boost')
+i2c = meson.get_compiler('cpp').find_library('i2c')
+sdbusplus = dependency('sdbusplus')
+systemd = dependency('systemd')
+systemd_system_unit_dir = systemd.get_pkgconfig_variable(
+ 'systemdsystemunitdir',
+ define_variable: ['prefix', get_option('prefix')])
+packagedir = join_paths(
+ get_option('prefix'),
+ get_option('datadir'),
+ meson.project_name(),
+)
+threads = dependency('threads')
+
+install_data('blacklist.json')
+
+configs = [
+ '1Ux16 Riser.json',
+ '2Ux8 Riser.json',
+ '8X25 HSBP.json',
+ 'A2UL16RISER.json',
+ 'A2UX8X4RISER.json',
+ 'AHW1UM2RISER.json',
+ 'AXX1P100HSSI_AIC.json',
+ 'AXX2PRTHDHD.json',
+ 'BNP Baseboard.json',
+ 'Delta DPS-750XB PSU.json',
+ 'F1U12X25 HSBP.json',
+ 'F1U4X25 HSBP.json',
+ 'F2U12X35 HSBP.json',
+ 'F2U8X25 HSBP.json',
+ 'FBTP.json',
+ 'FBYV2.json',
+ 'Flextronics S-1100ADU00-201 PSU.json',
+ 'Intel Front Panel.json',
+ 'NVME P4000.json',
+ 'PCIE SSD Retimer.json',
+ 'PSSF132202A.json',
+ 'PSSF162205A.json',
+ 'PSSF212201A.json',
+ 'PSSF222201A.json',
+ 'R1000 Chassis.json',
+ 'R2000 Chassis.json',
+ 'SAS Module.json',
+ 'SOLUM_PSSF162202_PSU.json',
+ 'STP Baseboard.json',
+ 'STP P4000 Chassis.json',
+ 'WFT Baseboard.json',
+]
+
+foreach c : configs
+ install_data(
+ join_paths('configurations', c),
+ install_dir: join_paths(
+ packagedir,
+ 'configurations',
+ )
+ )
+endforeach
+
+schemas = [
+ 'global.json',
+ 'Pid.json',
+ 'Pid.Zone.json',
+ 'Stepwise.json',
+]
+
+foreach s : schemas
+ install_data(
+ join_paths('schemas', s),
+ install_dir: join_paths(
+ packagedir,
+ 'configurations',
+ 'schemas',
+ )
+ )
+endforeach
+
+subdir('service_files')
+subdir('src')
+subdir('test')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..b7869f4
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,3 @@
+option(
+ 'tests', type: 'feature', description: 'Build tests.',
+)
diff --git a/service_files/meson.build b/service_files/meson.build
new file mode 100644
index 0000000..2f1932d
--- /dev/null
+++ b/service_files/meson.build
@@ -0,0 +1,14 @@
+unit_files = [
+ 'xyz.openbmc_project.FruDevice.service',
+ 'xyz.openbmc_project.EntityManager.service',
+]
+
+foreach u : unit_files
+ configure_file(
+ copy: true,
+ input: u,
+ install: true,
+ install_dir: systemd_system_unit_dir,
+ output: u,
+ )
+endforeach
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..ea446fc
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,32 @@
+cpp_args = boost_args + ['-DPACKAGE_DIR="' + packagedir + '/"']
+
+executable(
+ 'entity-manager',
+ 'EntityManager.cpp',
+ 'Overlay.cpp',
+ 'Utils.cpp',
+ cpp_args: cpp_args + ['-DBOOST_ASIO_DISABLE_THREADS'],
+ dependencies: [
+ boost,
+ sdbusplus,
+ ],
+ implicit_include_directories: false,
+ include_directories: '../include',
+ install: true,
+)
+
+executable(
+ 'fru-device',
+ 'FruDevice.cpp',
+ 'Utils.cpp',
+ cpp_args: cpp_args,
+ dependencies: [
+ boost,
+ i2c,
+ sdbusplus,
+ threads,
+ ],
+ implicit_include_directories: false,
+ include_directories: '../include',
+ install: true,
+)
diff --git a/test/meson.build b/test/meson.build
new file mode 100644
index 0000000..2785306
--- /dev/null
+++ b/test/meson.build
@@ -0,0 +1,18 @@
+gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
+
+test(
+ 'test_entity_manager',
+ executable(
+ 'test_entity_manager',
+ 'test_entity-manager.cpp',
+ '../src/Utils.cpp',
+ cpp_args: boost_args + ['-DBOOST_ASIO_DISABLE_THREADS'],
+ dependencies: [
+ boost,
+ gtest,
+ sdbusplus,
+ ],
+ implicit_include_directories: false,
+ include_directories: '../include',
+ )
+)