build: Migrate to meson and add clang-format

Removed the Cmake files and cleanup formatting errors.

Change-Id: I787041507d3ff6afc6b4a3af3930e8d8363c9570
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..692faa2
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,100 @@
+---
+Language:        Cpp
+# BasedOnStyle:  LLVM
+AccessModifierOffset: -2
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlinesLeft: false
+AlignOperands:   true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: true
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+  AfterCaseLabel:  true
+  AfterClass:      true
+  AfterControlStatement: true
+  AfterEnum:       true
+  AfterFunction:   true
+  AfterNamespace:  true
+  AfterObjCDeclaration: true
+  AfterStruct:     true
+  AfterUnion:      true
+  BeforeCatch:     true
+  BeforeElse:      true
+  IndentBraces:    false
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Custom
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: AfterColon
+ColumnLimit:     80
+CommentPragmas:  '^ IWYU pragma:'
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DerivePointerAlignment: false
+PointerAlignment: Left
+DisableFormat:   false
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: true
+ForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ]
+IncludeBlocks: Regroup
+IncludeCategories:
+  - Regex:           '^[<"](gtest|gmock)'
+    Priority:        5
+  - Regex:           '^"config.h"'
+    Priority:        -1
+  - Regex:           '^".*\.hpp"'
+    Priority:        1
+  - Regex:           '^<.*\.h>'
+    Priority:        2
+  - Regex:           '^<.*'
+    Priority:        3
+  - Regex:           '.*'
+    Priority:        4
+IndentCaseLabels: true
+IndentWidth:     4
+IndentWrappedFunctionNames: true
+KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: ''
+MacroBlockEnd:   ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 60
+ReflowComments:  true
+SortIncludes:    true
+SortUsingDeclarations: true
+SpaceAfterCStyleCast: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles:  false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard:        Cpp11
+TabWidth:        4
+UseTab:          Never
+...
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
deleted file mode 100644
index da3ff73..0000000
--- a/CMakeLists.txt
+++ /dev/null
@@ -1,110 +0,0 @@
-cmake_minimum_required (VERSION 3.5 FATAL_ERROR)
-
-cmake_policy (SET CMP0054 NEW)
-
-option (YOCTO "Use YOCTO depedencies system" OFF)
-include (ExternalProject)
-set (CMAKE_CXX_STANDARD 17)
-set (CMAKE_CXX_STANDARD_REQUIRED ON)
-set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
-
-
-set (
-    CMAKE_CXX_FLAGS
-    "${CMAKE_CXX_FLAGS} \
-    -Werror \
-    -Wtype-limits \
-    -Wnull-dereference \
-"
-)
-
-project (fii-ipmi-oem CXX)
-
-add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY)
-add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED)
-add_definitions (-DBOOST_ALL_NO_LIB)
-add_definitions (-DBOOST_NO_RTTI)
-add_definitions (-DBOOST_NO_TYPEID)
-add_definitions (-DBOOST_ASIO_DISABLE_THREADS)
-add_definitions (-DBOOST_COROUTINES_NO_DEPRECATION_WARNING)
-add_definitions (-Wno-psabi)
-
-if (NOT YOCTO) # headers that can't be built without yocto
-    include_directories (SYSTEM non-yocto)
-
-    configure_file (CMakeLists.txt.in 3rdparty/CMakeLists.txt)
-    execute_process (COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
-                     WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty)
-    execute_process (COMMAND ${CMAKE_COMMAND} --build .
-                     WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty)
-
-    set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/prefix ${CMAKE_PREFIX_PATH})
-    include_directories (SYSTEM ${CMAKE_BINARY_DIR}/prefix/include)
-    link_directories (${CMAKE_BINARY_DIR}/prefix/lib)
-
-    include_directories (SYSTEM ${CMAKE_BINARY_DIR}/sdbusplus-src)
-    link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/.libs)
-    include_directories (SYSTEM ${CMAKE_BINARY_DIR}/phosphor-logging-src)
-    link_directories (${CMAKE_BINARY_DIR}/phosphor-logging-src/.libs)
-    include_directories (SYSTEM ${CMAKE_BINARY_DIR}/phosphor-ipmi-host/include)
-    include_directories (SYSTEM ${CMAKE_BINARY_DIR}/ipmid/user_channel)
-    include_directories (SYSTEM ${CMAKE_BINARY_DIR}) # link_directories  (${CMAK
-                                                     # E_BINARY_DIR}/sdbusplus-
-                                                     # src/.libs)
-endif ()
-
-if (YOCTO)
-    find_package (PkgConfig REQUIRED)
-    pkg_check_modules (LOGGING phosphor-logging REQUIRED)
-    include_directories (SYSTEM ${LOGGING_INCLUDE_DIRS})
-    link_directories (${LOGGING_LIBRARY_DIRS})
-
-    pkg_check_modules (LIBIPMID libipmid REQUIRED)
-    include_directories (SYSTEM ${LIBIPMID_INCLUDE_DIRS})
-    link_directories (${LIBIPMID_LIBRARY_DIRS})
-
-endif ()
-
-include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
-
-#
-# import OpenSSL (crypto)
-find_package (OpenSSL REQUIRED)
-include_directories (SYSTEM ${OPENSSL_INCLUDE_DIR})
-
-include_directories (SYSTEM ${CMAKE_BINARY_DIR})
-add_custom_command(OUTPUT include/ipmi-whitelist.hpp
-                  COMMAND ./generate-whitelist.py
-                  ARGS ipmi-whitelist.conf ${CMAKE_BINARY_DIR}/ipmi-whitelist.hpp
-                  MAIN_DEPENDENCY ipmi-whitelist.conf
-                  DEPENDS generate-whitelist.py
-                  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
-
-add_library (fiioemcmds
-             SHARED
-             src/systemcommands.cpp
-             src/file_handling.cpp
-             src/bioscommands.cpp)
-
-set_target_properties (fiioemcmds PROPERTIES VERSION "0.1.0")
-set_target_properties (fiioemcmds PROPERTIES SOVERSION "0")
-target_link_libraries (fiioemcmds stdc++fs)
-target_link_libraries (fiioemcmds ipmid)
-target_link_libraries (fiioemcmds sdbusplus)
-target_link_libraries (fiioemcmds phosphor_logging)
-target_link_libraries (fiioemcmds -luserlayer)
-target_link_libraries (fiioemcmds -lchannellayer)
-target_link_libraries (fiioemcmds ${OPENSSL_CRYPTO_LIBRARY})
-target_link_libraries (fiioemcmds gpiodcxx)
-
-install (TARGETS fiioemcmds DESTINATION lib/ipmid-providers)
-
-target_compile_definitions (
-    fiioemcmds PRIVATE
-#    $<$<BOOL:${INTEL_PFR_ENABLED}>: -DINTEL_PFR_ENABLED>
-#    $<$<BOOL:${BMC_VALIDATION_UNSECURE_FEATURE}>:
-#    -DBMC_VALIDATION_UNSECURE_FEATURE>
-#    $<$<BOOL:${MDR_V1_SUPPORT}>: -DMDR_V1_SUPPORT>
-#    $<$<BOOL:${USING_ENTITY_MANAGER_DECORATORS}>:
-#    -DUSING_ENTITY_MANAGER_DECORATORS>
-)
diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in
deleted file mode 100644
index f50f74d..0000000
--- a/CMakeLists.txt.in
+++ /dev/null
@@ -1,31 +0,0 @@
-cmake_minimum_required (VERSION 3.5)
-
-include (ExternalProject)
-
-file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/prefix)
-file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/prefix/include)
-
-# requires apt install autoconf-archive and autoconf
-
-externalproject_add (
-    host-ipmid PREFIX ${CMAKE_BINARY_DIR}/phosphor-host-ipmid GIT_REPOSITORY
-    https://github.com/openbmc/phosphor-host-ipmid SOURCE_DIR
-    ${CMAKE_BINARY_DIR}/phosphor-ipmi-host-src BINARY_DIR
-    ${CMAKE_BINARY_DIR}/phosphor-ipmi-host-build CONFIGURE_COMMAND cd
-    ${CMAKE_BINARY_DIR}/phosphor-ipmi-host-src && export
-    PYTHONPATH=${CMAKE_BINARY_DIR}/prefix/lib/python2.7/site-packages:$ENV{PYTHONPATH}
-    && export PATH=${CMAKE_BINARY_DIR}/prefix/bin:$ENV{PATH} && export
-    PKG_CONFIG_PATH=${CMAKE_BINARY_DIR}/prefix/lib/pkgconfig && ./bootstrap.sh
-    && ./configure --prefix=${CMAKE_BINARY_DIR}/prefix
-    CPPFLAGS=-I${CMAKE_BINARY_DIR}/prefix/include/
-    CXXFLAGS=-Wno-error=unused-result LDFLAGS=-L${CMAKE_BINARY_DIR}/prefix/lib/
-    BUILD_COMMAND cd ${CMAKE_BINARY_DIR}/phosphor-ipmi-host-src && export
-    PYTHONPATH=${CMAKE_BINARY_DIR}/prefix/lib/python2.7/site-packages:$ENV{PYTHONPATH}
-    && export PATH=${CMAKE_BINARY_DIR}/prefix/bin:$ENV{PATH} && export
-    PKG_CONFIG_PATH=${CMAKE_BINARY_DIR}/prefix/lib/pkgconfig && make -j
-    verbose=1 INSTALL_COMMAND cd ${CMAKE_BINARY_DIR}/phosphor-ipmi-host-src &&
-    make install && mkdir -p
-    "${CMAKE_BINARY_DIR}/prefix/include/ipmid" && cp include/ipmid/api.h
-    "${CMAKE_BINARY_DIR}/prefix/include/ipmid/" LOG_DOWNLOAD ON
-)
-
diff --git a/README.md b/README.md
index 8764e81..c1e3420 100644
--- a/README.md
+++ b/README.md
@@ -1,74 +1,79 @@
-### Fii IPMI OEM Commands (0x34)
+# Fii IPMI OEM Commands (0x34)
 
 There are and will be a variety of sys specific commands.
 
