Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 1 | project( |
| 2 | 'bmcweb', |
| 3 | 'cpp', |
| 4 | version: '1.0', |
| 5 | meson_version: '>=0.63.0', |
| 6 | default_options: [ |
| 7 | 'b_lto_mode=default', |
| 8 | 'b_lto_threads=0', |
| 9 | 'b_lto=true', |
| 10 | 'b_ndebug=if-release', |
| 11 | 'buildtype=debugoptimized', |
| 12 | 'cpp_rtti=false', |
| 13 | 'cpp_std=c++20', |
| 14 | 'warning_level=3', |
| 15 | 'werror=true', |
| 16 | ], |
| 17 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 18 | |
| 19 | # Project related links |
| 20 | |
| 21 | project_pretty_name = 'bmcweb' |
| 22 | project_url = 'https://github.com/openbmc/' + project_pretty_name |
| 23 | project_issues_url = project_url + '/issues/new' |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 24 | summary('Issues', project_issues_url, section: 'Report Issues') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 25 | |
| 26 | # Validate the c++ Standard |
| 27 | |
Patrick Williams | c52ee72 | 2021-10-06 15:17:42 -0500 | [diff] [blame] | 28 | if get_option('cpp_std') != 'c++20' |
| 29 | error('This project requires c++20 support') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 30 | endif |
| 31 | |
| 32 | # Get compiler and default build type |
| 33 | |
| 34 | cxx = meson.get_compiler('cpp') |
| 35 | build = get_option('buildtype') |
| 36 | optimization = get_option('optimization') |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 37 | summary('Build Type', build, section: 'Build Info') |
| 38 | summary('Optimization', optimization, section: 'Build Info') |
Ed Tanous | 5e34b67 | 2021-02-05 14:21:27 -0800 | [diff] [blame] | 39 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 40 | # remove debug information for minsize buildtype |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 41 | if (get_option('buildtype') == 'minsize') |
| 42 | add_project_arguments(['-fdata-sections', '-ffunction-sections'], language: 'cpp') |
| 43 | add_project_arguments('-DNDEBUG', language: 'cpp') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 44 | endif |
| 45 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 46 | if (get_option('dns-resolver') == 'systemd-dbus') |
| 47 | add_project_arguments('-DBMCWEB_DBUS_DNS_RESOLVER', language: 'cpp') |
Ed Tanous | f8ca6d7 | 2022-06-28 12:12:03 -0700 | [diff] [blame] | 48 | endif |
| 49 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 50 | # Disable lto when compiling with no optimization |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 51 | if (get_option('optimization') == '0') |
| 52 | add_project_arguments('-fno-lto', language: 'cpp') |
| 53 | message('Disabling lto & its supported features as optimization is disabled') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 54 | endif |
| 55 | |
| 56 | # Include Directories |
| 57 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 58 | incdir = include_directories('include', 'redfish-core/include', 'redfish-core/lib', 'http') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 59 | |
| 60 | # Get the options and enable the respective features |
| 61 | ## create a MAP of "options : feature_flag" |
| 62 | |
| 63 | feature_map = { |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 64 | 'basic-auth': '-DBMCWEB_ENABLE_BASIC_AUTHENTICATION', |
| 65 | 'cookie-auth': '-DBMCWEB_ENABLE_COOKIE_AUTHENTICATION', |
| 66 | 'google-api': '-DBMCWEB_ENABLE_GOOGLE_API', |
| 67 | 'host-serial-socket': '-DBMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET', |
| 68 | 'ibm-management-console': '-DBMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE', |
| 69 | 'insecure-disable-auth': '-DBMCWEB_INSECURE_DISABLE_AUTHX', |
| 70 | 'insecure-disable-csrf': '-DBMCWEB_INSECURE_DISABLE_CSRF_PREVENTION', |
| 71 | 'insecure-disable-ssl': '-DBMCWEB_INSECURE_DISABLE_SSL', |
| 72 | 'insecure-push-style-notification': '-DBMCWEB_INSECURE_ENABLE_HTTP_PUSH_STYLE_EVENTING', |
| 73 | 'insecure-tftp-update': '-DBMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE', |
| 74 | 'insecure-ignore-content-type': '-DBMCWEB_INSECURE_IGNORE_CONTENT_TYPE', |
| 75 | 'kvm': '-DBMCWEB_ENABLE_KVM', |
| 76 | 'mutual-tls-auth': '-DBMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION', |
| 77 | 'redfish-aggregation': '-DBMCWEB_ENABLE_REDFISH_AGGREGATION', |
| 78 | 'redfish-allow-deprecated-power-thermal': '-DBMCWEB_ALLOW_DEPRECATED_POWER_THERMAL', |
| 79 | 'redfish-bmc-journal': '-DBMCWEB_ENABLE_REDFISH_BMC_JOURNAL', |
| 80 | 'redfish-cpu-log': '-DBMCWEB_ENABLE_REDFISH_CPU_LOG', |
| 81 | 'redfish-dbus-log': '-DBMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES', |
| 82 | 'redfish-dump-log': '-DBMCWEB_ENABLE_REDFISH_DUMP_LOG', |
| 83 | 'redfish-host-logger': '-DBMCWEB_ENABLE_REDFISH_HOST_LOGGER', |
| 84 | 'redfish-new-powersubsystem-thermalsubsystem': '-DBMCWEB_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM', |
| 85 | 'redfish-oem-manager-fan-data': '-DBMCWEB_ENABLE_REDFISH_OEM_MANAGER_FAN_DATA', |
| 86 | 'redfish-provisioning-feature': '-DBMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE', |
| 87 | 'redfish': '-DBMCWEB_ENABLE_REDFISH', |
| 88 | 'rest': '-DBMCWEB_ENABLE_DBUS_REST', |
| 89 | 'session-auth': '-DBMCWEB_ENABLE_SESSION_AUTHENTICATION', |
| 90 | 'static-hosting': '-DBMCWEB_ENABLE_STATIC_HOSTING', |
| 91 | 'experimental-redfish-multi-computer-system': '-DBMCWEB_ENABLE_MULTI_COMPUTERSYSTEM', |
| 92 | 'vm-websocket': '-DBMCWEB_ENABLE_VM_WEBSOCKET', |
| 93 | 'xtoken-auth': '-DBMCWEB_ENABLE_XTOKEN_AUTHENTICATION', |
| 94 | #'vm-nbdproxy' : '-DBMCWEB_ENABLE_VM_NBDPROXY', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | # Get the options status and build a project summary to show which flags are |
| 98 | # being enabled during the configuration time. |
| 99 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 100 | foreach option_key, option_value : feature_map |
| 101 | if (get_option(option_key).allowed()) |
| 102 | if ( |
| 103 | option_key == 'mutual-tls-auth' |
| 104 | or option_key == 'insecure-disable-ssl' |
| 105 | ) |
| 106 | if ( |
| 107 | get_option('insecure-disable-ssl').disabled() |
| 108 | or get_option('mutual-tls-auth').disabled() |
| 109 | ) |
| 110 | add_project_arguments(option_value, language: 'cpp') |
| 111 | summary(option_key, option_value, section: 'Enabled Features') |
| 112 | endif |
| 113 | elif ( |
| 114 | option_key in [ |
| 115 | 'basic-auth', |
| 116 | 'cookie-auth', |
| 117 | 'session-auth', |
| 118 | 'xtoken-auth', |
| 119 | 'mutual-tls-auth', |
| 120 | ] |
| 121 | ) |
| 122 | if (get_option('insecure-disable-auth').disabled()) |
| 123 | add_project_arguments(option_value, language: 'cpp') |
| 124 | summary(option_key, option_value, section: 'Enabled Features') |
| 125 | endif |
| 126 | else |
| 127 | summary(option_key, option_value, section: 'Enabled Features') |
| 128 | add_project_arguments(option_value, language: 'cpp') |
| 129 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 130 | else |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 131 | if (option_key == 'insecure-disable-ssl') |
| 132 | summary('ssl', '-DBMCWEB_ENABLE_SSL', section: 'Enabled Features') |
| 133 | add_project_arguments('-DBMCWEB_ENABLE_SSL', language: 'cpp') |
| 134 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 135 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 136 | endforeach |
| 137 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 138 | if (get_option('tests').allowed()) |
| 139 | summary('unittest', 'NA', section: 'Enabled Features') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 140 | endif |
| 141 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 142 | # Add compiler arguments |
| 143 | |
Ed Tanous | ade3f09 | 2024-03-13 13:28:36 -0700 | [diff] [blame] | 144 | if (cxx.get_id() == 'clang') |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 145 | if (cxx.version().version_compare('<17.0')) |
| 146 | error('This project requires clang-17 or higher') |
| 147 | endif |
| 148 | add_project_arguments( |
| 149 | '-Weverything', |
| 150 | '-Wformat=2', |
| 151 | '-Wno-c++98-compat-pedantic', |
| 152 | '-Wno-c++98-compat', |
| 153 | '-Wno-documentation-unknown-command', |
| 154 | '-Wno-documentation', |
| 155 | '-Wno-exit-time-destructors', |
| 156 | '-Wno-global-constructors', |
| 157 | '-Wno-newline-eof', |
| 158 | '-Wno-padded', |
| 159 | '-Wno-shadow', |
| 160 | '-Wno-used-but-marked-unused', |
| 161 | '-Wno-weak-vtables', |
| 162 | '-Wno-switch-enum', |
| 163 | '-Wno-unused-macros', |
| 164 | '-Wno-covered-switch-default', |
| 165 | language: 'cpp', |
| 166 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 167 | endif |
| 168 | |
Ed Tanous | ade3f09 | 2024-03-13 13:28:36 -0700 | [diff] [blame] | 169 | if (cxx.get_id() == 'gcc') |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 170 | if (cxx.version().version_compare('<13.0')) |
| 171 | error('This project requires gcc-13 or higher') |
| 172 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 173 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 174 | add_project_arguments( |
| 175 | '-Wformat=2', |
| 176 | '-Wcast-align', |
| 177 | '-Wconversion', |
| 178 | '-Woverloaded-virtual', |
| 179 | '-Wsign-conversion', |
| 180 | '-Wunused', |
| 181 | '-Wduplicated-cond', |
| 182 | '-Wduplicated-branches', |
| 183 | '-Wlogical-op', |
| 184 | '-Wnull-dereference', |
| 185 | '-Wunused-parameter', |
| 186 | '-Wdouble-promotion', |
| 187 | '-Wshadow', |
| 188 | '-Wno-psabi', |
| 189 | '-Wno-attributes', |
| 190 | language: 'cpp', |
| 191 | ) |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 192 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 193 | |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 194 | if (get_option('buildtype') != 'plain') |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 195 | if (get_option('b_lto') == true and get_option('optimization') != '0') |
| 196 | # Reduce the binary size by removing unnecessary |
| 197 | # dynamic symbol table entries |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 198 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 199 | add_project_arguments( |
| 200 | cxx.get_supported_arguments( |
| 201 | [ |
| 202 | '-fno-fat-lto-objects', |
| 203 | '-fvisibility=hidden', |
| 204 | '-fvisibility-inlines-hidden', |
| 205 | ], |
| 206 | ), |
| 207 | language: 'cpp', |
| 208 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 209 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 210 | if cxx.has_link_argument('-Wl,--exclude-libs,ALL') |
| 211 | add_project_link_arguments('-Wl,--exclude-libs,ALL', language: 'cpp') |
| 212 | endif |
George Liu | e820493 | 2021-02-01 14:42:49 +0800 | [diff] [blame] | 213 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 214 | endif |
| 215 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 216 | if ( |
| 217 | get_option('bmcweb-logging') != 'disabled' |
| 218 | or get_option('buildtype').startswith('debug') |
| 219 | ) |
| 220 | add_project_arguments(['-DBMCWEB_ENABLE_DEBUG'], language: 'cpp') |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 221 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 222 | summary('debug', '-DBMCWEB_ENABLE_DEBUG', section: 'Enabled Features') |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 223 | endif |
| 224 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 225 | # Set Compiler Security flags |
| 226 | |
| 227 | security_flags = [ |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 228 | '-fstack-protector-strong', |
| 229 | '-fPIE', |
| 230 | '-fPIC', |
| 231 | '-D_FORTIFY_SOURCE=2', |
| 232 | '-Wformat', |
| 233 | '-Wformat-security', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 234 | ] |
| 235 | |
| 236 | ## Add security flags for builds of type 'release','debugoptimized' and 'minsize' |
| 237 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 238 | if not ( |
| 239 | get_option('buildtype') == 'plain' |
| 240 | or get_option('buildtype').startswith('debug') |
| 241 | ) |
| 242 | add_project_arguments(cxx.get_supported_arguments([security_flags]), language: 'cpp') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 243 | endif |
| 244 | |
| 245 | # Boost dependency configuration |
| 246 | |
| 247 | add_project_arguments( |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 248 | cxx.get_supported_arguments( |
| 249 | [ |
| 250 | '-DBOOST_ASIO_DISABLE_CONCEPTS', |
| 251 | '-DBOOST_ALL_NO_LIB', |
| 252 | '-DBOOST_ALLOW_DEPRECATED_HEADERS', |
| 253 | '-DBOOST_ASIO_DISABLE_THREADS', |
| 254 | '-DBOOST_ASIO_NO_DEPRECATED', |
| 255 | '-DBOOST_ASIO_SEPARATE_COMPILATION', |
| 256 | '-DBOOST_BEAST_SEPARATE_COMPILATION', |
| 257 | '-DBOOST_EXCEPTION_DISABLE', |
| 258 | '-DBOOST_NO_EXCEPTIONS', |
| 259 | '-DBOOST_URL_NO_SOURCE_LOCATION', |
| 260 | '-DJSON_NOEXCEPTION', |
| 261 | '-DOPENSSL_NO_FILENAMES', |
| 262 | '-DSDBUSPLUS_DISABLE_BOOST_COROUTINES', |
| 263 | ], |
| 264 | ), |
| 265 | language: 'cpp', |
| 266 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 267 | |
| 268 | # Find the dependency modules, if not found use meson wrap to get them |
| 269 | # automatically during the configure step |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 270 | bmcweb_dependencies = [] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 271 | |
Nan Zhou | 8682c5a | 2021-11-13 11:00:07 -0800 | [diff] [blame] | 272 | pam = cxx.find_library('pam', required: true) |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 273 | atomic = cxx.find_library('atomic', required: true) |
Ed Tanous | e792399 | 2023-12-03 14:14:02 -0800 | [diff] [blame] | 274 | bmcweb_dependencies += [pam, atomic] |
| 275 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 276 | openssl = dependency('openssl', required: false, version: '>=3.0.0') |
Ed Tanous | e792399 | 2023-12-03 14:14:02 -0800 | [diff] [blame] | 277 | if not openssl.found() or get_option('b_sanitize') != 'none' |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 278 | openssl_proj = subproject( |
| 279 | 'openssl', |
| 280 | required: true, |
| 281 | default_options: ['warning_level=0', 'werror=false'], |
| 282 | ) |
| 283 | openssl = openssl_proj.get_variable('openssl_dep') |
| 284 | openssl = openssl.as_system('system') |
Ed Tanous | e792399 | 2023-12-03 14:14:02 -0800 | [diff] [blame] | 285 | endif |
| 286 | bmcweb_dependencies += [openssl] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 287 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 288 | nghttp2 = dependency('libnghttp2', version: '>=1.52.0', required: false) |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 289 | if not nghttp2.found() |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 290 | cmake = import('cmake') |
| 291 | opt_var = cmake.subproject_options() |
Ed Tanous | 211cfa4 | 2024-04-17 13:43:14 -0700 | [diff] [blame] | 292 | opt_var.add_cmake_defines( |
| 293 | { |
| 294 | 'ENABLE_LIB_ONLY': true, |
| 295 | 'ENABLE_STATIC_LIB': true, |
| 296 | }, |
| 297 | ) |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 298 | nghttp2_ex = cmake.subproject('nghttp2', options: opt_var) |
Ed Tanous | 211cfa4 | 2024-04-17 13:43:14 -0700 | [diff] [blame] | 299 | nghttp2 = nghttp2_ex.dependency('nghttp2') |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 300 | endif |
| 301 | bmcweb_dependencies += nghttp2 |
| 302 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 303 | sdbusplus = dependency('sdbusplus', required: false, include_type: 'system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 304 | if not sdbusplus.found() |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 305 | sdbusplus_proj = subproject('sdbusplus', required: true) |
| 306 | sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep') |
| 307 | sdbusplus = sdbusplus.as_system('system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 308 | endif |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 309 | bmcweb_dependencies += sdbusplus |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 310 | |
Ed Tanous | c9374ff | 2023-05-26 09:42:08 -0700 | [diff] [blame] | 311 | tinyxml = dependency( |
| 312 | 'tinyxml2', |
Cody Smith | 3a097b2 | 2022-05-19 14:22:32 -0700 | [diff] [blame] | 313 | include_type: 'system', |
Ed Tanous | c9374ff | 2023-05-26 09:42:08 -0700 | [diff] [blame] | 314 | version: '>=9.0.0', |
Konstantin Aladyshev | 60e299b | 2024-04-03 11:44:51 +0300 | [diff] [blame] | 315 | default_options: ['tests=false'], |
Cody Smith | 3a097b2 | 2022-05-19 14:22:32 -0700 | [diff] [blame] | 316 | ) |
Ed Tanous | c9374ff | 2023-05-26 09:42:08 -0700 | [diff] [blame] | 317 | if not tinyxml.found() |
| 318 | tinyxml_proj = subproject('tinyxml2', required: true) |
| 319 | tinyxml = tinyxml_proj.get_variable('tinyxml_dep') |
| 320 | tinyxml = tinyxml.as_system('system') |
| 321 | endif |
Cody Smith | 3a097b2 | 2022-05-19 14:22:32 -0700 | [diff] [blame] | 322 | bmcweb_dependencies += tinyxml |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 323 | |
| 324 | systemd = dependency('systemd') |
| 325 | zlib = dependency('zlib') |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 326 | bmcweb_dependencies += [systemd, zlib] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 327 | |
Patrick Williams | dfd5547 | 2023-12-07 11:50:37 -0600 | [diff] [blame] | 328 | nlohmann_json_dep = dependency('nlohmann_json', version: '>=3.11.2', include_type: 'system') |
| 329 | bmcweb_dependencies += nlohmann_json_dep |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 330 | |
Carson Labrado | 2b5b4da | 2023-10-18 00:02:10 +0000 | [diff] [blame] | 331 | boost = dependency( |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 332 | 'boost', |
| 333 | modules: [ |
| 334 | 'url', |
Carson Labrado | 2b5b4da | 2023-10-18 00:02:10 +0000 | [diff] [blame] | 335 | ], |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 336 | version: '>=1.84.0', |
| 337 | required: false, |
| 338 | include_type: 'system', |
Carson Labrado | 2b5b4da | 2023-10-18 00:02:10 +0000 | [diff] [blame] | 339 | ) |
Ed Tanous | 6fd2955 | 2023-10-04 09:40:14 -0700 | [diff] [blame] | 340 | if boost.found() |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 341 | bmcweb_dependencies += [boost] |
Ed Tanous | 6fd2955 | 2023-10-04 09:40:14 -0700 | [diff] [blame] | 342 | else |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 343 | cmake = import('cmake') |
| 344 | opt = cmake.subproject_options() |
| 345 | opt.add_cmake_defines( |
| 346 | { |
| 347 | 'BOOST_INCLUDE_LIBRARIES': 'asio;beast;callable_traits;headers;process;type_index;url;uuid', |
| 348 | 'BUILD_SHARED_LIBS': 'OFF', |
| 349 | }, |
| 350 | ) |
Ed Tanous | 144983c | 2024-03-28 00:39:10 -0700 | [diff] [blame] | 351 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 352 | boost = cmake.subproject('boost', required: true, options: opt) |
| 353 | boost_asio = boost.dependency('boost_asio').as_system() |
| 354 | boost_beast = boost.dependency('boost_beast').as_system() |
| 355 | boost_callable_traits = boost.dependency('boost_callable_traits').as_system() |
| 356 | boost_headers = boost.dependency('boost_headers').as_system() |
| 357 | boost_process = boost.dependency('boost_process').as_system() |
| 358 | boost_type_index = boost.dependency('boost_type_index').as_system() |
| 359 | boost_url = boost.dependency('boost_url').as_system() |
| 360 | boost_uuid = boost.dependency('boost_uuid').as_system() |
| 361 | bmcweb_dependencies += [ |
| 362 | boost_asio, |
| 363 | boost_beast, |
| 364 | boost_callable_traits, |
| 365 | boost_headers, |
| 366 | boost_process, |
| 367 | boost_type_index, |
| 368 | boost_url, |
| 369 | boost_uuid, |
| 370 | ] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 371 | endif |
| 372 | |
Patrick Williams | 549bed2 | 2023-11-29 06:45:06 -0600 | [diff] [blame] | 373 | if get_option('tests').allowed() |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 374 | gtest = dependency( |
| 375 | 'gtest', |
| 376 | main: true, |
| 377 | version: '>=1.14.0', |
| 378 | disabler: true, |
| 379 | required: false, |
| 380 | ) |
| 381 | gmock = dependency('gmock', required: false) |
| 382 | if not gtest.found() and get_option('tests').allowed() |
| 383 | gtest_proj = subproject('gtest', required: true) |
| 384 | gtest = gtest_proj.get_variable('gtest_main_dep') |
| 385 | gmock = gtest_proj.get_variable('gmock_dep') |
| 386 | endif |
| 387 | gtest = gtest.as_system('system') |
| 388 | gmock = gmock.as_system('system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 389 | endif |
| 390 | |
Patrick Williams | 4efe3e0 | 2023-04-12 08:05:58 -0500 | [diff] [blame] | 391 | systemd_system_unit_dir = systemd.get_variable('systemdsystemunitdir') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 392 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 393 | bindir = get_option('prefix') + '/' + get_option('bindir') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 394 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 395 | summary( |
| 396 | { |
| 397 | 'prefix': get_option('prefix'), |
| 398 | 'bindir': bindir, |
| 399 | 'systemd unit directory': systemd_system_unit_dir, |
| 400 | }, |
| 401 | section: 'Directories', |
| 402 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 403 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 404 | install_subdir('static', install_dir: 'share/www', strip_directory: true) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 405 | |
Nan Zhou | 307386e | 2022-10-12 20:29:34 +0000 | [diff] [blame] | 406 | # Config subdirectory |
| 407 | |
| 408 | subdir('config') |
| 409 | bmcweb_dependencies += conf_h_dep |
| 410 | |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 411 | # Source files |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 412 | fs = import('fs') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 413 | |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 414 | srcfiles_bmcweb = files( |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 415 | # end large files |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 416 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 417 | 'redfish-core/src/error_messages.cpp', |
| 418 | # Begin large files, should be at the beginning |
| 419 | 'redfish-core/src/redfish.cpp', |
| 420 | 'redfish-core/src/registries.cpp', |
| 421 | 'redfish-core/src/utils/dbus_utils.cpp', |
| 422 | 'redfish-core/src/utils/json_utils.cpp', |
| 423 | 'redfish-core/src/utils/time_utils.cpp', |
| 424 | 'src/boost_asio.cpp', |
| 425 | 'src/boost_asio_ssl.cpp', |
| 426 | 'src/boost_beast.cpp', |
| 427 | 'src/dbus_singleton.cpp', |
| 428 | 'src/json_html_serializer.cpp', |
| 429 | 'src/ossl_random.cpp', |
| 430 | 'src/webserver_run.cpp', |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 431 | ) |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 432 | |
Ed Tanous | 42bbcd8 | 2023-01-07 18:04:28 -0800 | [diff] [blame] | 433 | bmcweblib = static_library( |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 434 | 'bmcweblib', |
| 435 | srcfiles_bmcweb, |
| 436 | include_directories: incdir, |
| 437 | dependencies: bmcweb_dependencies, |
Ed Tanous | 42bbcd8 | 2023-01-07 18:04:28 -0800 | [diff] [blame] | 438 | ) |
| 439 | |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 440 | # Generate the bmcweb executable |
| 441 | executable( |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 442 | 'bmcweb', |
| 443 | 'src/webserver_main.cpp', |
| 444 | include_directories: incdir, |
| 445 | dependencies: bmcweb_dependencies, |
| 446 | link_with: bmcweblib, |
| 447 | link_args: '-Wl,--gc-sections', |
| 448 | install: true, |
| 449 | install_dir: bindir, |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 450 | ) |
| 451 | |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 452 | srcfiles_unittest = files( |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 453 | 'test/http/crow_getroutes_test.cpp', |
| 454 | 'test/http/http2_connection_test.cpp', |
| 455 | 'test/http/http_body_test.cpp', |
| 456 | 'test/http/http_connection_test.cpp', |
| 457 | 'test/http/http_response_test.cpp', |
| 458 | 'test/http/mutual_tls.cpp', |
| 459 | 'test/http/mutual_tls_meta.cpp', |
| 460 | 'test/http/parsing_test.cpp', |
| 461 | 'test/http/router_test.cpp', |
| 462 | 'test/http/server_sent_event_test.cpp', |
| 463 | 'test/http/utility_test.cpp', |
| 464 | 'test/http/verb_test.cpp', |
| 465 | 'test/include/async_resolve_test.cpp', |
| 466 | 'test/include/credential_pipe_test.cpp', |
| 467 | 'test/include/dbus_utility_test.cpp', |
| 468 | 'test/include/google/google_service_root_test.cpp', |
| 469 | 'test/include/http_utility_test.cpp', |
| 470 | 'test/include/human_sort_test.cpp', |
| 471 | 'test/include/ibm/configfile_test.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 472 | 'test/include/json_html_serializer.cpp', |
| 473 | 'test/include/multipart_test.cpp', |
| 474 | 'test/include/openbmc_dbus_rest_test.cpp', |
| 475 | 'test/include/ossl_random.cpp', |
| 476 | 'test/include/str_utility_test.cpp', |
| 477 | 'test/redfish-core/include/privileges_test.cpp', |
| 478 | 'test/redfish-core/include/redfish_aggregator_test.cpp', |
| 479 | 'test/redfish-core/include/registries_test.cpp', |
| 480 | 'test/redfish-core/include/utils/dbus_utils.cpp', |
| 481 | 'test/redfish-core/include/utils/hex_utils_test.cpp', |
| 482 | 'test/redfish-core/include/utils/ip_utils_test.cpp', |
| 483 | 'test/redfish-core/include/utils/json_utils_test.cpp', |
| 484 | 'test/redfish-core/include/utils/query_param_test.cpp', |
| 485 | 'test/redfish-core/include/utils/stl_utils_test.cpp', |
| 486 | 'test/redfish-core/include/utils/time_utils_test.cpp', |
| 487 | 'test/redfish-core/lib/chassis_test.cpp', |
| 488 | 'test/redfish-core/lib/log_services_dump_test.cpp', |
| 489 | 'test/redfish-core/lib/log_services_test.cpp', |
| 490 | 'test/redfish-core/lib/manager_diagnostic_data_test.cpp', |
| 491 | 'test/redfish-core/lib/power_subsystem_test.cpp', |
| 492 | 'test/redfish-core/lib/sensors_test.cpp', |
| 493 | 'test/redfish-core/lib/service_root_test.cpp', |
| 494 | 'test/redfish-core/lib/system_test.cpp', |
| 495 | 'test/redfish-core/lib/thermal_subsystem_test.cpp', |
| 496 | 'test/redfish-core/lib/update_service_test.cpp', |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 497 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 498 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 499 | if (get_option('tests').allowed()) |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 500 | # generate the test executable |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 501 | foreach test_src : srcfiles_unittest |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 502 | test_bin = executable( |
| 503 | fs.stem(test_src), |
| 504 | test_src, |
| 505 | link_with: bmcweblib, |
| 506 | include_directories: incdir, |
| 507 | install_dir: bindir, |
| 508 | dependencies: bmcweb_dependencies |
| 509 | + [ |
| 510 | gtest, |
| 511 | gmock, |
| 512 | ], |
| 513 | ) |
| 514 | test(fs.stem(test_src), test_bin) |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 515 | endforeach |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 516 | endif |