Add meson build support
Tested:
1. Project builds with each meson option turned on or off.
2. Unit tests build and pass.
3. On platform FW built with updated recipe
(I23fabdf57b8d6ac35c3aea0ece667be118de4b61):
a. SMBIOS blob store library is properly picked up by IPMI blob
store manager and handles OEM IPMI commands.
b. smbiosmdrv2app is running and populates objects on D-Bus.
c. cpuinfoapp is running and populates objects on D-Bus.
Change-Id: Ie65b281900cc07e7d0145445bcc65bbab1979214
Signed-off-by: Jonathan Doman <jonathan.doman@intel.com>
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..327ea97
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+/build*/
+/subprojects/*/
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..1a99644
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,27 @@
+project(
+ 'smbios-mdr',
+ 'cpp',
+ version: '0.1',
+ meson_version: '>=1.1.1',
+ default_options: [
+ 'cpp_std=c++23',
+ 'warning_level=3',
+ 'werror=true',
+ 'cpp_rtti=false'
+ ])
+
+boost_args = [
+ '-DBOOST_ALL_NO_LIB',
+ '-DBOOST_ASIO_DISABLE_THREADS',
+]
+
+root_inc = include_directories('include')
+
+boost_dep = dependency('boost')
+
+sdbusplus_dep = dependency('sdbusplus')
+phosphor_dbus_interfaces_dep= dependency('phosphor-dbus-interfaces')
+phosphor_logging_dep = dependency('phosphor-logging')
+
+subdir('src')
+subdir('service_files')
diff --git a/meson.options b/meson.options
new file mode 100644
index 0000000..8072041
--- /dev/null
+++ b/meson.options
@@ -0,0 +1,34 @@
+option(
+ 'tests',
+ type: 'feature',
+ value: 'disabled',
+ description: 'Build tests'
+)
+
+option(
+ 'dimm-dbus',
+ type: 'feature',
+ value: 'enabled',
+ description: 'Expose DIMM D-Bus Interface'
+)
+
+option(
+ 'dimm-only-locator',
+ type: 'feature',
+ value: 'disabled',
+ description: 'Only use the DIMM number, and not the bank'
+)
+
+option(
+ 'cpuinfo',
+ type: 'feature',
+ value: 'enabled',
+ description: 'Build CPUInfo service'
+)
+
+option(
+ 'smbios-ipmi-blob',
+ type: 'feature',
+ value: 'enabled',
+ description: 'Build IPMI blob library for SMBIOS transfer'
+)
diff --git a/service_files/meson.build b/service_files/meson.build
new file mode 100644
index 0000000..30a59a9
--- /dev/null
+++ b/service_files/meson.build
@@ -0,0 +1,17 @@
+# Map of unit file to meson option which controls whether file gets installed
+unit_files = [
+ ['smbios-mdrv2.service', ''],
+ ['xyz.openbmc_project.cpuinfo.service', 'cpuinfo'],
+]
+
+systemd_dep = dependency('systemd')
+systemd_system_unitdir = systemd_dep.get_variable(
+ 'systemd_system_unit_dir',
+ pkgconfig_define: ['rootprefix', get_option('prefix')]
+ )
+
+foreach u : unit_files
+ if u[1] == '' or get_option(u[1]).allowed()
+ install_data(u[0], install_dir: systemd_system_unitdir)
+ endif
+endforeach
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..4a54d28
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,60 @@
+cpp_args_smbios = boost_args
+if get_option('dimm-dbus').allowed()
+ cpp_args_smbios += ['-DDIMM_DBUS']
+endif
+
+if get_option('dimm-only-locator').allowed()
+ cpp_args_smbios += ['-DDIMM_ONLY_LOCATOR']
+endif
+
+executable(
+ 'smbiosmdrv2app',
+ 'mdrv2.cpp',
+ 'mdrv2_main.cpp',
+ 'cpu.cpp',
+ 'dimm.cpp',
+ 'system.cpp',
+ 'pcieslot.cpp',
+ cpp_args: cpp_args_smbios,
+ dependencies: [
+ boost_dep,
+ sdbusplus_dep,
+ phosphor_logging_dep,
+ phosphor_dbus_interfaces_dep,
+ ],
+ implicit_include_directories: false,
+ include_directories: root_inc,
+ install: true,
+)
+
+if get_option('cpuinfo').allowed()
+ cpp = meson.get_compiler('cpp')
+ # i2c-tools provides no pkgconfig so we need to find it manually
+ i2c_dep = cpp.find_library('i2c')
+
+ peci_dep = dependency('libpeci')
+
+ executable(
+ 'cpuinfoapp',
+ 'cpuinfo_main.cpp',
+ 'speed_select.cpp',
+ 'sst_mailbox.cpp',
+ 'cpuinfo_utils.cpp',
+ cpp_args: boost_args,
+ dependencies: [
+ boost_dep,
+ sdbusplus_dep,
+ phosphor_logging_dep,
+ phosphor_dbus_interfaces_dep,
+ i2c_dep,
+ peci_dep,
+ ],
+ implicit_include_directories: false,
+ include_directories: root_inc,
+ install: true,
+ )
+endif
+
+if get_option('smbios-ipmi-blob').allowed()
+ subdir('smbios-ipmi-blobs')
+endif
diff --git a/src/smbios-ipmi-blobs/meson.build b/src/smbios-ipmi-blobs/meson.build
new file mode 100644
index 0000000..62d1d4f
--- /dev/null
+++ b/src/smbios-ipmi-blobs/meson.build
@@ -0,0 +1,21 @@
+ipmi_blob_dep = dependency('phosphor-ipmi-blobs')
+libipmid_dep = dependency('libipmid').partial_dependency(includes: true)
+
+smbiosstore_common_deps = [ipmi_blob_dep, libipmid_dep, sdbusplus_dep]
+
+shared_module(
+ 'smbiosstore',
+ 'main.cpp',
+ 'handler.cpp',
+ dependencies: [
+ smbiosstore_common_deps,
+ phosphor_logging_dep,
+ ],
+ include_directories: root_inc,
+ install: true,
+ install_dir: get_option('libdir') / 'blob-ipmid'
+ )
+
+if get_option('tests').allowed()
+ subdir('test')
+endif
diff --git a/src/smbios-ipmi-blobs/test/meson.build b/src/smbios-ipmi-blobs/test/meson.build
new file mode 100644
index 0000000..6e2c28e
--- /dev/null
+++ b/src/smbios-ipmi-blobs/test/meson.build
@@ -0,0 +1,27 @@
+gtest = dependency('gtest', main: true)
+gmock = dependency('gmock')
+
+tests = [
+ 'handler_unittest',
+ 'handler_open_unittest',
+ 'handler_readwrite_unittest',
+ 'handler_statclose_unittest',
+]
+
+foreach t : tests
+ test(
+ t,
+ executable(
+ t.underscorify(),
+ t + '.cpp',
+ '../handler.cpp',
+ include_directories: ['../', root_inc],
+ dependencies: [
+ smbiosstore_common_deps,
+ gtest,
+ gmock
+ ]
+ ),
+ protocol: 'gtest'
+ )
+endforeach
diff --git a/subprojects/libpeci.wrap b/subprojects/libpeci.wrap
new file mode 100644
index 0000000..521591b
--- /dev/null
+++ b/subprojects/libpeci.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/openbmc/libpeci.git
+revision = HEAD
+
+[provide]
+libpeci = libpeci_dep
diff --git a/subprojects/phosphor-dbus-interfaces.wrap b/subprojects/phosphor-dbus-interfaces.wrap
new file mode 100644
index 0000000..346aa0c
--- /dev/null
+++ b/subprojects/phosphor-dbus-interfaces.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/openbmc/phosphor-dbus-interfaces.git
+revision = HEAD
+
+[provide]
+phosphor-dbus-interfaces = phosphor_dbus_interfaces_dep
diff --git a/subprojects/phosphor-host-ipmid.wrap b/subprojects/phosphor-host-ipmid.wrap
new file mode 100644
index 0000000..55261f6
--- /dev/null
+++ b/subprojects/phosphor-host-ipmid.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/openbmc/phosphor-host-ipmid.git
+revision = HEAD
+
+[provide]
+libipmid = ipmid_dep
diff --git a/subprojects/phosphor-ipmi-blobs.wrap b/subprojects/phosphor-ipmi-blobs.wrap
new file mode 100644
index 0000000..5de0e0a
--- /dev/null
+++ b/subprojects/phosphor-ipmi-blobs.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/openbmc/phosphor-ipmi-blobs.git
+revision = HEAD
+
+[provide]
+phosphor-ipmi-blobs = ipmi_blob_dep
diff --git a/subprojects/phosphor-logging.wrap b/subprojects/phosphor-logging.wrap
new file mode 100644
index 0000000..71eee8b
--- /dev/null
+++ b/subprojects/phosphor-logging.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/openbmc/phosphor-logging.git
+revision = HEAD
+
+[provide]
+phosphor-logging = phosphor_logging_dep
diff --git a/subprojects/sdbusplus.wrap b/subprojects/sdbusplus.wrap
new file mode 100644
index 0000000..7b076d0
--- /dev/null
+++ b/subprojects/sdbusplus.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/openbmc/sdbusplus.git
+revision = HEAD
+
+[provide]
+sdbusplus = sdbusplus_dep