-### System Commands (0x h)
+## System Commands (0x h)
 
-#### PCIe Bifurcation Command 0x03
+### PCIe Bifurcation Command 0x03
 
-The PCIe bifurcation command checks the type of pcei adapter instailled in
-each slot.
+The PCIe bifurcation command checks the type of pcei adapter instailled in each
+slot.
 
 Request
 
-|Byte(s) |Value  |Data
-|--------|-------|----
-|0x00|0x03|Subcommand
+| Byte(s) | Value | Data       |
+| ------- | ----- | ---------- |
+| 0x00    | 0x03  | Subcommand |
 
 Response
 
-|Byte(s) |Value  |Data
-|--------|-------|----
-|0x00|0x03|Subcommand
-|0x01|0x--|Bifurcation each bit identified the slot support x16(1b) or x8(0b)
-|0x02|0x--|Present bit each bit identified PCIe adapter installed(0b) or not(1b)
+| Byte(s) | Value | Data                                                                  |
+| ------- | ----- | --------------------------------------------------------------------- |
+| 0x00    | 0x03  | Subcommand                                                            |
+| 0x01    | 0x--  | Bifurcation each bit identified the slot support x16(1b) or x8(0b)    |
+| 0x02    | 0x--  | Present bit each bit identified PCIe adapter installed(0b) or not(1b) |
 
 Example
