Convert project to meson and C++20
Converting build system from CMake to Meson and C++20.
Signed-off-by: Hieu Huynh <hieuh@os.amperecomputing.com>
Change-Id: Ieaf98401328b77683fce14222512bdecec9be908
diff --git a/CMakeLists.txt b/CMakeLists.txt
deleted file mode 100644
index d4e34ed..0000000
--- a/CMakeLists.txt
+++ /dev/null
@@ -1,106 +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})
-
-option (USING_ENTITY_MANAGER_DECORATORS
- "Enable using EM decorators to map FRUs to entity IDs" ON)
-
-set (
- CMAKE_CXX_FLAGS
- "${CMAKE_CXX_FLAGS} \
- -Werror \
- -Wtype-limits \
- -Wnull-dereference \
-"
-)
-
-project (ampere-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_library (zampoemcmds
- SHARED
- src/bridgingcommands.cpp
- src/appcommands.cpp
- src/oemcommands.cpp)
-
-set_target_properties (zampoemcmds PROPERTIES VERSION "0.1.0")
-set_target_properties (zampoemcmds PROPERTIES SOVERSION "0")
-target_link_libraries (zampoemcmds stdc++fs)
-target_link_libraries (zampoemcmds ipmid)
-target_link_libraries (zampoemcmds sdbusplus)
-target_link_libraries (zampoemcmds phosphor_logging)
-target_link_libraries (zampoemcmds -luserlayer)
-target_link_libraries (zampoemcmds -lchannellayer)
-target_link_libraries (zampoemcmds ${OPENSSL_CRYPTO_LIBRARY})
-target_link_libraries (zampoemcmds gpiodcxx)
-
-install (TARGETS zampoemcmds DESTINATION lib/ipmid-providers)
-
-target_compile_definitions (
- zampoemcmds 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/cmake-format.json b/cmake-format.json
deleted file mode 100644
index 4a68fb7..0000000
--- a/cmake-format.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "enum_char": ".",
- "line_ending": "unix",
- "bullet_char": "*",
- "max_subargs_per_line": 99,
- "command_case": "lower",
- "tab_size": 4,
- "line_width": 80,
- "separate_fn_name_with_space": true,
- "dangle_parens": true,
- "separate_ctrl_name_with_space": true
-}
-
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..acf5ec1
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,57 @@
+project(
+ 'ampere-ipmi-oem',
+ 'cpp',
+ version: '0.1',
+ meson_version: '>=0.57.0',
+ default_options: [
+ 'werror=true',
+ 'warning_level=3',
+ 'cpp_std=c++20',
+ ])
+
+# Project Arguments
+cpp = meson.get_compiler('cpp')
+add_project_arguments(
+ cpp.get_supported_arguments([
+ '-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',
+ '-Wno-psabi',
+ '-Wno-pedantic',
+ ]),
+ language : 'cpp')
+
+root_inc = include_directories('.', 'include')
+
+# Dependencies
+phosphor_logging_dep = dependency('phosphor-logging')
+sdbusplus_dep = dependency('sdbusplus', required : false, include_type: 'system')
+ipmid_dep = dependency('libipmid')
+channellayer_dep = cpp.find_library('channellayer', required: true)
+userlayer_dep = cpp.find_library('userlayer', required: true)
+
+zampoemcmds_pre = declare_dependency(
+ include_directories: root_inc,
+ dependencies: [
+ phosphor_logging_dep,
+ sdbusplus_dep,
+ ipmid_dep,
+ channellayer_dep,
+ userlayer_dep,
+ ])
+
+zampoemcmds_lib = library(
+ 'zampoemcmds',
+ 'src/appcommands.cpp',
+ 'src/bridgingcommands.cpp',
+ 'src/oemcommands.cpp',
+ implicit_include_directories: false,
+ dependencies: zampoemcmds_pre,
+ version: meson.project_version(),
+ override_options: ['b_lundef=false'],
+ install: true,
+ install_dir: get_option('libdir') / 'ipmid-providers')
\ No newline at end of file
diff --git a/src/bridgingcommands.cpp b/src/bridgingcommands.cpp
index 13fda3f..3b45da0 100644
--- a/src/bridgingcommands.cpp
+++ b/src/bridgingcommands.cpp
@@ -71,8 +71,8 @@
ipmi::RspType<> ipmiAppClearMessageFlags(ipmi::Context::ptr ctx,
bool receiveMessage,
bool eventMsgBufFull, bool reserved2,
- bool watchdogTimeout, bool reserved1,
- bool oem0, bool oem1, bool oem2)
+ bool, bool reserved1,
+ bool, bool, bool)
{
ipmi::ChannelInfo chInfo;
diff --git a/src/oemcommands.cpp b/src/oemcommands.cpp
index f55c16e..deea8e2 100644
--- a/src/oemcommands.cpp
+++ b/src/oemcommands.cpp
@@ -65,6 +65,7 @@
{
std::string cmd;
std::string cmdOutput;
+ int ret;
try
{
/* Check the mode of NTP in the system, set the system time in case the
@@ -80,7 +81,12 @@
else
{
/* Sync time from RTC to BMC using hwclock */
- system("hwclock --hctosys");
+ ret = system("hwclock --hctosys");
+ if (ret == -1)
+ {
+ log<level::INFO>("Can not set the system time");
+ return responseFailure();
+ }
}
}
catch(const std::exception& e)