build: Add meson

Change-Id: I9b6bf99113a4fbfb92b0b8b6c4e3feff0c070421
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/example/meson.build b/example/meson.build
new file mode 100644
index 0000000..9600468
--- /dev/null
+++ b/example/meson.build
@@ -0,0 +1,8 @@
+shared_module(
+  'example',
+  'example.cpp',
+  implicit_include_directories: false,
+  dependencies: ipmi_blob_dep,
+  install: true,
+  install_dir: get_option('libdir') / 'blob-ipmid')
+
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..2ec535b
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,70 @@
+project(
+  'phosphor-ipmi-blobs',
+  'cpp',
+  version: '0.1',
+  meson_version: '>=0.51.0',
+  default_options: [
+    'cpp_std=c++17',
+    'warning_level=3',
+    'werror=true',
+  ])
+
+ipmi_blob_dep = declare_dependency(
+  include_directories: include_directories('.'))
+
+import('pkgconfig').generate(
+  name: 'phosphor-ipmi-blobs',
+  description: 'Phosphor Blob Transfer Interface',
+  version: meson.project_version())
+
+phosphor_logging_dep = dependency('phosphor-logging')
+
+blob_manager_pre = declare_dependency(
+  dependencies: [
+    ipmi_blob_dep,
+    dependency('ipmiblob'),
+    phosphor_logging_dep,
+  ])
+
+blob_manager_lib = static_library(
+  'blobmanager',
+  'fs.cpp',
+  'internal/sys.cpp',
+  'ipmi.cpp',
+  'manager.cpp',
+  'process.cpp',
+  'utils.cpp',
+  implicit_include_directories: false,
+  dependencies: blob_manager_pre)
+
+blob_manager_dep = declare_dependency(
+  link_with: blob_manager_lib,
+  dependencies: blob_manager_pre)
+
+conf_data = configuration_data()
+conf_data.set_quoted(
+  'BLOB_LIB_PATH',
+  get_option('prefix') / get_option('libdir') / 'blob-ipmid')
+conf_h = configure_file(
+  output: 'config.h',
+  configuration: conf_data)
+
+shared_module(
+  'blobmanager',
+  conf_h,
+  'main.cpp',
+  implicit_include_directories: false,
+  dependencies: [
+    blob_manager_dep,
+    dependency('libipmid'),
+  ],
+  install: true,
+  install_dir: get_option('libdir') / 'ipmid-providers')
+
+if get_option('examples')
+  subdir('example')
+endif
+
+if not get_option('tests').disabled()
+  subdir('test')
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..86bc7fc
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,2 @@
+option('tests', type: 'feature', description: 'Build tests')
+option('examples', type: 'boolean', value: true, description: 'Build examples')
diff --git a/test/meson.build b/test/meson.build
new file mode 100644
index 0000000..db240b3
--- /dev/null
+++ b/test/meson.build
@@ -0,0 +1,42 @@
+gtest = dependency('gtest', main: true, disabler: true, required: get_option('tests'))
+gmock = dependency('gmock', disabler: true, required: get_option('tests'))
+
+tests = [
+  'ipmi_close_unittest',
+  'ipmi_commit_unittest',
+  'ipmi_delete_unittest',
+  'ipmi_enumerate_unittest',
+  'ipmi_getcount_unittest',
+  'ipmi_open_unittest',
+  'ipmi_read_unittest',
+  'ipmi_sessionstat_unittest',
+  'ipmi_stat_unittest',
+  'ipmi_unittest',
+  'ipmi_validate_unittest',
+  'ipmi_write_unittest',
+  'ipmi_writemeta_unittest',
+  'manager_close_unittest',
+  'manager_commit_unittest',
+  'manager_delete_unittest',
+  'manager_expire_unittest',
+  'manager_getsession_unittest',
+  'manager_open_unittest',
+  'manager_read_unittest',
+  'manager_sessionstat_unittest',
+  'manager_stat_unittest',
+  'manager_unittest',
+  'manager_write_unittest',
+  'manager_writemeta_unittest',
+  'process_unittest',
+  'utils_unittest',
+]
+
+foreach t : tests
+  test(
+    t,
+    executable(
+      t.underscorify(),
+      t + '.cpp',
+      implicit_include_directories: false,
+      dependencies: [blob_manager_dep, gtest, gmock]))
+endforeach