-|# |Command |Example
-|--------|-------|----
-|1|Read the information|ipmitool 0x34 0x03
 
-### BIOS Related Commands (0x7X)
+| \#  | Command              | Example            |
+| --- | -------------------- | ------------------ |
+| 1   | Read the information | ipmitool 0x34 0x03 |
 
-#### BIOS Boot Count 0x71
+## BIOS Related Commands (0x7X)
+
+### BIOS Boot Count 0x71
 
 This is a 32 bits register that provides bios pushs the boot counter to BMC, or
 get the boot counter from BMC.
 
 Request
-|Byte(s) |Value|Description
-|--------|-----|----
-|0x00|0x71|Subcommand
-|0x01|Op value|Operation to be performed
-|0x02-0x05|byte0 byte1 byte2 byte3|32-bit Count value for set operation
 
-|Op value |Operation to be performed
-|------|---------
-|0x00|Read boot count value
-|0x01|Increment boot count value
-|0x02|Clear boot count value
-|0x03|Set the boot count with given 4 byte value
+| Byte(s)   | Value                   | Description                          |
+| --------- | ----------------------- | ------------------------------------ |
+| 0x00      | 0x71                    | Subcommand                           |
+| 0x01      | Op value                | Operation to be performed            |
+| 0x02-0x05 | byte0 byte1 byte2 byte3 | 32-bit Count value for set operation |
+
+| Op value | Operation to be performed                  |
+| -------- | ------------------------------------------ |
+| 0x00     | Read boot count value                      |
+| 0x01     | Increment boot count value.                |
+| 0x02     | Clear boot count value                     |
+| 0x03     | Set the boot count with given 4 byte value |
 
 Response
