build: Add meson build
Changes to note,
- `with_systemdsystemunitdir` and `with_tmpfilesdir` is removed since it
is not being documented nor used in OpenBMC.
- Removed the Code coverage feature with `-DDHAVE_GCOV`, since it is not
used and meson covers it.
- Removed `--enable-oe-sdk` for using the OpenBMC SDK. It should work
directly with no change required.
Tested:
```
Jan 01 00:01:54 ipmid[709]: Try loading blob from persistent data
Jan 01 00:01:54 ipmid[709]: Stale blob data, resetting internals...
Jan 01 00:01:56 ipmid[709]: config loaded: /flash/bios
Jan 01 00:01:56 ipmid[709]: config loaded: /flash/image
Jan 01 00:01:56 ipmid[709]: config loaded: /flash/dummy
...
```
```
$ ls /usr/lib/blob-ipmid/
libfirmwareblob.so
libfirmwarecleanupblob.so libversionblob.so
```
Testing the service,
```
$ echo "hello" > /tmp/test.txt
$ burn_my_bmc -command update -layout dummy -image /tmp/test.txt
Sending over the firmware image.
Opening the verification file
Committing to /flash/verify to trigger service
Calling stat on /flash/verify session to check status
running
success
Returned success
succeeded
```
On the BMC.
```
/run/initramfs$ cat dummy
hello
```
Change-Id: I21c7c33bd62c0ee40681cb40da90125c125bea2f
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..0246aa2
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,169 @@
+project(
+ 'phosphor-ipmi-flash',
+ 'cpp',
+ version: '0.1',
+ meson_version: '>=0.57.0',
+ default_options: [
+ 'cpp_std=c++20',
+ 'warning_level=3',
+ 'werror=true',
+ ])
+
+root_inc = include_directories('.')
+
+# Setting up config data
+conf_data = configuration_data()
+conf_data.set_quoted('STATIC_HANDLER_STAGED_NAME', get_option('static-handler-staged-name'))
+conf_data.set_quoted('PREPARATION_DBUS_SERVICE', get_option('preparation-dbus-service'))
+conf_data.set_quoted('VERIFY_DBUS_SERVICE', get_option('verify-dbus-service'))
+conf_data.set_quoted('UPDATE_DBUS_SERVICE', get_option('update-dbus-service'))
+conf_data.set_quoted('BIOS_STAGED_NAME', get_option('bios-staged-name'))
+conf_data.set_quoted('PREPARATION_BIOS_TARGET', get_option('preparation-bios-target'))
+conf_data.set_quoted('VERIFY_BIOS_TARGET', get_option('verify-bios-target'))
+conf_data.set_quoted('UPDATE_BIOS_TARGET', get_option('update-bios-target'))
+
+conf_data.set_quoted('TARBALL_STAGED_NAME', get_option('tarball-staged-name'))
+conf_data.set_quoted('HASH_FILENAME', get_option('hash-filename'))
+conf_data.set_quoted('VERIFY_STATUS_FILENAME', get_option('verify-status-filename'))
+conf_data.set_quoted('UPDATE_STATUS_FILENAME', get_option('update-status-filename'))
+conf_data.set_quoted('BIOS_VERIFY_STATUS_FILENAME', get_option('bios-verify-status-filename'))
+conf_data.set('MAPPED_ADDRESS', get_option('mapped-address'))
+
+
+conf_h = configure_file(
+ output: 'config.h',
+ configuration: conf_data)
+
+# Setup for the test config
+if not get_option('tests').disabled()
+ add_project_arguments('-DENABLE_STATIC_LAYOUT', language: 'cpp')
+ add_project_arguments('-DENABLE_TARBALL_UBI', language: 'cpp')
+ add_project_arguments('-DASPEED_P2A', language: 'cpp')
+ add_project_arguments('-DENABLE_PCI_BRIDGE', language: 'cpp')
+ add_project_arguments('-DASPEED_LPC', language: 'cpp')
+ add_project_arguments('-DNUVOTON_LPC', language: 'cpp')
+ add_project_arguments('-DENABLE_LPC_BRIDGE', language: 'cpp')
+ add_project_arguments('-DENABLE_HOST_BIOS', language: 'cpp')
+endif
+
+if get_option('lpc-type') != 'none'
+ add_project_arguments('-DENABLE_LPC_BRIDGE', language: 'cpp')
+endif
+
+# Enable LPC and PCI for tests only.
+assert(
+ not get_option('tests').disabled() \
+ or get_option('lpc-type') == 'none' \
+ or get_option('p2a-type') == 'none',
+ 'Invalid configuration enabling both PCI and LPC.')
+
+if get_option('p2a-type') != 'none'
+ add_project_arguments('-DENABLE_PCI_BRIDGE', language: 'cpp')
+endif
+
+feature_map = {
+ 'host-bios' : '-DENABLE_HOST_BIOS',
+ 'ppc' : '-DENABLE_PPC',
+ 'reboot-update' : '-DENABLE_REBOOT_UPDATE',
+ 'update-status' : '-DENABLE_UPDATE_STATUS',
+ 'net-bridge' : '-DENABLE_NET_BRIDGE',
+}
+
+# Get the options status and build a project summary to show which flags are
+# being enabled during the configuration time.
+
+foreach option_key, option_value : feature_map
+ if get_option(option_key)
+ add_project_arguments(option_value, language: 'cpp')
+ summary(option_key, option_value, section : 'Enabled Features')
+ endif
+endforeach
+
+
+update_type_combo_map = {
+ 'static-layout' : '-DENABLE_STATIC_LAYOUT',
+ 'tarball-ubi' : '-DENABLE_TARBALL_UBI',
+}
+
+foreach option_key, option_value : update_type_combo_map
+ if get_option('update-type') == option_key
+ add_project_arguments(option_value, language: 'cpp')
+ summary(option_key, option_value, section : 'Enabled Firmware Update Features')
+ endif
+endforeach
+
+lpc_type_combo_map = {
+ 'aspeed-lpc' : '-DASPEED_LPC',
+ 'nuvoton-lpc' : '-DASPEED_LPC',
+}
+
+foreach option_key, option_value : lpc_type_combo_map
+ if get_option('lpc-type') == option_key
+ add_project_arguments(option_value, language: 'cpp')
+ summary(option_key, option_value, section : 'Enabled LPC Features')
+ endif
+endforeach
+
+pci_type_combo_map = {
+ 'aspeed-p2a' : '-DASPEED_P2A',
+ 'nuvoton-p2a-vga' : '-DNUVOTON_P2A_VGA',
+ 'nuvoton-p2a-mbox' : '-DNUVOTON_P2A_MBOX',
+}
+
+foreach option_key, option_value : pci_type_combo_map
+ if get_option('p2a-type') == option_key
+ add_project_arguments(option_value, language: 'cpp')
+ summary(option_key, option_value, section : 'Enabled PCI Features')
+ endif
+endforeach
+
+
+sys_lib = static_library(
+ 'sys',
+ 'internal/sys.cpp',
+ implicit_include_directories: false)
+
+sys_dep = declare_dependency(
+ link_with: sys_lib)
+
+phosphor_logging_dep = dependency(
+ 'phosphor-logging',
+ fallback : [
+ 'phosphor-logging',
+ 'phosphor_logging_dep'])
+
+blobs_dep = dependency('phosphor-ipmi-blobs')
+
+if not get_option('tests').disabled()
+ gtest = dependency('gtest', main: true, disabler: true, required: false)
+ gmock = dependency('gmock', disabler: true, required: false)
+ if not gtest.found() or not gmock.found()
+ gtest_opt = import('cmake').subproject_options()
+ gtest_opt.append_compile_args('c++', ['-DCMAKE_CXX_FLAGS=-Wno-pedantic'])
+ gtest_proj = cmake.subproject('googletest', options: gtest_opt, required: false)
+ fmt_depj.dependency('fmt')
+
+ if gtest_proj.found()
+ gtest = declare_dependency(
+ dependencies: [
+ dependency('threads'),
+ gtest_proj.dependency('gtest'),
+ gtest_proj.dependency('gtest_main'),
+ ])
+ gmock = gtest_proj.dependency('gmock')
+ endif
+ endif
+endif
+
+
+if not get_option('bmc-blob-handler').disabled()
+ subdir('bmc')
+endif
+
+if not get_option('host-tool').disabled()
+ subdir('tools')
+endif
+
+if not get_option('cleanup-delete').disabled()
+ subdir('cleanup')
+endif