add meson build

most the other openbmc projects are turning into meson projects, so
let's hop on that meson train.

Tested: Builds as expected

Change-Id: I06b6f9e28e27bf7922f42f93756efb98bdb40b2a
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/.gitignore b/.gitignore
index 0662a7b..3127bd3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,3 +21,5 @@
 runSensorTests
 ipmi-allowlist.hpp
 check-code-coverage*
+subprojects/*
+!subprojects/*.wrap
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..2f01792
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,129 @@
+project(
+  'intel-ipmi-oem',
+  'cpp',
+  version: '0.1',
+  meson_version: '>=1.1.1',
+  default_options: [
+    'werror=true',
+    'warning_level=3',
+    'cpp_std=c++23',
+  ])
+
+# Project Arguments
+all_args = [
+    '-DBOOST_ERROR_CODE_HEADER_ONLY',
+    '-DBOOST_SYSTEM_NO_DEPRECATED',
+    '-DBOOST_ALL_NO_LIB',
+    '-DBOOST_NO_RTTI',
+    '-DBOOST_NO_TYPEID',
+    '-DBOOST_ASIO_DISABLE_THREADS',
+    '-DBOOST_COROUTINES_NO_DEPRECATION_WARNING',
+    '-DBMC_VALIDATION_UNSECURE_FEATURE',
+    '-DUSING_ENTITY_MANAGER_DECORATORS',
+    '-Wno-psabi',
+    '-Wno-pedantic',
+  ]
+
+feature_map = {
+  'intel-pfr': '-DINTEL_PFR_ENABLED',
+  'bmc-validation-unsecure-feature': '-DBMC_VALIDATION_UNSECURE_FEATURE',
+  'using-entity-manager-decorators': '-DUSING_ENTITY_MANAGER_DECORATORS',
+}
+
+foreach option_key, option_value : feature_map
+  if(get_option(option_key).allowed())
+    summary(option_key,option_value, section : 'Enabled Features')
+    add_project_arguments(option_value,language:'cpp')
+  endif
+endforeach
+
+cpp = meson.get_compiler('cpp')
+add_project_arguments(
+  cpp.get_supported_arguments(all_args),
+  language : 'cpp')
+
+fs = import('fs')
+
+root_inc = include_directories('.', 'include')
+
+# Dependencies
+sdbusplus_dep = dependency('sdbusplus')
+phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
+phosphor_logging_dep = dependency('phosphor-logging')
+ipmid_dep = dependency('libipmid')
+channellayer_dep = dependency('libchannellayer')
+userlayer_dep = dependency('libuserlayer')
+
+if cpp.has_header_symbol(
+        'nlohmann/json.hpp',
+        'nlohmann::json::string_t',
+        required:false)
+    nlohmann_json_dep = declare_dependency()
+else
+    nlohmann_json_dep = dependency('nlohmann-json')
+endif
+
+tinyxml_dep = dependency('tinyxml2',
+    default_options: ['tests=false'],
+    include_type: 'system',
+)
+
+gpio_dep = dependency('libgpiodcxx',
+      default_options: ['bindings=cxx'],
+      )
+
+zinteloemcmds_pre = declare_dependency(
+  include_directories: root_inc,
+  dependencies: [
+    channellayer_dep,
+    ipmid_dep,
+    gpio_dep,
+    nlohmann_json_dep,
+    phosphor_dbus_interfaces_dep,
+    phosphor_logging_dep,
+    sdbusplus_dep,
+    tinyxml_dep,
+    userlayer_dep,
+  ])
+
+prog_python = import('python').find_installation('python3')
+generate_allowlist_script = files('generate-allowlist.py')
+ipmiallowlist = custom_target(
+    'ipmi-allowlist.hpp',
+    input: [generate_allowlist_script, 'ipmi-allowlist.conf' ],
+    output: 'ipmi-allowlist.hpp',
+    command: [ prog_python, '@INPUT0@', '@INPUT1@', '@OUTPUT@' ],
+    )
+
+zinteloemcmds_src = [
+  'src/oemcommands.cpp',
+  'src/sensorcommands.cpp',
+  'src/biosconfigcommands.cpp',
+  'src/storagecommands.cpp',
+  'src/multinodecommands.cpp',
+  'src/firmware-update.cpp',
+  'src/appcommands.cpp',
+  'src/smbiosmdrv2handler.cpp',
+  'src/manufacturingcommands.cpp',
+  'src/bmccontrolservices.cpp',
+  'src/bridgingcommands.cpp',
+  'src/ipmi_to_redfish_hooks.cpp',
+  'src/me_to_redfish_hooks.cpp',
+  'src/chassiscommands.cpp',
+  'src/allowlist-filter.cpp',
+  ipmiallowlist,
+]
+
+zinteloemcmds_lib = library(
+  'zinteloemcmds',
+  sources: zinteloemcmds_src,
+  implicit_include_directories: false,
+  dependencies: zinteloemcmds_pre,
+  version: meson.project_version(),
+  override_options: ['b_lundef=false'],
+  install: true,
+  install_dir: get_option('libdir') / 'ipmid-providers')
+
+if get_option('tests').allowed()
+  subdir('tests')
+endif
diff --git a/meson.options b/meson.options
new file mode 100644
index 0000000..e0bf2d1
--- /dev/null
+++ b/meson.options
@@ -0,0 +1,4 @@
+option('tests', type: 'feature', description: 'Build tests')
+option('intel-pfr', type: 'feature', description: 'Intel Platform Firmware Resilience enabled')
+option('bmc-validation-unsecure-feature', type: 'feature', description: 'Enables unsecure features required by validation. Note: must be turned off for production images.')
+option('using-entity-manager-decorators', type: 'feature', description: 'Enable using EM decorators to map FRUs to entity IDs')
diff --git a/subprojects/nlohmann-json.wrap b/subprojects/nlohmann-json.wrap
new file mode 100644
index 0000000..a2884b1
--- /dev/null
+++ b/subprojects/nlohmann-json.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/nlohmann/json
+revision = HEAD
+
+[provide]
+nlohmann-json = nlohmann_json_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..4eb85a2
--- /dev/null
+++ b/subprojects/phosphor-host-ipmid.wrap
@@ -0,0 +1,8 @@
+[wrap-git]
+url = https://github.com/openbmc/phosphor-host-ipmid
+revision = HEAD
+
+[provide]
+libipmid = ipmid_dep
+libchannellayer = channellayer_dep
+libuserlayer = userlayer_dep
diff --git a/subprojects/phosphor-logging.wrap b/subprojects/phosphor-logging.wrap
new file mode 100644
index 0000000..6876a6e
--- /dev/null
+++ b/subprojects/phosphor-logging.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/openbmc/phosphor-logging
+revision = HEAD
+
+[provide]
+phosphor-logging = phosphor_logging_dep
diff --git a/subprojects/sdbusplus.wrap b/subprojects/sdbusplus.wrap
new file mode 100644
index 0000000..42cfcee
--- /dev/null
+++ b/subprojects/sdbusplus.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/openbmc/sdbusplus
+revision = HEAD
+
+[provide]
+sdbusplus = sdbusplus_dep
diff --git a/subprojects/sdeventplus.wrap b/subprojects/sdeventplus.wrap
new file mode 100644
index 0000000..7503664
--- /dev/null
+++ b/subprojects/sdeventplus.wrap
@@ -0,0 +1,3 @@
+[wrap-git]
+url = https://github.com/openbmc/sdeventplus
+revision = HEAD
diff --git a/subprojects/stdplus.wrap b/subprojects/stdplus.wrap
new file mode 100644
index 0000000..00dae65
--- /dev/null
+++ b/subprojects/stdplus.wrap
@@ -0,0 +1,3 @@
+[wrap-git]
+url = https://github.com/openbmc/stdplus
+revision = HEAD
diff --git a/subprojects/tinyxml2.wrap b/subprojects/tinyxml2.wrap
new file mode 100644
index 0000000..f1fcec7
--- /dev/null
+++ b/subprojects/tinyxml2.wrap
@@ -0,0 +1,9 @@
+[wrap-file]
+directory = tinyxml2-9.0.0
+source_url = https://github.com/leethomason/tinyxml2/archive/9.0.0.tar.gz
+source_filename = 9.0.0.tar.gz
+source_hash = cc2f1417c308b1f6acc54f88eb70771a0bf65f76282ce5c40e54cfe52952702c
+
+[provide]
+tinyxml2 = dep_tinyxml2
+
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..22c1859
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,34 @@
+gtest_dep = dependency('gtest', main: true, disabler: true, required: false)
+gmock_dep = dependency('gmock', disabler: true, required: false)
+if not gtest_dep.found() or not gmock_dep.found()
+    gtest_proj = import('cmake').subproject('googletest', required: false)
+    if gtest_proj.found()
+        gtest_dep = declare_dependency(
+            dependencies: [
+                dependency('threads'),
+                gtest_proj.dependency('gtest'),
+                gtest_proj.dependency('gtest_main'),
+            ]
+        )
+        gmock_dep = gtest_proj.dependency('gmock')
+    else
+        assert(
+            not get_option('tests').enabled(),
+            'Googletest is required if tests are enabled'
+        )
+    endif
+endif
+
+test('message',
+  executable(
+    'sensorcommands',
+    'test_sensorcommands.cpp',
+    include_directories: root_inc,
+    build_by_default: false,
+    implicit_include_directories: false,
+    dependencies: [
+        gtest_dep,
+        gmock_dep,
+    ],
+  )
+)