-|Byte(s) |Value  |Description
-|--------|-------|----
-|0x00|CC|Completion code returned
-|0x01|--|Byte 0 of boot count
-|0x02|--|Byte 1 of boot count
-|0x03|--|Byte 2 of boot count
-|0x04|--|Byte 3 of boot count
+
+| Byte(s) | Value | Description              |
+| ------- | ----- | ------------------------ |
+| 0x00    | CC    | Completion code returned |
+| 0x01    | --    | Byte 0 of boot count     |
+| 0x02    | --    | Byte 1 of boot count     |
+| 0x03    | --    | Byte 2 of boot count     |
+| 0x04    | --    | Byte 3 of boot count     |
 
 Completion Codes (CC)
-|CC   |Description
-|-----|-----------|
-|0xC1|Invalid Command
-|0x00|Command Success
-|0xC7|Data length Invalid
+
+| CC   | Description         |
+| ---- | ------------------- |
+| 0xC1 | Invalid Command     |
+| 0x00 | Command Success     |
+| 0xC7 | Data length Invalid |
 
 Example
-|# |Command |Example
-|--------|-------|----
-|1|Read the boot count|ipmitool raw 0x34 0x71 0x00
-|2|Increment the boot count by 1|ipmitool raw 0x34 0x71 0x01
-|3|Clear the boot count to all 0's|ipmitool raw 0x34 0x71 0x02
-|4|Set the boot count to given value|ipmitool raw 0x34 0x71 0x03 byte0 byte1 byte2 byte3
+
+| \#  | Command                           | Example                                             |
+| --- | --------------------------------- | --------------------------------------------------- |
+| 1   | Read the boot count               | ipmitool raw 0x34 0x71 0x00                         |
+| 2   | Increment the boot count by 1     | ipmitool raw 0x34 0x71 0x01                         |
+| 3   | Clear the boot count to all 0's   | ipmitool raw 0x34 0x71 0x02                         |
+| 4   | Set the boot count to given value | ipmitool raw 0x34 0x71 0x03 byte0 byte1 byte2 byte3 |
diff --git a/generate-whitelist.py b/generate-whitelist.py
index c732726..eaf87b1 100755
--- a/generate-whitelist.py
+++ b/generate-whitelist.py
@@ -1,6 +1,8 @@
 #!/usr/bin/env python3
 
-import re, sys, os.path
+import re
+import sys
+
 
 def usage():
     sys.stderr.write("Usage: $0 whitelist-config-in whitelist-header-out\n")
@@ -8,30 +10,36 @@
     sys.stderr.write("    and outputs a header file\n")
     sys.exit(-1)
 
+
 class Error(Exception):
     pass
 
+
 class DuplicateEntry(Error):
     def __init__(self, e):
         super(Error, self).__init__(
-             "Multiple entries with matching netfn/cmd found ({})".format(e))
+            "Multiple entries with matching netfn/cmd found ({})".format(e)
+        )
+
 
 class ParseError(Error):
     def __init__(self, d):
         super(Error, self).__init__("Parse error at: '{}'".format(d))
 
+
 class entry:
     linere = re.compile(
-            r'(0x[0-9a-f]{2}):(0x[0-9a-f]{2})((:(0x[0-9a-f]{4}))?)\s*((//\s*(.*))?)',
-            re.I
-        )
+        r"(0x[0-9a-f]{2}):(0x[0-9a-f]{2})((:(0x[0-9a-f]{4}))?)\s*((//\s*(.*))?)",
+        re.I,
+    )
+
     def __init__(self, data):
         # parse data line into values:
         # type 1, two values: netfn, cmd
         # type 2, three values: netfn, cmd, channels
         try:
             m = self.linere.fullmatch(data).groups()
-        except:
+        except Exception:
             raise ParseError(data)
         self.netfn = int(m[0], 16)
         self.cmd = int(m[1], 16)
@@ -40,32 +48,39 @@
         else:
             # if no channel was provided, default to previous behavior, which
             # is allow all interfaces, including the system interface (ch 15)
-            self.channels = 0xffff
+            self.channels = 0xFFFF
         if m[6] is not None:
             self.comment = "// " + m[7]
         else:
             self.comment = "//"
+
     def __str__(self):
