diff options
-rw-r--r-- | CMakeLists.txt | 487 | ||||
-rw-r--r-- | CMakeLists.txt.in | 65 | ||||
-rw-r--r-- | JenkinsFile | 12 | ||||
-rw-r--r-- | README.md | 34 | ||||
-rw-r--r-- | bmcweb.service.in | 2 | ||||
-rwxr-xr-x | build_x86.sh | 10 | ||||
-rw-r--r-- | cmake-format.json | 12 | ||||
-rw-r--r-- | cmake/FindGMock.cmake | 129 | ||||
-rw-r--r-- | cmake/FindPAM.cmake | 71 | ||||
-rw-r--r-- | cmake/FindSystemd.cmake | 15 | ||||
-rw-r--r-- | cmake/Finddbus.cmake | 61 | ||||
-rw-r--r-- | config.h.in | 1 | ||||
-rw-r--r-- | meson.build | 389 | ||||
-rw-r--r-- | meson_options.txt | 34 | ||||
-rw-r--r-- | src/gtest_main.cpp | 8 | ||||
-rw-r--r-- | subprojects/boost-url.wrap | 3 | ||||
-rw-r--r-- | subprojects/boost.wrap | 4 | ||||
-rw-r--r-- | subprojects/gtest.wrap | 10 | ||||
-rw-r--r-- | subprojects/nlohmann.wrap | 3 | ||||
-rw-r--r-- | subprojects/sdbusplus.wrap | 3 | ||||
-rw-r--r-- | subprojects/tinyxml2.wrap | 11 |
21 files changed, 495 insertions, 869 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 98ccb2834b..0000000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,487 +0,0 @@ -cmake_minimum_required (VERSION 3.5 FATAL_ERROR) - -project (bmc-webserver CXX) - -cmake_policy (SET CMP0054 NEW) - -set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) - -option (BUILD_STATIC_LIBS "Built static libraries" ON) - -option (YOCTO_DEPENDENCIES "Use YOCTO dependencies system" OFF) - -option ( - BMCWEB_ENABLE_KVM - "Enable the KVM host video WebSocket. Path is '/kvm/0'. Video is from the - BMC's '/dev/video' device." - ON -) -option ( - BMCWEB_ENABLE_VM_WEBSOCKET - "Enable the Virtual Media WebSocket. Path is '/vm/0/0'to open the websocket. - See https://github.com/openbmc/jsnbd/blob/master/README." - ON -) -option ( - BMCWEB_ENABLE_VM_NBDPROXY - "Enable the Virtual Media WebSocket." - OFF -) -option ( - BMCWEB_ENABLE_DBUS_REST - "Enable Phosphor REST (D-Bus) APIs. Paths directly map Phosphor D-Bus - object paths, for example, '/xyz/openbmc_project/logging/entry/enumerate'. - See https://github.com/openbmc/docs/blob/master/rest-api.md." - ON -) -option ( - BMCWEB_ENABLE_REDFISH - "Enable Redfish APIs. Paths are under '/redfish/v1/'. See - https://github.com/openbmc/bmcweb/blob/master/DEVELOPING.md#redfish." - ON -) -option ( - BMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET - "Enable host serial console WebSocket. Path is '/console0'. See - https://github.com/openbmc/docs/blob/master/console.md." - ON -) -option ( - BMCWEB_ENABLE_STATIC_HOSTING - "Enable serving files from the '/usr/share/www' directory as paths under - '/'." - ON -) -option ( - BMCWEB_ENABLE_REDFISH_BMC_JOURNAL - "Enable BMC journal access through Redfish. Paths are under - '/redfish/v1/Managers/bmc/LogServices/Journal'." - OFF -) -option ( - BMCWEB_ENABLE_REDFISH_RAW_PECI - "Enable PECI transactions through Redfish. Paths are under - '/redfish/v1/Systems/system/LogServices/CpuLog/Actions/Oem/CpuLog.SendRawPeci'." - OFF -) -option ( - BMCWEB_ENABLE_REDFISH_CPU_LOG - "Enable CPU log service transactions through Redfish. Paths are under - '/redfish/v1/Systems/system/LogServices/Crashdump'." - OFF -) -option ( - BMCWEB_ENABLE_REDFISH_DUMP_LOG - "Enable BMC and System dump log service transactions through Redfish. For BMC dump, paths - are under '/redfish/v1/Managers/bmc/LogServices/Dump' and for System dump, - paths are under '/redfish/v1/Systems/system/LogServices/Dump'." - OFF -) -option ( - BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES - "Enable DBUS log service transactions through Redfish. Paths are under - '/redfish/v1/Systems/system/LogServices/EventLog/Entries'." - OFF -) -option ( - BMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE - "Enable provisioning feature support in redfish. Paths are under - '/redfish/v1/Systems/system/'." - OFF -) -option ( - BMCWEB_ENABLE_LOGGING - "Enable output the extended debug logs" - OFF -) -option ( - BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION - "Enables authenticating users through TLS client certificates. - The BMCWEB_INSECURE_DISABLE_SSL must be OFF for this option to take effect." - ON -) -option ( - BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE - "Enable the IBM management console specific functionality. Paths are under - '/ibm/v1/'." - OFF -) - - -# Insecure options. Every option that starts with a BMCWEB_INSECURE flag should -# not be enabled by default for any platform, unless the author fully -# comprehends the implications of doing so. In general, enabling these options -# will cause security problems of varying degrees -option ( - BMCWEB_INSECURE_DISABLE_CSRF_PREVENTION - "Disable CSRF prevention checks. Should be set to OFF for production - systems." - OFF -) - -option (BMCWEB_INSECURE_DISABLE_SSL - "Disable SSL ports. Should be set to OFF for production systems." OFF) - -option ( - BMCWEB_INSECURE_DISABLE_AUTHENTICATION - "Disable authentication on all ports. Should be set to OFF for production - systems" - OFF -) - -option (BMCWEB_INSECURE_DISABLE_XSS_PREVENTION "Disable XSS preventions" OFF) - -option ( - BMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE - "Enable TFTP based firmware update transactions through Redfish - UpdateService.SimpleUpdate." - OFF -) - -option ( - BMCWEB_INSECURE_ENABLE_HTTP_PUSH_STYLE_EVENTING - "Enable HTTP push style eventing feature" OFF -) - -option ( - BMCWEB_ENABLE_VALIDATION_UNSECURE_FEATURE - "Enables unsecure features required by validation. Note: must - be turned off for production images." - OFF) - -option ( - BMCWEB_INSECURE_UNRESTRICTED_SENSOR_OVERRIDE - "Enables Sensor override feature without any check." - OFF) - -set (BMCWEB_HTTP_REQ_BODY_LIMIT_MB "30" CACHE STRING - "The max HTTP request body size in MB") - -configure_file(config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/include/config.h) - -if (BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION AND BMCWEB_INSECURE_DISABLE_SSL) - message("SSL Must be enabled to allow SSL authentication") - set(BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION OFF) -endif() - - -include (CTest) - -set (CMAKE_CXX_STANDARD 17) -set (CMAKE_CXX_STANDARD_REQUIRED ON) - -set (CMAKE_EXPORT_COMPILE_COMMANDS ON) - -set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -Wall") - -# reenable when https://github.com/chriskohlhoff/asio/issues/533 -# is resolved. ASIO default executor doesn't build with no-rtti -#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \ -# -fno-rtti \ -#") - -set ( - CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} \ - -Wall \ - -Wextra \ - -Wnon-virtual-dtor \ - -Wold-style-cast \ - -Wcast-align \ - -Wunused \ - -Woverloaded-virtual \ - -Wpedantic \ - -Wconversion \ - -Wsign-conversion \ -" -) - -# only set -Werror if we're on a compiler that we know passes -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0) - set ( - CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} \ - -Werror \ - -Wduplicated-cond \ - -Wduplicated-branches \ - -Wlogical-op \ - -Wnull-dereference \ - -Wdouble-promotion \ - -Wformat=2 \ - -Wno-stringop-overflow \ - -Wunused-parameter \ - " - ) - endif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0) -endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0) - set ( - CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} \ - -Werror \ - -Weverything \ - -Wno-c++98-compat \ - -Wno-c++98-compat-pedantic \ - -Wno-global-constructors \ - -Wno-exit-time-destructors \ - -Wno-shadow \ - -Wno-used-but-marked-unused \ - -Wno-documentation-unknown-command \ - -Wno-weak-vtables \ - -Wno-documentation \ - -Wno-padded \ - -Wunused-parameter \ - -Wcovered-switch-default \ - -Wcomma \ - -Wextra-semi \ - -Wzero-as-null-pointer-constant \ - -Wswitch-enum \ - -Wnull-dereference \ - -Wdouble-promotion \ - -Wformat=2 \ - " - ) - endif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0) -endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") -set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti") - -# general -option (BMCWEB_BUILD_UT "Enable Unit test" OFF) - -# security flags -set ( - SECURITY_FLAGS - "-fstack-protector-strong \ - -fPIE \ - -fPIC \ - -D_FORTIFY_SOURCE=2 \ - -Wformat \ - -Wformat-security" -) -set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${SECURITY_FLAGS}") -set (CMAKE_CXX_FLAGS_RELWITHDEBINFO - "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${SECURITY_FLAGS}") -set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} ${SECURITY_FLAGS}") - -# Enable link time optimization This is a temporary workaround because -# INTERPROCEDURAL_OPTIMIZATION isn't available until cmake 3.9. gcc-ar and gcc- -# ranlib are wrappers around ar and ranlib which add the lto plugin to the -# command line. -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - if (NOT CMAKE_BUILD_TYPE MATCHES Debug) - string (REGEX REPLACE "ar$" "gcc-ar" CMAKE_AR ${CMAKE_AR}) - string (REGEX - REPLACE "ranlib$" "gcc-ranlib" CMAKE_RANLIB ${CMAKE_RANLIB}) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -fno-fat-lto-objects") - - # Reduce the binary size by removing unnecessary dynamic symbol table - # entries - set ( - CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} \ - -fvisibility=hidden \ - -fvisibility-inlines-hidden \ - -Wl,--exclude-libs,ALL" - ) - endif (NOT CMAKE_BUILD_TYPE MATCHES Debug) -endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - -if (NOT ${YOCTO_DEPENDENCIES}) # Download and unpack googletest at configure - # time - 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}) -endif () - -find_package (Boost 1.73 REQUIRED) -message (BOOST_VERSION = ${Boost_VERSION}) -include_directories (SYSTEM ${BOOST_SRC_DIR}) - -# add_definitions(-DBOOST_ASIO_ENABLE_HANDLER_TRACKING) -add_definitions (-DBOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT) -add_definitions (-DBOOST_ASIO_DISABLE_THREADS) -add_definitions (-DBOOST_BEAST_USE_STD_STRING_VIEW) -add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY) -add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED) -add_definitions (-DBOOST_ASIO_NO_DEPRECATED) -add_definitions (-DBOOST_ALL_NO_LIB) -add_definitions (-DBOOST_NO_RTTI) -add_definitions (-DBOOST_NO_TYPEID) -add_definitions (-DBOOST_COROUTINES_NO_DEPRECATION_WARNING) -add_definitions (-DBOOST_URL_STANDALONE) -add_definitions (-DBOOST_URL_HEADER_ONLY) - -# sdbusplus -if (NOT ${YOCTO_DEPENDENCIES}) - include_directories (SYSTEM ${CMAKE_BINARY_DIR}/sdbusplus-src) - link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/build) -endif () - -# Its an Out of tree build,enabling ibm management console for -# unit-test purpose. -if (NOT ${YOCTO_DEPENDENCIES}) - add_definitions(-DBMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE) -endif(NOT ${YOCTO_DEPENDENCIES}) - -# Openssl -find_package (OpenSSL REQUIRED) -include_directories (SYSTEM ${OPENSSL_INCLUDE_DIR}) -message ("OPENSSL_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR}") - -# bmcweb -message ("CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") -if (CMAKE_BUILD_TYPE MATCHES Debug) - set(BMCWEB_ENABLE_LOGGING ON) -endif (CMAKE_BUILD_TYPE MATCHES Debug) - -if (NOT "${BMCWEB_INSECURE_DISABLE_SSL}") - add_definitions (-DBMCWEB_ENABLE_SSL) -endif (NOT "${BMCWEB_INSECURE_DISABLE_SSL}") -include_directories (${CMAKE_CURRENT_SOURCE_DIR}/http) - -# Build with the extended debug logs output -if (${BMCWEB_ENABLE_LOGGING}) - message ("Logging enabled") - add_definitions (-DBMCWEB_ENABLE_DEBUG) - add_definitions (-DBMCWEB_ENABLE_LOGGING) -endif(${BMCWEB_ENABLE_LOGGING}) - -# Zlib -find_package (ZLIB REQUIRED) -include_directories (SYSTEM ${ZLIB_INCLUDE_DIRS}) - -# PAM -option (WEBSERVER_ENABLE_PAM "enable pam authentication" ON) -if ("${WEBSERVER_ENABLE_PAM}") - find_package (PAM REQUIRED) -else () - add_definitions ("-DWEBSERVER_DISABLE_PAM") -endif () - -add_definitions ("-Wno-attributes") -# Copy pam-webserver to etc/pam.d -install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/pam-webserver DESTINATION /etc/pam.d/ - RENAME webserver) - -# tinyxml2 -find_package (tinyxml2 REQUIRED) - -set (WEBSERVER_MAIN src/webserver_main.cpp) - -include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) -include_directories (${CMAKE_CURRENT_SOURCE_DIR}/redfish-core/include) -include_directories (${CMAKE_CURRENT_SOURCE_DIR}/redfish-core/lib) - -file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/include/bmcweb) -include_directories (${CMAKE_BINARY_DIR}/include) - -set (SRC_FILES redfish-core/src/error_messages.cpp - redfish-core/src/utils/json_utils.cpp ${GENERATED_SRC_FILES}) - -file (COPY src/test_resources DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - -# Unit Tests -if (NOT ${YOCTO_DEPENDENCIES}) - set (UT_FILES src/gtest_main.cpp src/msan_test.cpp - redfish-core/ut/privileges_test.cpp - redfish-core/ut/lock_test.cpp - http/ut/utility_test.cpp - ${CMAKE_BINARY_DIR}/include/bmcweb/blns.hpp) # big list of naughty - # strings - add_custom_command (OUTPUT ${CMAKE_BINARY_DIR}/include/bmcweb/blns.hpp - COMMAND - xxd -i - ${CMAKE_CURRENT_SOURCE_DIR}/src/test_resources/blns - ${CMAKE_BINARY_DIR}/include/bmcweb/blns.hpp) - - set_source_files_properties (${CMAKE_BINARY_DIR}/include/bmcweb/blns.hpp - PROPERTIES GENERATED TRUE) - enable_testing () - - add_executable (webtest ${SRC_FILES} ${UT_FILES}) - - find_package (GTest REQUIRED) - find_package (GMock REQUIRED) - target_link_libraries (webtest ${GTEST_LIBRARIES}) - target_link_libraries (webtest ${GMOCK_LIBRARIES}) - - target_link_libraries (webtest pthread) - target_link_libraries (webtest ${OPENSSL_LIBRARIES}) - target_link_libraries (webtest ${ZLIB_LIBRARIES}) - target_link_libraries (webtest pam) - target_link_libraries (webtest tinyxml2) - target_link_libraries (webtest sdbusplus) - target_link_libraries (webtest -lsystemd) - target_link_libraries (webtest -lstdc++fs) - add_test (webtest webtest "--gtest_output=xml:webtest.xml") - -endif (NOT ${YOCTO_DEPENDENCIES}) - -install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/static/ DESTINATION share/www) - -# bmcweb -add_executable (bmcweb ${WEBSERVER_MAIN} ${HDR_FILES} ${SRC_FILES}) -target_link_libraries (bmcweb ${OPENSSL_LIBRARIES}) -target_link_libraries (bmcweb ${ZLIB_LIBRARIES}) -target_link_libraries (bmcweb pam) -target_link_libraries (bmcweb -latomic) -target_link_libraries (bmcweb -lsystemd) -target_link_libraries (bmcweb -lstdc++fs) -target_link_libraries (bmcweb sdbusplus) -target_link_libraries (bmcweb tinyxml2) -install (TARGETS bmcweb DESTINATION bin) - -target_compile_definitions ( - bmcweb PRIVATE $<$<BOOL:${BMCWEB_ENABLE_KVM}>: -DBMCWEB_ENABLE_KVM> - $<$<BOOL:${BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION}>: -DBMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION> - $<$<BOOL:${BMCWEB_ENABLE_VM_WEBSOCKET}>: -DBMCWEB_ENABLE_VM_WEBSOCKET> - $<$<BOOL:${BMCWEB_ENABLE_VM_NBDPROXY}>: -DBMCWEB_ENABLE_VM_NBDPROXY> - $<$<BOOL:${BMCWEB_ENABLE_DBUS_REST}>: -DBMCWEB_ENABLE_DBUS_REST> - $<$<BOOL:${BMCWEB_ENABLE_REDFISH}>: -DBMCWEB_ENABLE_REDFISH> - $<$<BOOL:${BMCWEB_ENABLE_STATIC_HOSTING}>: -DBMCWEB_ENABLE_STATIC_HOSTING> - $<$<BOOL:${BMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET}>: - -DBMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET> - $<$<BOOL:${BMCWEB_INSECURE_DISABLE_CSRF_PREVENTION}>: - -DBMCWEB_INSECURE_DISABLE_CSRF_PREVENTION> - $<$<BOOL:${BMCWEB_INSECURE_DISABLE_SSL}>: -DBMCWEB_INSECURE_DISABLE_SSL> - $<$<BOOL:${BMCWEB_INSECURE_DISABLE_XSS_PREVENTION}>: - -DBMCWEB_INSECURE_DISABLE_XSS_PREVENTION> - $<$<BOOL:${BMCWEB_ENABLE_REDFISH_RAW_PECI}>: - -DBMCWEB_ENABLE_REDFISH_RAW_PECI> - $<$<BOOL:${BMCWEB_ENABLE_REDFISH_CPU_LOG}>: - -DBMCWEB_ENABLE_REDFISH_CPU_LOG> - $<$<BOOL:${BMCWEB_ENABLE_REDFISH_DUMP_LOG}>: - -DBMCWEB_ENABLE_REDFISH_DUMP_LOG> - $<$<BOOL:${BMCWEB_ENABLE_REDFISH_BMC_JOURNAL}>: - -DBMCWEB_ENABLE_REDFISH_BMC_JOURNAL> - $<$<BOOL:${BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES}>: - -DBMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES> - $<$<BOOL:${BMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE}>: - -DBMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE> - $<$<BOOL:${BMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE}>: - -DBMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE> - $<$<BOOL:${BMCWEB_ENABLE_VALIDATION_UNSECURE_FEATURE}>: - -DBMCWEB_ENABLE_VALIDATION_UNSECURE_FEATURE> - $<$<BOOL:${BMCWEB_INSECURE_UNRESTRICTED_SENSOR_OVERRIDE}>: - -DBMCWEB_INSECURE_UNRESTRICTED_SENSOR_OVERRIDE> - $<$<BOOL:${BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE}>: - -DBMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE> - $<$<BOOL:${BMCWEB_INSECURE_ENABLE_HTTP_PUSH_STYLE_EVENTING}>: - -DBMCWEB_INSECURE_ENABLE_HTTP_PUSH_STYLE_EVENTING> -) - -# configure and install systemd unit files -configure_file (bmcweb.socket bmcweb.socket COPYONLY) -configure_file (bmcweb.service.in bmcweb.service) -pkg_get_variable (SYSTEMD_SYSTEMUNITDIR systemd systemdsystemunitdir) -install (FILES ${PROJECT_BINARY_DIR}/bmcweb.socket DESTINATION - ${SYSTEMD_SYSTEMUNITDIR}) -install (FILES ${PROJECT_BINARY_DIR}/bmcweb.service DESTINATION - ${SYSTEMD_SYSTEMUNITDIR}) diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in deleted file mode 100644 index 605f8e3fc0..0000000000 --- a/CMakeLists.txt.in +++ /dev/null @@ -1,65 +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 ( - sdbusplus-project PREFIX ${CMAKE_BINARY_DIR}/sdbusplus-project - GIT_REPOSITORY https://github.com/openbmc/sdbusplus.git GIT_TAG - fa3137a78e952134559bf7c41c4f29fa4afabe02 SOURCE_DIR - ${CMAKE_BINARY_DIR}/sdbusplus-src BINARY_DIR - ${CMAKE_BINARY_DIR}/sdbusplus-build CONFIGURE_COMMAND "" BUILD_COMMAND cd - ${CMAKE_BINARY_DIR}/sdbusplus-src && meson build -Ddefault_library=static - && ninja -C build libsdbusplus.a INSTALL_COMMAND "" - LOG_DOWNLOAD ON -) - -externalproject_add ( - tinyxml2 GIT_REPOSITORY https://github.com/leethomason/tinyxml2.git GIT_TAG - 8c8293ba8969a46947606a93ff0cb5a083aab47a CMAKE_ARGS SOURCE_DIR - "${CMAKE_BINARY_DIR}/tinyxml2-src" BINARY_DIR - "${CMAKE_BINARY_DIR}/tinyxml2-build" CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/prefix -) - -externalproject_add ( - gtest GIT_REPOSITORY "https://github.com/google/googletest.git" GIT_TAG - dfa853b63d17c787914b663b50c2095a0c5b706e CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/googletest-build SOURCE_DIR - "${CMAKE_BINARY_DIR}/googletest-src" BINARY_DIR - "${CMAKE_BINARY_DIR}/googletest-build" CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/prefix -) - -externalproject_add ( - Boost URL - https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.tar.gz - URL_MD5 4036cd27ef7548b8d29c30ea10956196 SOURCE_DIR - "${CMAKE_BINARY_DIR}/boost-src" BINARY_DIR "${CMAKE_BINARY_DIR}/boost-build" - CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND mkdir -p - "${CMAKE_BINARY_DIR}/prefix/include/" && cp -R - ${CMAKE_BINARY_DIR}/boost-src/boost ${CMAKE_BINARY_DIR}/prefix/include -) - -externalproject_add ( - nlohmann-json GIT_REPOSITORY "https://github.com/nlohmann/json.git" GIT_TAG - b3e5cb7f20dcc5c806e418df34324eca60d17d4e SOURCE_DIR - "${CMAKE_BINARY_DIR}/nlohmann-json-src" BINARY_DIR - "${CMAKE_BINARY_DIR}/nlohmann-json-build" CONFIGURE_COMMAND "" BUILD_COMMAND - "" INSTALL_COMMAND mkdir -p "${CMAKE_BINARY_DIR}/prefix/include/nlohmann" && - cp -r "${CMAKE_BINARY_DIR}/nlohmann-json-src/include/nlohmann" - "${CMAKE_BINARY_DIR}/prefix/include" -) - -externalproject_add ( - Boost-URL GIT_REPOSITORY "https://github.com/CPPAlliance/url.git" GIT_TAG - a56ae0df6d3078319755fbaa67822b4fa7fd352b SOURCE_DIR - "${CMAKE_BINARY_DIR}/boost-url-src" BINARY_DIR - "${CMAKE_BINARY_DIR}/boost-url-build" CONFIGURE_COMMAND "" BUILD_COMMAND - "" INSTALL_COMMAND mkdir -p "${CMAKE_BINARY_DIR}/prefix/include" && - cp -r "${CMAKE_BINARY_DIR}/boost-url-src/include/boost" - "${CMAKE_BINARY_DIR}/prefix/include" -) diff --git a/JenkinsFile b/JenkinsFile index 6114771d3a..00e6649c7e 100644 --- a/JenkinsFile +++ b/JenkinsFile @@ -1,10 +1,8 @@ #!groovy stage 'Debug Build' sh '''rm -rf build_debug - mkdir build_debug - cd build_debug - cmake .. -DCMAKE_BUILD_TYPE="Debug" - cmake --build .''' + meson build_debug --buildtype=debug + ninja -C build_debug''' //stage 'Debug Test' //sh '''cd build_debug @@ -12,10 +10,8 @@ sh '''rm -rf build_debug stage 'Release Build' sh '''rm -rf build_release - mkdir build_release - cd build_release - cmake .. -DCMAKE_BUILD_TYPE="Release" - cmake --build .''' + meson build_release --buildtype=release + ninja -C build_release''' //stage 'Release Test' //sh '''cd build_release @@ -16,11 +16,35 @@ At this time, the webserver implements a few interfaces: ## Configuration BMCWeb is configured by setting `-D` flags that correspond to options -in `bmcweb/CMakeLists.txt` and then compiling. For example, `cmake --DBMCWEB_ENABLE_KVM=NO ...` followed by `make`. The option names -become C++ preprocessor symbols that control which code is compiled -into the program. - +in `bmcweb/meson_options.txt` and then compiling. For example, `meson +<builddir> -Dkvm=disabled ...` followed by `ninja` in build directory. +The option names become C++ preprocessor symbols that control which code +is compiled into the program. + +### Compile bmcweb with default options: +```ascii +meson builddir +ninja -C builddir +``` +### Compile bmcweb with yocto defaults: +```ascii +meson builddir -Dbuildtype=minsize -Db_lto=true -Dtests=disabled +ninja -C buildir +``` +If any of the dependencies are not found on the host system during +configuration, meson automatically gets them via its wrap dependencies +mentioned in `bmcweb/subprojects`. + +### Enable/Disable meson wrap feature +```ascii +meson builddir -Dwrap_mode=nofallback +ninja -C builddir +``` +### Generate test coverage report: +```ascii +meson builddir -Db_coverage=true -Dtests=enabled +ninja coverage -C builddir test +``` When BMCWeb starts running, it reads persistent configuration data (such as UUID and session data) from a local file. If this is not usable, it generates a new configuration. diff --git a/bmcweb.service.in b/bmcweb.service.in index fdb023b809..a0b6777caf 100644 --- a/bmcweb.service.in +++ b/bmcweb.service.in @@ -6,7 +6,7 @@ After=network.target [Service] ExecReload=kill -s HUP $MAINPID -ExecStart=@CMAKE_INSTALL_PREFIX@/bin/bmcweb +ExecStart=@MESON_INSTALL_PREFIX@/bin/bmcweb Type=simple WorkingDirectory=/home/root diff --git a/build_x86.sh b/build_x86.sh index c1585a0ed9..d6d9d09f4f 100755 --- a/build_x86.sh +++ b/build_x86.sh @@ -1,7 +1,5 @@ #!/bin/sh -sudo apt-get install -y libpam0g-dev libssl-dev zlib1g-dev \ - autoconf-archive autoconf -mkdir -p build -cd build -cmake .. -cmake --build . +sudo apt-get install -y libpam0g-dev libssl-dev zlib1g-dev +pip install meson --user +meson builddir -Dyocto-deps=enabled +ninja -C builddir diff --git a/cmake-format.json b/cmake-format.json deleted file mode 100644 index 4a701aee10..0000000000 --- a/cmake-format.json +++ /dev/null @@ -1,12 +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/cmake/FindGMock.cmake b/cmake/FindGMock.cmake deleted file mode 100644 index ec76d4b6a9..0000000000 --- a/cmake/FindGMock.cmake +++ /dev/null @@ -1,129 +0,0 @@ -# Locate the Google C++ Mocking Framework. -# (This file is almost an identical copy of the original FindGTest.cmake file, -# feel free to use it as it is or modify it for your own needs.) -# -# -# Defines the following variables: -# -# GMOCK_FOUND - Found the Google Testing framework -# GMOCK_INCLUDE_DIRS - Include directories -# -# Also defines the library variables below as normal -# variables. These contain debug/optimized keywords when -# a debugging library is found. -# -# GMOCK_BOTH_LIBRARIES - Both libgmock & libgmock-main -# GMOCK_LIBRARIES - libgmock -# GMOCK_MAIN_LIBRARIES - libgmock-main -# -# Accepts the following variables as input: -# -# GMOCK_ROOT - (as a CMake or environment variable) -# The root directory of the gmock install prefix -# -# GMOCK_MSVC_SEARCH - If compiling with MSVC, this variable can be set to -# "MD" or "MT" to enable searching a gmock build tree -# (defaults: "MD") -# -#----------------------- -# Example Usage: -# -# find_package(GMock REQUIRED) -# include_directories(${GMOCK_INCLUDE_DIRS}) -# -# add_executable(foo foo.cc) -# target_link_libraries(foo ${GMOCK_BOTH_LIBRARIES}) -# -#============================================================================= -# This file is released under the MIT licence: -# -# Copyright (c) 2011 Matej Svec -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -#============================================================================= - - -function(_gmock_append_debugs _endvar _library) - if(${_library} AND ${_library}_DEBUG) - set(_output optimized ${${_library}} debug ${${_library}_DEBUG}) - else() - set(_output ${${_library}}) - endif() - set(${_endvar} ${_output} PARENT_SCOPE) -endfunction() - -function(_gmock_find_library _name) - find_library(${_name} - NAMES ${ARGN} - HINTS - $ENV{GMOCK_ROOT} - ${GMOCK_ROOT} - PATH_SUFFIXES ${_gmock_libpath_suffixes} - ) - mark_as_advanced(${_name}) -endfunction() - - -if(NOT DEFINED GMOCK_MSVC_SEARCH) - set(GMOCK_MSVC_SEARCH MD) -endif() - -set(_gmock_libpath_suffixes lib) -if(MSVC) - if(GMOCK_MSVC_SEARCH STREQUAL "MD") - list(APPEND _gmock_libpath_suffixes - msvc/gmock-md/Debug - msvc/gmock-md/Release) - elseif(GMOCK_MSVC_SEARCH STREQUAL "MT") - list(APPEND _gmock_libpath_suffixes - msvc/gmock/Debug - msvc/gmock/Release) - endif() -endif() - -find_path(GMOCK_INCLUDE_DIR gmock/gmock.h - HINTS - $ENV{GMOCK_ROOT}/include - ${GMOCK_ROOT}/include -) -mark_as_advanced(GMOCK_INCLUDE_DIR) - -if(MSVC AND GMOCK_MSVC_SEARCH STREQUAL "MD") - # The provided /MD project files for Google Mock add -md suffixes to the - # library names. - _gmock_find_library(GMOCK_LIBRARY gmock-md gmock) - _gmock_find_library(GMOCK_LIBRARY_DEBUG gmock-mdd gmockd) - _gmock_find_library(GMOCK_MAIN_LIBRARY gmock_main-md gmock_main) - _gmock_find_library(GMOCK_MAIN_LIBRARY_DEBUG gmock_main-mdd gmock_maind) -else() - _gmock_find_library(GMOCK_LIBRARY gmock) - _gmock_find_library(GMOCK_LIBRARY_DEBUG gmockd) - _gmock_find_library(GMOCK_MAIN_LIBRARY gmock_main) - _gmock_find_library(GMOCK_MAIN_LIBRARY_DEBUG gmock_maind) -endif() - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GMock DEFAULT_MSG GMOCK_LIBRARY GMOCK_INCLUDE_DIR GMOCK_MAIN_LIBRARY) - -if(GMOCK_FOUND) - set(GMOCK_INCLUDE_DIRS ${GMOCK_INCLUDE_DIR}) - _gmock_append_debugs(GMOCK_LIBRARIES GMOCK_LIBRARY) - _gmock_append_debugs(GMOCK_MAIN_LIBRARIES GMOCK_MAIN_LIBRARY) - set(GMOCK_BOTH_LIBRARIES ${GMOCK_LIBRARIES} ${GMOCK_MAIN_LIBRARIES}) -endif() diff --git a/cmake/FindPAM.cmake b/cmake/FindPAM.cmake deleted file mode 100644 index 25307bd3c3..0000000000 --- a/cmake/FindPAM.cmake +++ /dev/null @@ -1,71 +0,0 @@ -# - Try to find the PAM libraries -# Once done this will define -# -# PAM_FOUND - system has pam -# PAM_INCLUDE_DIR - the pam include directory -# PAM_LIBRARIES - libpam library - -if (PAM_INCLUDE_DIR AND PAM_LIBRARY) - # Already in cache, be silent - set(PAM_FIND_QUIETLY TRUE) -endif (PAM_INCLUDE_DIR AND PAM_LIBRARY) - -find_path(PAM_INCLUDE_DIR NAMES security/pam_appl.h pam/pam_appl.h) -find_library(PAM_LIBRARY pam) -find_library(DL_LIBRARY dl) - -if (PAM_INCLUDE_DIR AND PAM_LIBRARY) - set(PAM_FOUND TRUE) - if (DL_LIBRARY) - set(PAM_LIBRARIES ${PAM_LIBRARY} ${DL_LIBRARY}) - else (DL_LIBRARY) - set(PAM_LIBRARIES ${PAM_LIBRARY}) - endif (DL_LIBRARY) - - if (EXISTS ${PAM_INCLUDE_DIR}/pam/pam_appl.h) - # darwin claims to be something special - set(HAVE_PAM_PAM_APPL_H 1) - endif (EXISTS ${PAM_INCLUDE_DIR}/pam/pam_appl.h) - - if (NOT DEFINED PAM_MESSAGE_CONST) - include(CheckCXXSourceCompiles) - # XXX does this work with plain c? - check_cxx_source_compiles(" -#if ${HAVE_PAM_PAM_APPL_H}+0 -# include <pam/pam_appl.h> -#else -# include <security/pam_appl.h> -#endif -static int PAM_conv( - int num_msg, - const struct pam_message **msg, /* this is the culprit */ - struct pam_response **resp, - void *ctx) -{ - return 0; -} -int main(void) -{ - struct pam_conv PAM_conversation = { - &PAM_conv, /* this bombs out if the above does not match */ - 0 - }; - return 0; -} -" PAM_MESSAGE_CONST) - endif (NOT DEFINED PAM_MESSAGE_CONST) - set(PAM_MESSAGE_CONST ${PAM_MESSAGE_CONST} CACHE BOOL "PAM expects a conversation function with const pam_message") - -endif (PAM_INCLUDE_DIR AND PAM_LIBRARY) - -if (PAM_FOUND) - if (NOT PAM_FIND_QUIETLY) - message(STATUS "Found PAM: ${PAM_LIBRARIES}") - endif (NOT PAM_FIND_QUIETLY) -else (PAM_FOUND) - if (PAM_FIND_REQUIRED) - message(FATAL_ERROR "PAM was not found") - endif(PAM_FIND_REQUIRED) -endif (PAM_FOUND) - -mark_as_advanced(PAM_INCLUDE_DIR PAM_LIBRARY DL_LIBRARY PAM_MESSAGE_CONST) diff --git a/cmake/FindSystemd.cmake b/cmake/FindSystemd.cmake deleted file mode 100644 index 533feb5baf..0000000000 --- a/cmake/FindSystemd.cmake +++ /dev/null @@ -1,15 +0,0 @@ -include(FeatureSummary) -set_package_properties(Systemd PROPERTIES - URL "http://freedesktop.org/wiki/Software/systemd/" - DESCRIPTION "System and Service Manager") - -find_package(PkgConfig) -pkg_check_modules(PC_SYSTEMD libsystemd) -find_library(SYSTEMD_LIBRARIES NAMES systemd ${PC_SYSTEMD_LIBRARY_DIRS}) -find_path(SYSTEMD_INCLUDE_DIRS systemd/sd-login.h HINTS ${PC_SYSTEMD_INCLUDE_DIRS}) - -set(SYSTEMD_DEFINITIONS ${PC_SYSTEMD_CFLAGS_OTHER}) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(SYSTEMD DEFAULT_MSG SYSTEMD_INCLUDE_DIRS SYSTEMD_LIBRARIES) -mark_as_advanced(SYSTEMD_INCLUDE_DIRS SYSTEMD_LIBRARIES SYSTEMD_DEFINITIONS) diff --git a/cmake/Finddbus.cmake b/cmake/Finddbus.cmake deleted file mode 100644 index 2d8eea2569..0000000000 --- a/cmake/Finddbus.cmake +++ /dev/null @@ -1,61 +0,0 @@ -# - Try to find DBus -# Once done, this will define -# -# DBUS_FOUND - system has DBus -# DBUS_INCLUDE_DIRS - the DBus include directories -# DBUS_LIBRARIES - link these to use DBus -# -# Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org> -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS -# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -FIND_PACKAGE(PkgConfig) -PKG_CHECK_MODULES(PC_DBUS QUIET dbus-1) - -FIND_LIBRARY(DBUS_LIBRARIES - NAMES dbus-1 - HINTS ${PC_DBUS_LIBDIR} - ${PC_DBUS_LIBRARY_DIRS} -) - -message("DBUS_LIBRARIES = ${DBUS_LIBRARIES}") - -FIND_PATH(DBUS_INCLUDE_DIR - NAMES dbus/dbus.h - HINTS ${PC_DBUS_INCLUDEDIR} - ${PC_DBUS_INCLUDE_DIRS} -) - -GET_FILENAME_COMPONENT(_DBUS_LIBRARY_DIR ${DBUS_LIBRARIES} PATH) -FIND_PATH(DBUS_ARCH_INCLUDE_DIR - NAMES dbus/dbus-arch-deps.h - HINTS ${PC_DBUS_INCLUDEDIR} - ${PC_DBUS_INCLUDE_DIRS} - ${_DBUS_LIBRARY_DIR} - ${DBUS_INCLUDE_DIR} - PATH_SUFFIXES include -) - -SET(DBUS_INCLUDE_DIRS ${DBUS_INCLUDE_DIR} ${DBUS_ARCH_INCLUDE_DIR}) - -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(DBUS REQUIRED_VARS DBUS_INCLUDE_DIRS DBUS_LIBRARIES) diff --git a/config.h.in b/config.h.in deleted file mode 100644 index 70b98c9a1e..0000000000 --- a/config.h.in +++ /dev/null @@ -1 +0,0 @@ -#cmakedefine BMCWEB_HTTP_REQ_BODY_LIMIT_MB @BMCWEB_HTTP_REQ_BODY_LIMIT_MB@ diff --git a/meson.build b/meson.build new file mode 100644 index 0000000000..51da83a2fa --- /dev/null +++ b/meson.build @@ -0,0 +1,389 @@ +project('bmcweb', 'cpp', + version : '1.0', + meson_version: '>=0.53.2', + default_options: [ + 'werror=true', + 'warning_level=3', + 'cpp_std=c++17', + 'buildtype=debugoptimized', + 'b_ndebug=if-release', + 'b_lto=true', +# enable when https://github.com/chriskohlhoff/asio/issues/533 +# is resolved. ASIO default executor doesn't build with no-rtti + #'cpp_rtti=false' + ]) + +# Project related links + +project_pretty_name = 'bmcweb' +project_url = 'https://github.com/openbmc/' + project_pretty_name +project_issues_url = project_url + '/issues/new' +summary('Issues',project_issues_url, section: 'Report Issues') + +# Validate the c++ Standard + +if get_option('cpp_std') != 'c++17' + error('This project requires c++17 support') +endif + +# Get compiler and default build type + +cxx = meson.get_compiler('cpp') +build = get_option('buildtype') +optimization = get_option('optimization') +summary('Build Type',build, section : 'Build Info') +summary('Optimization',optimization, section : 'Build Info') + +# remove debug information for minsize buildtype +if(get_option('buildtype') == 'minsize') + add_project_arguments('-DNDEBUG', language : 'cpp') +endif + +# Disable lto when compiling with no optimization +if(get_option('optimization') == '0') + add_project_arguments('-fno-lto', language: 'cpp') + message('Disabling lto & its supported features as optimization is disabled') +endif + +# Include Directories + +incdir = include_directories('include','redfish-core/include', + 'redfish-core/lib','http') + +# Get the options and enable the respective features +## create a MAP of "options : feature_flag" + +feature_map = { +'insecure-disable-auth' : '-DBMCWEB_INSECURE_DISABLE_AUTHENTICATION', +'insecure-disable-csrf' : '-DBMCWEB_INSECURE_DISABLE_CSRF_PREVENTION', +'insecure-disable-ssl' : '-DBMCWEB_INSECURE_DISABLE_SSL', +'insecure-disable-xss' : '-DBMCWEB_INSECURE_DISABLE_XSS_PREVENTION', +'host-serial-socket' : '-DBMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET', +'ibm-management-console' : '-DBMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE', +'kvm' : '-DBMCWEB_ENABLE_KVM' , +'mutual-tls-auth' : '-DBMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION', +'pam' : '-DWEBSERVER_ENABLE_PAM', +'insecure-push-style-notification': '-DBMCWEB_INSECURE_ENABLE_HTTP_PUSH_STYLE_EVENTING', +'redfish' : '-DBMCWEB_ENABLE_REDFISH', +'redfish-bmc-journal' : '-DBMCWEB_ENABLE_REDFISH_BMC_JOURNAL', +'redfish-cpu-log' : '-DBMCWEB_ENABLE_REDFISH_CPU_LOG', +'redfish-dbus-log' : '-DBMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES', +'redfish-provisioning-feature' : '-DBMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE', +'redfish-raw-peci' : '-DBMCWEB_ENABLE_REDFISH_RAW_PECI', +'redfish-sysdump-log' : '-DBMCWEB_ENABLE_REDFISH_SYSTEMDUMP_LOG', +'rest' : '-DBMCWEB_ENABLE_DBUS_REST', +'insecure-sensor-override' : '-DBMCWEB_INSECURE_UNRESTRICTED_SENSOR_OVERRIDE', +'static-hosting' : '-DBMCWEB_ENABLE_STATIC_HOSTING', +'insecure-tftp-update' : '-DBMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE', +'validate-unsecure-feature' : '-DBMCWEB_ENABLE_VALIDATION_UNSECURE_FEATURE', +'vm-nbdproxy' : '-DBMCWEB_ENABLE_VM_NBDPROXY', +'vm-websocket' : '-DBMCWEB_ENABLE_VM_WEBSOCKET', +} + +# 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).enabled()) + if(option_key == 'mutual-tls-auth' or option_key == 'insecure-disable-ssl') + if(get_option('insecure-disable-ssl').disabled() or get_option('mutual-tls-auth').disabled()) + add_project_arguments(option_value,language:'cpp') + summary(option_key,option_value, section : 'Enabled Features') + endif + else + summary(option_key,option_value, section : 'Enabled Features') + add_project_arguments(option_value,language:'cpp') + endif + else + if(option_key == 'insecure-disable-ssl') + summary('ssl','-DBMCWEB_ENABLE_SSL', section : 'Enabled Features') + add_project_arguments('-DBMCWEB_ENABLE_SSL', language : 'cpp') + endif + endif +endforeach + +if(get_option('tests').enabled()) + summary('unittest','NA', section : 'Enabled Features') +endif + +if get_option('yocto-deps').disabled() + # This is an out of tree build, so enable ibm console flag + # for CI purpose. + add_project_arguments('-DBMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE', language: 'cpp') + summary('ibm-management-console','-DBMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE',section : 'Enabled Features') +endif + +# Add compiler arguments + +# -Wpedantic, -Wextra comes by default with warning level +add_project_arguments( + cxx.get_supported_arguments([ + '-Wold-style-cast', + '-Wcast-align', + '-Wunused', + '-Woverloaded-virtual', + '-Wconversion', + '-Wsign-conversion', + '-Wno-attributes', + ]), + language: 'cpp' +) + +if (cxx.get_id() == 'clang' and cxx.version().version_compare('>9.0')) +add_project_arguments( + cxx.get_supported_arguments([ + '-Weverything', + '-Wno-c++98-compat', + '-Wno-c++98-compat-pedantic', + '-Wno-global-constructors', + '-Wno-exit-time-destructors', + '-Wno-shadow', + '-Wno-used-but-marked-unused', + '-Wno-documentation-unknown-command', + '-Wno-weak-vtables', + '-Wno-documentation', + '-Wno-padded', + '-Wunused-parameter', + '-Wcovered-switch-default', + '-Wcomma', + '-Wextra-semi', + '-Wzero-as-null-pointer-constant', + '-Wswitch-enum', + '-Wnull-dereference', + '-Wdouble-promotion', + '-Wformat=2', + ]), + language:'cpp') +endif + +# if compiler is gnu-gcc , and version is > 8.0 then we add few more +# compiler arguments , we know that will pass + +if (cxx.get_id() == 'gcc' and cxx.version().version_compare('>8.0')) + + ## remove once bmcweb/issues/147 is fixed + add_global_link_arguments('-Wno-stringop-overflow',language:['c','cpp']) + add_project_arguments('-Wno-stringop-overflow',language:['c','cpp']) + + add_project_arguments( + cxx.get_supported_arguments([ + '-Wduplicated-cond', + '-Wduplicated-branches', + '-Wlogical-op', + '-Wunused-parameter', + '-Wnull-dereference', + '-Wdouble-promotion', + '-Wformat=2', + ]), + language:'cpp') + + if (get_option('buildtype') != 'plain') + if (get_option('b_lto') == true and get_option('optimization')!='0') + # Reduce the binary size by removing unnecessary + # dynamic symbol table entries + + add_project_arguments( + cxx.get_supported_arguments([ + '-fno-fat-lto-objects', + '-fvisibility=hidden', + '-fvisibility-inlines-hidden' + ]), + language: 'cpp') + + if cxx.has_link_argument('-Wl,--exclude-libs,ALL') + add_project_link_arguments('-Wl,--exclude-libs,ALL', language: 'cpp') + endif + endif + + if( get_option('bmcweb-logging').enabled() and \ + get_option('buildtype').startswith('debug')) + add_project_arguments([ + '-DBMCWEB_ENABLE_LOGGING', + '-DBMCWEB_ENABLE_DEBUG' + ], + language : 'cpp') + + summary({'debug' :'-DBMCWEB_ENABLE_DEBUG', + 'logging' : '-DBMCWEB_ENABLE_LOGGING', + },section : 'Enabled Features') + endif + + endif +endif + +# Set Compiler Security flags + +security_flags = [ +'-fstack-protector-strong', +'-fPIE', +'-fPIC', +'-D_FORTIFY_SOURCE=2', +'-Wformat', +'-Wformat-security' +] + +## Add security flags for builds of type 'release','debugoptimized' and 'minsize' + +if not (get_option('buildtype') == 'plain' or get_option('buildtype').startswith('debug')) + add_project_arguments( + cxx.get_supported_arguments([ + security_flags + ]), + language: 'cpp') +endif + +# Boost dependency configuration + +add_project_arguments( +cxx.get_supported_arguments([ +'-DBOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT', +'-DBOOST_ASIO_DISABLE_THREADS', +'-DBOOST_BEAST_USE_STD_STRING_VIEW', +'-DBOOST_ERROR_CODE_HEADER_ONLY', +'-DBOOST_SYSTEM_NO_DEPRECATED', +'-DBOOST_ASIO_NO_DEPRECATED', +'-DBOOST_ALL_NO_LIB', +'-DBOOST_NO_RTTI', +'-DBOOST_NO_TYPEID', +'-DBOOST_COROUTINES_NO_DEPRECATION_WARNING', +'-DBOOST_URL_STANDALONE', +'-DBOOST_URL_HEADER_ONLY' +]), +language : 'cpp') + +# Find the dependency modules, if not found use meson wrap to get them +# automatically during the configure step + +pam = cxx.find_library('pam', required: get_option('pam')) +atomic = cxx.find_library('atomic', required: true) +openssl = dependency('openssl', required : true) +sdbusplus = dependency('sdbusplus',required : false) + +if not sdbusplus.found() + sdbusplus_proj = subproject('sdbusplus', required: true) + sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep') + sdbusplus = sdbusplus.as_system('system') +endif + +if get_option('rest').enabled() + tinyxml = dependency('tinyxml2', required: false) + if not tinyxml.found() + tinyxml_proj = subproject('tinyxml2', required: true) + tinyxml = tinyxml_proj.get_variable('tinyxml2_dep') + tinyxml = tinyxml.as_system('system') + endif +endif + +systemd = dependency('systemd') +zlib = dependency('zlib') + +if cxx.has_header('nlohmann/json.hpp') + nlohmann_json = declare_dependency() +else + subproject('nlohmann', required: false) + nlohmann_json = declare_dependency( + include_directories: [ + 'subprojects/nlohmann/single_include', + 'subprojects/nlohmann/single_include/nlohmann', + ] + ) +endif + +boost = dependency('boost',version : '1.73.0', required : false) +if not boost.found() + subproject('boost', required: false) + boost_inc = include_directories('subprojects/boost_1_73_0/', is_system:true) + boost = declare_dependency(include_directories : boost_inc) +endif + +if cxx.has_header('boost/url/url_view.hpp') + boost_url = declare_dependency() +else + subproject('boost-url', required: false) + boost_url_inc = include_directories('subprojects/boost-url/include', is_system:true) + boost_url= declare_dependency(include_directories : boost_url_inc) +endif + +if get_option('tests').enabled() + gtest = dependency('gtest', main: true,disabler: true, required : false) + gmock = dependency('gmock', required : false) + if not gtest.found() and get_option('tests').enabled() + gtest_proj = subproject('gtest', required: true) + gtest = gtest_proj.get_variable('gtest_main_dep') + gmock = gtest_proj.get_variable('gmock_dep') + endif +endif + +# Source files + +srcfiles_bmcweb = ['src/webserver_main.cpp','redfish-core/src/error_messages.cpp', + 'redfish-core/src/utils/json_utils.cpp'] + +srcfiles_unittest = ['src/msan_test.cpp', + 'redfish-core/ut/privileges_test.cpp', + 'redfish-core/ut/lock_test.cpp', + 'http/ut/utility_test.cpp'] + +# Gather the Configuration data + +conf_data = configuration_data() +conf_data.set('BMCWEB_HTTP_REQ_BODY_LIMIT_MB',get_option('http-body-limit')) +conf_data.set('MESON_INSTALL_PREFIX',get_option('prefix')) +configure_file(output: 'config.h', + configuration: conf_data) + +# Configure and install systemd unit files + +systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir') + +bindir = get_option('prefix') + '/' +get_option('bindir') + +summary({ + 'prefix' : get_option('prefix'), + 'bindir' : bindir, + 'systemd unit directory' : systemd_system_unit_dir + }, section : 'Directories') + +configure_file(input : 'bmcweb.socket', + output : 'bmcweb.socket', + copy : true, + install_dir: systemd_system_unit_dir, + install : true) + +configure_file(input : 'bmcweb.service.in', + output : 'bmcweb.service', + install_dir: systemd_system_unit_dir, + configuration: conf_data, + install : true) + +# Copy pam-webserver to etc/pam.d +configure_file(input : 'pam-webserver', + output : 'webserver', + copy : true, + install_dir: '/etc/pam.d', + install : true) + +install_subdir('static', install_dir : 'share/www', strip_directory : true) + +# Generate the bmcweb executable and the test binary + +executable('bmcweb',srcfiles_bmcweb, + include_directories : incdir, + dependencies: [ + boost, boost_url, pam, atomic, sdbusplus, openssl, + tinyxml, systemd, zlib + ], + install: true, + install_dir:bindir) + +if(get_option('tests').enabled()) + foreach src_test : srcfiles_unittest + testname = src_test.split('/')[-1].split('.')[0] + test(testname,executable(testname,src_test, + include_directories : incdir, + install_dir: bindir, + dependencies: [ + boost, boost_url, gtest,openssl,gmock + ])) + endforeach +endif diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000000..e808f46a03 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,34 @@ +option('pam', type: 'feature', value : 'enabled', description : 'Built static libraries') +option('yocto-deps', type: 'feature', value: 'disabled', description : 'Use YOCTO dependencies system') +option('kvm', type : 'feature',value : 'enabled', description : 'Enable the KVM host video WebSocket. Path is \'/kvm/0\'. Video is from the BMC\'s \'/dev/video\' device.') +option ('tests', type : 'feature', value : 'enabled', description : 'Enable Unit tests for bmcweb') +option('vm-websocket', type : 'feature', value : 'enabled', description : '''Enable the Virtual Media WebSocket. Path is \'/vm/0/0\'to open the websocket. See https://github.com/openbmc/jsnbd/blob/master/README.''') +option('vm-nbdproxy', type: 'feature', value : 'disabled', description : 'Enable the Virtual Media WebSocket.') +option('rest', type : 'feature', value : 'enabled', description : '''Enable Phosphor REST (D-Bus) APIs. Paths directly map Phosphor D-Bus object paths, for example, \'/xyz/openbmc_project/logging/entry/enumerate\'. See https://github.com/openbmc/docs/blob/master/rest-api.md.''') +option('redfish', type : 'feature',value : 'enabled', description: 'Enable Redfish APIs. Paths are under \'/redfish/v1/\'. See https://github.com/openbmc/bmcweb/blob/master/DEVELOPING.md#redfish.') +option('host-serial-socket', type : 'feature', value : 'enabled', description : 'Enable host serial console WebSocket. Path is \'/console0\'. See https://github.com/openbmc/docs/blob/master/console.md.') +option('static-hosting', type : 'feature', value : 'enabled', description : 'Enable serving files from the \'/usr/share/www\' directory as paths under \'/\'.') +option('redfish-bmc-journal', type : 'feature', value : 'disabled', description : 'Enable BMC journal access through Redfish. Paths are under \'/redfish/v1/Managers/bmc/LogServices/Journal\'.') +option('redfish-raw-peci', type : 'feature', value : 'disabled', description : '''Enable PECI transactions through Redfish. Paths are under \/redfish/v1/Systems/system/LogServices/CpuLog/Actions/Oem/CpuLog.SendRawPeci\'.''') +option('redfish-cpu-log', type : 'feature', value : 'disabled', description : '''Enable CPU log service transactions through Redfish. Paths are under \'/redfish/v1/Systems/system/LogServices/Crashdump'.''') +option('redfish-sysdump-log', type : 'feature', value : 'disabled', description : '''Enable System dump log service transactions through Redfish. Paths are under \'/redfish/v1/Systems/system/LogServices/SystemDump\''') +option('redfish-dbus-log', type : 'feature', value : 'disabled', description : 'Enable DBUS log service transactions through Redfish. Paths are under \'/redfish/v1/Systems/system/LogServices/EventLog/Entries\'') +option('redfish-provisioning-feature', type : 'feature', value : 'disabled', description : 'Enable provisioning feature support in redfish. Paths are under \'/redfish/v1/Systems/system/\'') +option('bmcweb-logging', type : 'feature', value : 'disabled', description : 'Enable output the extended debug logs') +option('mutual-tls-auth', type : 'feature', value : 'enabled', description : '''Enables authenticating users through TLS client certificates. The insecure-disable-ssl must be disabled for this option to take effect.''') +option('ibm-management-console', type : 'feature', value : 'disabled', description : 'Enable the IBM management console specific functionality. Paths are under \'/ibm/v1/\'') +option('http-body-limit', type: 'integer', min : 0, max : 30, value : 30, description : 'Specifies the http request body length limit') + +# Insecure options. Every option that starts with a `insecure` flag should +# not be enabled by default for any platform, unless the author fully comprehends +# the implications of doing so.In general, enabling these options will cause security +# problems of varying degrees + +option ('insecure-disable-csrf', type : 'feature', value : 'disabled', description : 'Disable CSRF prevention checks.Should be set to false for production systems.') +option ('insecure-disable-ssl', type : 'feature', value : 'disabled', description : 'Disable SSL ports. Should be set to false for production systems.') +option ('insecure-disable-auth', type : 'feature', value : 'disabled', description : 'Disable authentication on all ports. Should be set to false for production systems') +option ('insecure-disable-xss', type : 'feature', value : 'disabled', description : 'Disable XSS preventions') +option ('insecure-tftp-update', type : 'feature', value : 'disabled', description : '''Enable TFTP based firmware update transactions through Redfish UpdateService.SimpleUpdate.''') +option ('insecure-push-style-notification',type : 'feature', value : 'disabled', description : 'Enable HTTP push style eventing feature') +option ('validate-unsecure-feature', type : 'feature', value : 'disabled', description : '''Enables unsecure features required by validation. Note: mustbe turned off for production images.''') +option ('insecure-sensor-override', type : 'feature', value : 'disabled', description : 'Enables Sensor override feature without any check.') diff --git a/src/gtest_main.cpp b/src/gtest_main.cpp deleted file mode 100644 index 8d2d071d85..0000000000 --- a/src/gtest_main.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "gmock/gmock.h" -#include "gtest/gtest.h" - -int main(int argc, char** argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -}
\ No newline at end of file diff --git a/subprojects/boost-url.wrap b/subprojects/boost-url.wrap new file mode 100644 index 0000000000..c41d2d119e --- /dev/null +++ b/subprojects/boost-url.wrap @@ -0,0 +1,3 @@ +[wrap-git] +revision = a56ae0df6d3078319755fbaa67822b4fa7fd352b +url = https://github.com/CPPAlliance/url.git
\ No newline at end of file diff --git a/subprojects/boost.wrap b/subprojects/boost.wrap new file mode 100644 index 0000000000..8e408fd627 --- /dev/null +++ b/subprojects/boost.wrap @@ -0,0 +1,4 @@ +[wrap-file] +source_url = https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.tar.gz +source_hash = 9995e192e68528793755692917f9eb6422f3052a53c5e13ba278a228af6c7acf +source_filename = boost_1_73_0.tar.gz diff --git a/subprojects/gtest.wrap b/subprojects/gtest.wrap new file mode 100644 index 0000000000..ca5d699ec0 --- /dev/null +++ b/subprojects/gtest.wrap @@ -0,0 +1,10 @@ +[wrap-file] +directory = googletest-release-1.10.0 + +source_url = https://github.com/google/googletest/archive/release-1.10.0.zip +source_filename = gtest-1.10.0.zip +source_hash = 94c634d499558a76fa649edb13721dce6e98fb1e7018dfaeba3cd7a083945e91 + +patch_url = https://wrapdb.mesonbuild.com/v1/projects/gtest/1.10.0/1/get_zip +patch_filename = gtest-1.10.0-1-wrap.zip +patch_hash = 04ff14e8880e4e465f6260221e9dfd56fea6bc7cce4c4aff0dc528e4a2c8f514 diff --git a/subprojects/nlohmann.wrap b/subprojects/nlohmann.wrap new file mode 100644 index 0000000000..a77b7c9c11 --- /dev/null +++ b/subprojects/nlohmann.wrap @@ -0,0 +1,3 @@ +[wrap-git] +revision = b3e5cb7f20dcc5c806e418df34324eca60d17d4e +url = https://github.com/nlohmann/json.git diff --git a/subprojects/sdbusplus.wrap b/subprojects/sdbusplus.wrap new file mode 100644 index 0000000000..d470130393 --- /dev/null +++ b/subprojects/sdbusplus.wrap @@ -0,0 +1,3 @@ +[wrap-git] +url = https://github.com/openbmc/sdbusplus.git +revision = HEAD diff --git a/subprojects/tinyxml2.wrap b/subprojects/tinyxml2.wrap new file mode 100644 index 0000000000..1b01769906 --- /dev/null +++ b/subprojects/tinyxml2.wrap @@ -0,0 +1,11 @@ +[wrap-file] +directory = tinyxml2-7.0.1 + +source_url = https://github.com/leethomason/tinyxml2/archive/7.0.1.tar.gz +source_filename = 7.0.1.tar.gz +source_hash = a381729e32b6c2916a23544c04f342682d38b3f6e6c0cad3c25e900c3a7ef1a6 + +patch_url = https://wrapdb.mesonbuild.com/v1/projects/tinyxml2/7.0.1/1/get_zip +patch_filename = tinyxml2-7.0.1-1-wrap.zip +patch_hash = a40a3cf03a71075d21793c6b920a93cac07e75f1bdcd1637f04ee9d504fdb09b + |