-        return " ".join([ '{',
-            "0x{0.netfn:02x},".format(self),
-            "0x{0.cmd:02x},".format(self),
-            "0x{0.channels:04x}".format(self),
-            "},",
-            "{0.comment}".format(self),
-        ])
+        return " ".join(
+            [
+                "{",
+                "0x{0.netfn:02x},".format(self),
+                "0x{0.cmd:02x},".format(self),
+                "0x{0.channels:04x}".format(self),
+                "},",
+                "{0.comment}".format(self),
+            ]
+        )
+
     def __lt__(self, other):
         if self.netfn == other.netfn:
             return self.cmd < other.cmd
         return self.netfn < other.netfn
+
     def match(self, other):
         return (self.netfn == other.netfn) and (self.cmd == other.cmd)
 
+
 def parse(config):
     entries = []
     with open(config) as f:
         for line in f:
             line = line.strip()
-            if len(line) == 0 or line[0] == '#':
+            if len(line) == 0 or line[0] == "#":
                 continue
             e = entry(line)
             if any([e.match(item) for item in entries]):
@@ -76,23 +91,28 @@
     entries.sort()
     return entries
 
+
 def output(entries, hppfile):
     lines = [
-            "#pragma once",
-            "",
-            "// AUTOGENERATED FILE; DO NOT MODIFY",
-            "",
-            "#include <array>",
-            "#include <tuple>",
-            "",
-            "using netfncmd_tuple = std::tuple<unsigned char, unsigned char, unsigned short>;",
-            "",
-            "constexpr const std::array<netfncmd_tuple, {}> whitelist = ".format(
-                    len(entries)),
-            "{{"
-            ]
-    lines.extend(['    {}'.format(e) for e in entries])
-    lines.append("}};\n");
+        "#pragma once",
+        "",
+        "// AUTOGENERATED FILE; DO NOT MODIFY",
+        "",
+        "#include <array>",
+        "#include <tuple>",
+        "",
+        (
+            "using netfncmd_tuple = std::tuple<unsigned char, unsigned char,"
+            " unsigned short>;"
+        ),
+        "",
+        "constexpr const std::array<netfncmd_tuple, {}> whitelist = ".format(
+            len(entries)
+        ),
+        "{{",
+    ]
+    lines.extend(["    {}".format(e) for e in entries])
+    lines.append("}};\n")
 
     with open(hppfile, "w") as hpp:
         hpp.write("\n".join(lines))
diff --git a/include/bioscommands.hpp b/include/bioscommands.hpp
index 6a705a5..2e915bb 100644
--- a/include/bioscommands.hpp
+++ b/include/bioscommands.hpp
@@ -1,3 +1,4 @@
+// clang-format off
 /********************************************************************************
 *                       HON HAI Precision IND.Co., LTD.                         *
 *            Personal Computer & Enterprise Product Business Group              *
@@ -13,12 +14,17 @@
 *     permission of FOXCONN/CESBG/CABG/SRD.                                     *
 *                                                                               *
 ********************************************************************************/
+// clang-format on
 
 #pragma once
-#define BOOT_COUNT_READ    0x00
-#define BOOT_COUNT_INCREMENT   0x01
-#define BOOT_COUNT_CLEAR   0x02
-#define BOOT_COUNT_SET   0x03
+
+#include <cstddef>
+#include <string>
+
+#define BOOT_COUNT_READ 0x00
+#define BOOT_COUNT_INCREMENT 0x01
+#define BOOT_COUNT_CLEAR 0x02
+#define BOOT_COUNT_SET 0x03
 #define FII_CMD_BIOS_BOOT_COUNT 0x71
 #define OPERATION_BYTE_LENGTH 1
 #define SET_BYTE_LENGTH 5
diff --git a/include/file_handling.hpp b/include/file_handling.hpp
index bb4f703..94f6d5a 100644
--- a/include/file_handling.hpp
+++ b/include/file_handling.hpp
@@ -1,3 +1,4 @@
+// clang-format off
 /********************************************************************************
 *                       HON HAI Precision IND.Co., LTD.                         *
 *            Personal Computer & Enterprise Product Business Group              *
@@ -13,8 +14,11 @@
 *     permission of FOXCONN/CESBG/CABG/SRD.                                     *
 *                                                                               *
 ********************************************************************************/
+// clang-format on
 #include <unistd.h>
 
+#include <system_error>
+
 std::system_error errnoException(const std::string& message);
 
 int sysopen(const std::string& path);
@@ -23,7 +27,6 @@
 
 void lseeker(int fd_, size_t offset);
 
-void readBin(int fd_, size_t offset, void *ptr, size_t size);
+void readBin(int fd_, size_t offset, void* ptr, size_t size);
 
-void writeBin(int fd_, size_t offset, void *ptr, size_t size);
-
+void writeBin(int fd_, size_t offset, void* ptr, size_t size);
diff --git a/include/systemcommands.hpp b/include/systemcommands.hpp
index 2a67a0b..e263c92 100644
--- a/include/systemcommands.hpp
+++ b/include/systemcommands.hpp
@@ -1,3 +1,4 @@
+// clang-format off
 /********************************************************************************
 *                       HON HAI Precision IND.Co., LTD.                         *
 *            Personal Computer & Enterprise Product Business Group              *
@@ -13,7 +14,7 @@
 *     permission of FOXCONN/CESBG/CABG/SRD.                                     *
 *                                                                               *
 ********************************************************************************/
-
+// clang-format on
 #pragma once
 
 #define PCIEINFO_COMMAND "i2cget -y -a -f 26 0x76 0x01 i 2"
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..2c0d977
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,36 @@
+project(
+  'foxconn-ipmi-oem',
+  'cpp',
+  version: '0.1',
+  meson_version: '>=0.63.0',
+  default_options: [
+    'werror=true',
+    'warning_level=3',
+    'cpp_std=c++20',
+  ]
+)
+
+root_inc = include_directories('.', 'include')
+
+# Dependencies
+fiioemcmds_dep = declare_dependency(
+  include_directories: root_inc,
+  dependencies: [
+    dependency('libipmid'),
+    dependency('phosphor-logging'),
+    dependency('sdbusplus'),
+    dependency('libgpiod'),
+  ]
+)
+
+shared_module(
+  'fiioemcmds',
+  'src/systemcommands.cpp',
+  'src/file_handling.cpp',
+  'src/bioscommands.cpp',
+  implicit_include_directories: false,
+  dependencies: fiioemcmds_dep,
+  install: true,
+  install_dir: get_option('libdir') / 'ipmid-providers'
+)
+
diff --git a/src/bioscommands.cpp b/src/bioscommands.cpp
index eb7fa08..361b809 100644
--- a/src/bioscommands.cpp
+++ b/src/bioscommands.cpp
@@ -1,3 +1,4 @@
+// clang-format off
 /********************************************************************************
 *                       HON HAI Precision IND.Co., LTD.                         *
 *            Personal Computer & Enterprise Product Business Group              *
@@ -13,13 +14,14 @@
 *     permission of FOXCONN/CESBG/CABG/SRD.                                     *
 *                                                                               *
 ********************************************************************************/
+// clang-format on
 
-#include <ipmid/api.hpp>
-#include <phosphor-logging/log.hpp>
-#include <sdbusplus/message/types.hpp>
 #include <bioscommands.hpp>
 #include <boost/endian/arithmetic.hpp>
 #include <file_handling.hpp>
+#include <ipmid/api.hpp>
+#include <phosphor-logging/log.hpp>
+#include <sdbusplus/message/types.hpp>
 
 struct bios_boot_count
 {
@@ -30,46 +32,47 @@
 namespace ipmi
 {
 static void registerBIOSFunctions() __attribute__((constructor));
-ipmi::RspType<uint32_t> FiiBIOSBootCount(boost::asio::yield_context yield,
-        std::vector<uint8_t> reqParams)
+ipmi::RspType<uint32_t>
+    FiiBIOSBootCount([[maybe_unused]] boost::asio::yield_context yield,
+                     std::vector<uint8_t> reqParams)
 {
     int boot_count_operation;
     bios_boot_count boot;
     if (reqParams.empty())
     {
         phosphor::logging::log<phosphor::logging::level::ERR>(
-                " Fii bios cmd : command format error.");
+            " Fii bios cmd : command format error.");
         return ipmi::responseReqDataLenInvalid();
     }
 
     boot_count_operation = reqParams[0];
 
-    if((boot_count_operation == BOOT_COUNT_SET &&
-        reqParams.size() != SET_BYTE_LENGTH) ||
+    if ((boot_count_operation == BOOT_COUNT_SET &&
+         reqParams.size() != SET_BYTE_LENGTH) ||
         (boot_count_operation != BOOT_COUNT_SET &&
          reqParams.size() != OPERATION_BYTE_LENGTH))
     {
-         return ipmi::responseReqDataLenInvalid();
+        return ipmi::responseReqDataLenInvalid();
     }
 
-    if(boot_count_operation > BOOT_COUNT_SET)
+    if (boot_count_operation > BOOT_COUNT_SET)
     {
-         return ipmi::responseInvalidCommand();
+        return ipmi::responseInvalidCommand();
     }
 
     int fd = sysopen(EEPROM_PATH);
     readBin(fd, EEPROM_OFFSET, &boot, sizeof(boot));
 
-    if(boot.header != BOOT_COUNT_HEADER)
+    if (boot.header != BOOT_COUNT_HEADER)
     {
         phosphor::logging::log<phosphor::logging::level::INFO>(
-                  "Boot count header is corrupted or missing. Initializing.");
+            "Boot count header is corrupted or missing. Initializing.");
         boot.header = BOOT_COUNT_HEADER;
         boot.count = INITIAL_VALUE;
         writeBin(fd, EEPROM_OFFSET, &boot, sizeof(boot));
     }
 
-    switch(boot_count_operation)
+    switch (boot_count_operation)
     {
         case BOOT_COUNT_READ:
             break;
@@ -84,19 +87,22 @@
             break;
     }
 
-    if( boot_count_operation != BOOT_COUNT_READ )
+    if (boot_count_operation != BOOT_COUNT_READ)
     {
         writeBin(fd, EEPROM_OFFSET + 4, &boot.count, sizeof(boot.count));
-    } 
+    }
     sysclose(fd);
     return ipmi::responseSuccess(boot.count);
 }
 
 void registerBIOSFunctions()
 {
-    std::fprintf(stderr, "Registering OEM:[0x34], Cmd:[%#04X] for Fii BIOS OEM Commands\n",
-            FII_CMD_BIOS_BOOT_COUNT);
-    ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnOemThree, FII_CMD_BIOS_BOOT_COUNT,
-            ipmi::Privilege::User, FiiBIOSBootCount);
+    std::fprintf(
+        stderr,
+        "Registering OEM:[0x34], Cmd:[%#04X] for Fii BIOS OEM Commands\n",
+        FII_CMD_BIOS_BOOT_COUNT);
+    ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnOemThree,
+                          FII_CMD_BIOS_BOOT_COUNT, ipmi::Privilege::User,
+                          FiiBIOSBootCount);
 }
-}
+} // namespace ipmi
diff --git a/src/file_handling.cpp b/src/file_handling.cpp
index 529e9f2..2b6598b 100644
--- a/src/file_handling.cpp
+++ b/src/file_handling.cpp
@@ -1,7 +1,8 @@
-#include <iostream>
 #include <fcntl.h>
 #include <unistd.h>
 
+#include <iostream>
+
 using namespace std::string_literals;
 std::system_error errnoException(const std::string& message)
 {
@@ -31,17 +32,17 @@
     }
 }
 
-void readBin(int fd_, size_t offset, void *ptr, size_t size)
+void readBin(int fd_, size_t offset, void* ptr, size_t size)
 {
     lseeker(fd_, offset);
-    size_t ret = read(fd_, ptr, size);
-    if(ret < 0 )
+    ssize_t ret = read(fd_, ptr, size);
+    if (ret < 0)
     {
         throw errnoException("Error reading from file"s);
     }
 }
 
-void writeBin(int fd_, size_t offset, void *ptr, size_t size)
+void writeBin(int fd_, size_t offset, void* ptr, size_t size)
 {
     lseeker(fd_, offset);
     ssize_t ret;
@@ -53,7 +54,7 @@
     if (static_cast<size_t>(ret) != size)
     {
         throw std::runtime_error(
-                "Tried to send data size "s + std::to_string(size) +
-                " but could only send "s + std::to_string(ret));
+            "Tried to send data size "s + std::to_string(size) +
+            " but could only send "s + std::to_string(ret));
     }
 }
diff --git a/src/systemcommands.cpp b/src/systemcommands.cpp
index 3cfb574..aaca4e5 100644
--- a/src/systemcommands.cpp
+++ b/src/systemcommands.cpp
@@ -1,3 +1,4 @@
+// clang-format off
 /********************************************************************************
 *                       HON HAI Precision IND.Co., LTD.                         *
 *            Personal Computer & Enterprise Product Business Group              *
@@ -13,59 +14,66 @@
 *     permission of FOXCONN/CESBG/CABG/SRD.                                     *
 *                                                                               *
 ********************************************************************************/
+// clang-format on
 
-
-#include <systemcommands.hpp>
 #include <ipmid/api.hpp>
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/message/types.hpp>
+#include <systemcommands.hpp>
 
 namespace ipmi
+{
+static void registerSystemFunctions() __attribute__((constructor));
+
+ipmi::RspType<std::vector<uint8_t>>
+    FiiSysPCIeInfo([[maybe_unused]] boost::asio::yield_context yield)
+{
+    std::vector<uint8_t> rsp;
+    char buffer[128], *token;
+    uint32_t value;
+    FILE* pipe = popen(PCIEINFO_COMMAND, "r");
+
+    // Read pcie bifurcation information
+    // it return two bytes, 1st byte bifurcation, 2nd byte present pin
+    if (!pipe)
+        throw std::runtime_error("popen() failed !!!");
+    while (fgets(buffer, sizeof(buffer), pipe) != NULL)
     {
-    static void registerSystemFunctions() __attribute__((constructor));
+        std::cerr << " Command : " << buffer << std::endl;
+    }
+    pclose(pipe);
 
-    ipmi::RspType<std::vector<uint8_t>> FiiSysPCIeInfo(boost::asio::yield_context yield)
+    token = std::strtok(buffer, " ");
+    if (token == NULL)
     {
-        std::vector<uint8_t> rsp;
-        char buffer[128], *token;
-        uint32_t value;
-        FILE *pipe = popen(PCIEINFO_COMMAND, "r");
-
-        // Read pcie bifurcation information
-        // it return two bytes, 1st byte bifurcation, 2nd byte present pin
-        if (!pipe) throw std::runtime_error("popen() failed !!!");
-        while (fgets(buffer, sizeof(buffer), pipe) != NULL)
-        {
-            std::cerr << " Command : " << buffer << std::endl;
-        }
-        pclose(pipe);
-
-        token = std::strtok(buffer, " ");
-        if (token == NULL)
-        {
-            phosphor::logging::log<phosphor::logging::level::ERR>(
-                "Fii system cmd : Error geting PCIe Info came back null");
-            ipmi::responseUnspecifiedError();
-        }
+        phosphor::logging::log<phosphor::logging::level::ERR>(
+            "Fii system cmd : Error geting PCIe Info came back null");
+        ipmi::responseUnspecifiedError();
+    }
+    token = std::strtok(NULL, " ");
+    while (token != NULL)
+    {
+        // std::cerr << " Command token: " << token << std::endl;
+        value = std::stoul(token, nullptr, 16);
+        // std::cerr << " Command value: " << value << ":" << std::hex << value
+        // << std::endl;
+        rsp.push_back(static_cast<uint8_t>(value & 0xFF));
         token = std::strtok(NULL, " ");
-        while (token != NULL)
-        {
-            //std::cerr << " Command token: " << token << std::endl;
-            value = std::stoul(token, nullptr, 16);
-            //std::cerr << " Command value: " << value << ":" << std::hex << value << std::endl;
-            rsp.push_back(static_cast<uint8_t>(value & 0xFF));
-            token = std::strtok(NULL, " ");
-        }
-
-        return ipmi::responseSuccess(rsp);
     }
 
-    void registerSystemFunctions()
-    {
-        std::fprintf(stderr, "Registering OEM:[0x34], Cmd:[%#04X] for Fii System OEM Commands\n", FII_CMD_SYS_PCIE_INFO);
-        ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnOemThree, FII_CMD_SYS_PCIE_INFO, ipmi::Privilege::User,
-                FiiSysPCIeInfo);
-
-        return;
-    }
+    return ipmi::responseSuccess(rsp);
 }
+
+void registerSystemFunctions()
+{
+    std::fprintf(
+        stderr,
+        "Registering OEM:[0x34], Cmd:[%#04X] for Fii System OEM Commands\n",
+        FII_CMD_SYS_PCIE_INFO);
+    ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnOemThree,
+                          FII_CMD_SYS_PCIE_INFO, ipmi::Privilege::User,
+                          FiiSysPCIeInfo);
+
+    return;
+}
+} // namespace ipmi