Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 1 | project('bmcweb', 'cpp', |
| 2 | version : '1.0', |
Patrick Williams | c52ee72 | 2021-10-06 15:17:42 -0500 | [diff] [blame] | 3 | meson_version: '>=0.57.0', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 4 | default_options: [ |
Manojkiran Eda | cb2ed19 | 2021-02-15 08:30:43 +0530 | [diff] [blame] | 5 | 'b_lto_mode=default', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 6 | 'b_lto_threads=0', |
| 7 | 'b_lto=true', |
| 8 | 'b_ndebug=if-release', |
| 9 | 'buildtype=debugoptimized', |
| 10 | 'cpp_rtti=false', |
| 11 | 'cpp_std=c++20', |
| 12 | 'warning_level=3', |
| 13 | 'werror=true', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 14 | ]) |
| 15 | |
| 16 | # Project related links |
| 17 | |
| 18 | project_pretty_name = 'bmcweb' |
| 19 | project_url = 'https://github.com/openbmc/' + project_pretty_name |
| 20 | project_issues_url = project_url + '/issues/new' |
| 21 | summary('Issues',project_issues_url, section: 'Report Issues') |
| 22 | |
| 23 | # Validate the c++ Standard |
| 24 | |
Patrick Williams | c52ee72 | 2021-10-06 15:17:42 -0500 | [diff] [blame] | 25 | if get_option('cpp_std') != 'c++20' |
| 26 | error('This project requires c++20 support') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 27 | endif |
| 28 | |
| 29 | # Get compiler and default build type |
| 30 | |
| 31 | cxx = meson.get_compiler('cpp') |
| 32 | build = get_option('buildtype') |
| 33 | optimization = get_option('optimization') |
| 34 | summary('Build Type',build, section : 'Build Info') |
| 35 | summary('Optimization',optimization, section : 'Build Info') |
| 36 | |
Ed Tanous | 5e34b67 | 2021-02-05 14:21:27 -0800 | [diff] [blame] | 37 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 38 | # remove debug information for minsize buildtype |
| 39 | if(get_option('buildtype') == 'minsize') |
Ed Tanous | 5e34b67 | 2021-02-05 14:21:27 -0800 | [diff] [blame] | 40 | add_project_arguments(['-fdata-sections', '-ffunction-sections'], language : 'cpp') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 41 | add_project_arguments('-DNDEBUG', language : 'cpp') |
| 42 | endif |
| 43 | |
| 44 | # Disable lto when compiling with no optimization |
| 45 | if(get_option('optimization') == '0') |
| 46 | add_project_arguments('-fno-lto', language: 'cpp') |
| 47 | message('Disabling lto & its supported features as optimization is disabled') |
| 48 | endif |
| 49 | |
| 50 | # Include Directories |
| 51 | |
Ed Tanous | cf2f932 | 2021-09-22 15:34:41 -0700 | [diff] [blame] | 52 | incdir = include_directories( |
| 53 | 'include', |
| 54 | 'redfish-core/include', |
| 55 | 'redfish-core/lib', |
| 56 | 'http' |
| 57 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 58 | |
| 59 | # Get the options and enable the respective features |
| 60 | ## create a MAP of "options : feature_flag" |
| 61 | |
| 62 | feature_map = { |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 63 | 'basic-auth' : '-DBMCWEB_ENABLE_BASIC_AUTHENTICATION', |
| 64 | 'cookie-auth' : '-DBMCWEB_ENABLE_COOKIE_AUTHENTICATION', |
| 65 | 'google-api' : '-DBMCWEB_ENABLE_GOOGLE_API', |
| 66 | 'host-serial-socket' : '-DBMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET', |
| 67 | 'ibm-management-console' : '-DBMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE', |
Nan Zhou | a43ea82 | 2022-05-27 00:42:44 +0000 | [diff] [blame] | 68 | 'insecure-disable-auth' : '-DBMCWEB_INSECURE_DISABLE_AUTHX', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 69 | 'insecure-disable-csrf' : '-DBMCWEB_INSECURE_DISABLE_CSRF_PREVENTION', |
| 70 | 'insecure-disable-ssl' : '-DBMCWEB_INSECURE_DISABLE_SSL', |
| 71 | 'insecure-push-style-notification' : '-DBMCWEB_INSECURE_ENABLE_HTTP_PUSH_STYLE_EVENTING', |
| 72 | 'insecure-tftp-update' : '-DBMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE', |
| 73 | 'kvm' : '-DBMCWEB_ENABLE_KVM' , |
| 74 | 'mutual-tls-auth' : '-DBMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION', |
Carson Labrado | 7fb3356 | 2022-04-18 23:26:56 +0000 | [diff] [blame] | 75 | 'redfish-aggregation' : '-DBMCWEB_ENABLE_REDFISH_AGGREGATION', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 76 | 'redfish-allow-deprecated-power-thermal' : '-DBMCWEB_ALLOW_DEPRECATED_POWER_THERMAL', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 77 | 'redfish-bmc-journal' : '-DBMCWEB_ENABLE_REDFISH_BMC_JOURNAL', |
| 78 | 'redfish-cpu-log' : '-DBMCWEB_ENABLE_REDFISH_CPU_LOG', |
| 79 | 'redfish-dbus-log' : '-DBMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES', |
| 80 | 'redfish-dump-log' : '-DBMCWEB_ENABLE_REDFISH_DUMP_LOG', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 81 | 'redfish-host-logger' : '-DBMCWEB_ENABLE_REDFISH_HOST_LOGGER', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 82 | 'redfish-new-powersubsystem-thermalsubsystem' : '-DBMCWEB_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 83 | 'redfish-provisioning-feature' : '-DBMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE', |
Ed Tanous | 4dc23f3 | 2022-05-11 11:32:19 -0700 | [diff] [blame] | 84 | 'redfish-post-to-old-updateservice' : '-DBMCWEB_ENABLE_REDFISH_UPDATESERVICE_OLD_POST_URL', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 85 | 'redfish' : '-DBMCWEB_ENABLE_REDFISH', |
| 86 | 'rest' : '-DBMCWEB_ENABLE_DBUS_REST', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 87 | 'session-auth' : '-DBMCWEB_ENABLE_SESSION_AUTHENTICATION', |
| 88 | 'static-hosting' : '-DBMCWEB_ENABLE_STATIC_HOSTING', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 89 | 'vm-websocket' : '-DBMCWEB_ENABLE_VM_WEBSOCKET', |
| 90 | 'xtoken-auth' : '-DBMCWEB_ENABLE_XTOKEN_AUTHENTICATION', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 91 | #'vm-nbdproxy' : '-DBMCWEB_ENABLE_VM_NBDPROXY', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | # Get the options status and build a project summary to show which flags are |
| 95 | # being enabled during the configuration time. |
| 96 | |
| 97 | foreach option_key,option_value : feature_map |
| 98 | if(get_option(option_key).enabled()) |
| 99 | if(option_key == 'mutual-tls-auth' or option_key == 'insecure-disable-ssl') |
| 100 | if(get_option('insecure-disable-ssl').disabled() or get_option('mutual-tls-auth').disabled()) |
| 101 | add_project_arguments(option_value,language:'cpp') |
| 102 | summary(option_key,option_value, section : 'Enabled Features') |
| 103 | endif |
Nan Zhou | 3acced2 | 2022-07-12 23:21:02 +0000 | [diff] [blame] | 104 | elif (option_key in ['basic-auth', 'cookie-auth', 'session-auth', 'xtoken-auth', 'mutual-tls-auth']) |
| 105 | if (get_option('insecure-disable-auth').disabled()) |
| 106 | add_project_arguments(option_value, language:'cpp') |
| 107 | summary(option_key,option_value, section : 'Enabled Features') |
| 108 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 109 | else |
| 110 | summary(option_key,option_value, section : 'Enabled Features') |
| 111 | add_project_arguments(option_value,language:'cpp') |
| 112 | endif |
| 113 | else |
| 114 | if(option_key == 'insecure-disable-ssl') |
| 115 | summary('ssl','-DBMCWEB_ENABLE_SSL', section : 'Enabled Features') |
| 116 | add_project_arguments('-DBMCWEB_ENABLE_SSL', language : 'cpp') |
| 117 | endif |
| 118 | endif |
| 119 | endforeach |
| 120 | |
| 121 | if(get_option('tests').enabled()) |
| 122 | summary('unittest','NA', section : 'Enabled Features') |
| 123 | endif |
| 124 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 125 | # Add compiler arguments |
| 126 | |
| 127 | # -Wpedantic, -Wextra comes by default with warning level |
| 128 | add_project_arguments( |
| 129 | cxx.get_supported_arguments([ |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 130 | '-Wcast-align', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 131 | '-Wconversion', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 132 | '-Wformat=2', |
| 133 | '-Wold-style-cast', |
| 134 | '-Woverloaded-virtual', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 135 | '-Wsign-conversion', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 136 | '-Wunused', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 137 | '-Wno-attributes', |
| 138 | ]), |
| 139 | language: 'cpp' |
| 140 | ) |
| 141 | |
| 142 | if (cxx.get_id() == 'clang' and cxx.version().version_compare('>9.0')) |
| 143 | add_project_arguments( |
| 144 | cxx.get_supported_arguments([ |
| 145 | '-Weverything', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 146 | '-Wno-c++98-compat-pedantic', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 147 | '-Wno-c++98-compat', |
| 148 | '-Wno-documentation-unknown-command', |
| 149 | '-Wno-documentation', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 150 | '-Wno-exit-time-destructors', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 151 | '-Wno-global-constructors', |
| 152 | '-Wno-newline-eof', |
| 153 | '-Wno-padded', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 154 | '-Wno-shadow', |
| 155 | '-Wno-used-but-marked-unused', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 156 | '-Wno-weak-vtables', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 157 | ]), |
| 158 | language:'cpp') |
| 159 | endif |
| 160 | |
| 161 | # if compiler is gnu-gcc , and version is > 8.0 then we add few more |
| 162 | # compiler arguments , we know that will pass |
| 163 | |
| 164 | if (cxx.get_id() == 'gcc' and cxx.version().version_compare('>8.0')) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 165 | add_project_arguments( |
| 166 | cxx.get_supported_arguments([ |
| 167 | '-Wduplicated-cond', |
| 168 | '-Wduplicated-branches', |
| 169 | '-Wlogical-op', |
| 170 | '-Wunused-parameter', |
| 171 | '-Wnull-dereference', |
| 172 | '-Wdouble-promotion', |
Ed Tanous | 8a59281 | 2022-06-04 09:06:59 -0700 | [diff] [blame] | 173 | '-Wshadow', |
Ed Tanous | 30f11eb | 2022-05-25 10:42:15 -0700 | [diff] [blame] | 174 | '-Wno-psabi', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 175 | ]), |
| 176 | language:'cpp') |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 177 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 178 | |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 179 | if (get_option('buildtype') != 'plain') |
| 180 | if (get_option('b_lto') == true and get_option('optimization')!='0') |
| 181 | # Reduce the binary size by removing unnecessary |
| 182 | # dynamic symbol table entries |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 183 | |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 184 | add_project_arguments( |
| 185 | cxx.get_supported_arguments([ |
| 186 | '-fno-fat-lto-objects', |
| 187 | '-fvisibility=hidden', |
| 188 | '-fvisibility-inlines-hidden' |
| 189 | ]), |
| 190 | language: 'cpp') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 191 | |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 192 | if cxx.has_link_argument('-Wl,--exclude-libs,ALL') |
| 193 | add_project_link_arguments('-Wl,--exclude-libs,ALL', language: 'cpp') |
George Liu | e820493 | 2021-02-01 14:42:49 +0800 | [diff] [blame] | 194 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 195 | endif |
| 196 | endif |
| 197 | |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 198 | if( get_option('bmcweb-logging').enabled() or \ |
| 199 | get_option('buildtype').startswith('debug')) |
| 200 | add_project_arguments([ |
| 201 | '-DBMCWEB_ENABLE_LOGGING', |
| 202 | '-DBMCWEB_ENABLE_DEBUG' |
| 203 | ], |
| 204 | language : 'cpp') |
| 205 | |
| 206 | summary({'debug' :'-DBMCWEB_ENABLE_DEBUG', |
| 207 | 'logging' : '-DBMCWEB_ENABLE_LOGGING', |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 208 | |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 209 | },section : 'Enabled Features') |
| 210 | endif |
| 211 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 212 | # Set Compiler Security flags |
| 213 | |
| 214 | security_flags = [ |
Ed Tanous | cf2f932 | 2021-09-22 15:34:41 -0700 | [diff] [blame] | 215 | '-fstack-protector-strong', |
| 216 | '-fPIE', |
| 217 | '-fPIC', |
| 218 | '-D_FORTIFY_SOURCE=2', |
| 219 | '-Wformat', |
| 220 | '-Wformat-security' |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 221 | ] |
| 222 | |
| 223 | ## Add security flags for builds of type 'release','debugoptimized' and 'minsize' |
| 224 | |
| 225 | if not (get_option('buildtype') == 'plain' or get_option('buildtype').startswith('debug')) |
| 226 | add_project_arguments( |
| 227 | cxx.get_supported_arguments([ |
| 228 | security_flags |
| 229 | ]), |
| 230 | language: 'cpp') |
| 231 | endif |
| 232 | |
| 233 | # Boost dependency configuration |
| 234 | |
| 235 | add_project_arguments( |
| 236 | cxx.get_supported_arguments([ |
Ed Tanous | cf2f932 | 2021-09-22 15:34:41 -0700 | [diff] [blame] | 237 | '-DBOOST_ALL_NO_LIB', |
Ed Tanous | cf2f932 | 2021-09-22 15:34:41 -0700 | [diff] [blame] | 238 | '-DBOOST_ALLOW_DEPRECATED_HEADERS', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 239 | '-DBOOST_ASIO_DISABLE_THREADS', |
| 240 | '-DBOOST_ASIO_NO_DEPRECATED', |
| 241 | '-DBOOST_ASIO_SEPARATE_COMPILATION', |
| 242 | '-DBOOST_BEAST_SEPARATE_COMPILATION', |
| 243 | '-DBOOST_BEAST_USE_STD_STRING_VIEW', |
Ed Tanous | 9e710e7 | 2022-03-12 17:40:04 -0800 | [diff] [blame] | 244 | '-DBOOST_EXCEPTION_DISABLE', |
| 245 | '-DJSON_NOEXCEPTION', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 246 | ]), |
| 247 | language : 'cpp') |
| 248 | |
| 249 | # Find the dependency modules, if not found use meson wrap to get them |
| 250 | # automatically during the configure step |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 251 | bmcweb_dependencies = [] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 252 | |
Nan Zhou | 8682c5a | 2021-11-13 11:00:07 -0800 | [diff] [blame] | 253 | pam = cxx.find_library('pam', required: true) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 254 | atomic = cxx.find_library('atomic', required: true) |
| 255 | openssl = dependency('openssl', required : true) |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 256 | bmcweb_dependencies += [pam, atomic, openssl] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 257 | |
Ed Tanous | 7bb985e | 2021-09-02 14:31:40 -0700 | [diff] [blame] | 258 | sdbusplus = dependency('sdbusplus', required : false, include_type: 'system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 259 | if not sdbusplus.found() |
| 260 | sdbusplus_proj = subproject('sdbusplus', required: true) |
| 261 | sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep') |
| 262 | sdbusplus = sdbusplus.as_system('system') |
| 263 | endif |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 264 | bmcweb_dependencies += sdbusplus |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 265 | |
Cody Smith | 3a097b2 | 2022-05-19 14:22:32 -0700 | [diff] [blame] | 266 | tinyxml = dependency('tinyxml2', |
| 267 | default_options: ['tests=false'], |
| 268 | include_type: 'system', |
| 269 | ) |
| 270 | bmcweb_dependencies += tinyxml |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 271 | |
| 272 | systemd = dependency('systemd') |
| 273 | zlib = dependency('zlib') |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 274 | bmcweb_dependencies += [systemd, zlib] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 275 | |
| 276 | if cxx.has_header('nlohmann/json.hpp') |
| 277 | nlohmann_json = declare_dependency() |
| 278 | else |
Josh Lehan | 259df35 | 2021-10-07 15:20:02 -0700 | [diff] [blame] | 279 | nlohmann_json_proj = subproject('nlohmann', required: true) |
| 280 | nlohmann_json = nlohmann_json_proj.get_variable('nlohmann_json_dep') |
Ed Tanous | b00dcc2 | 2021-02-23 12:52:50 -0800 | [diff] [blame] | 281 | nlohmann_json = nlohmann_json.as_system('system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 282 | endif |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 283 | bmcweb_dependencies += nlohmann_json |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 284 | |
Nan Zhou | 6bbda2c | 2022-02-21 12:47:41 -0800 | [diff] [blame] | 285 | boost = dependency('boost',version : '>=1.78.0', required : false, include_type: 'system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 286 | if not boost.found() |
| 287 | subproject('boost', required: false) |
Nan Zhou | 6bbda2c | 2022-02-21 12:47:41 -0800 | [diff] [blame] | 288 | boost_inc = include_directories('subprojects/boost_1_78_0/', is_system:true) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 289 | boost = declare_dependency(include_directories : boost_inc) |
Ed Tanous | b00dcc2 | 2021-02-23 12:52:50 -0800 | [diff] [blame] | 290 | boost = boost.as_system('system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 291 | endif |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 292 | bmcweb_dependencies += boost |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 293 | |
| 294 | if cxx.has_header('boost/url/url_view.hpp') |
| 295 | boost_url = declare_dependency() |
| 296 | else |
| 297 | subproject('boost-url', required: false) |
| 298 | boost_url_inc = include_directories('subprojects/boost-url/include', is_system:true) |
| 299 | boost_url= declare_dependency(include_directories : boost_url_inc) |
Ed Tanous | b00dcc2 | 2021-02-23 12:52:50 -0800 | [diff] [blame] | 300 | boost_url = boost_url.as_system('system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 301 | endif |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 302 | bmcweb_dependencies += boost_url |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 303 | |
| 304 | if get_option('tests').enabled() |
| 305 | gtest = dependency('gtest', main: true,disabler: true, required : false) |
| 306 | gmock = dependency('gmock', required : false) |
| 307 | if not gtest.found() and get_option('tests').enabled() |
| 308 | gtest_proj = subproject('gtest', required: true) |
| 309 | gtest = gtest_proj.get_variable('gtest_main_dep') |
| 310 | gmock = gtest_proj.get_variable('gmock_dep') |
| 311 | endif |
Ed Tanous | b00dcc2 | 2021-02-23 12:52:50 -0800 | [diff] [blame] | 312 | gtest = gtest.as_system('system') |
| 313 | gmock = gmock.as_system('system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 314 | endif |
| 315 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 316 | # Gather the Configuration data |
| 317 | |
| 318 | conf_data = configuration_data() |
Ed Tanous | 0260d9d | 2021-02-07 19:31:07 +0000 | [diff] [blame] | 319 | conf_data.set('BMCWEB_HTTP_REQ_BODY_LIMIT_MB', get_option('http-body-limit')) |
| 320 | xss_enabled = get_option('insecure-disable-xss') |
Ed Tanous | feaf150 | 2021-02-23 08:53:50 -0800 | [diff] [blame] | 321 | conf_data.set10('BMCWEB_INSECURE_DISABLE_XSS_PREVENTION', xss_enabled.enabled()) |
Ed Tanous | fa0b217 | 2022-03-24 10:25:03 -0700 | [diff] [blame] | 322 | enable_redfish_query = get_option('insecure-enable-redfish-query') |
| 323 | conf_data.set10('BMCWEB_INSECURE_ENABLE_QUERY_PARAMS', enable_redfish_query.enabled()) |
Carson Labrado | 7fb3356 | 2022-04-18 23:26:56 +0000 | [diff] [blame] | 324 | # enable_redfish_aggregation = get_option('redfish-aggregation') |
| 325 | # conf_data.set10('BMCWEB_ENABLE_REDFISH_AGGREGATION', enable_redfish_aggregation.enabled()) |
Ed Tanous | eb1c47d | 2022-02-09 11:47:27 -0800 | [diff] [blame] | 326 | insecure_push_style_notification = get_option('insecure-push-style-notification') |
| 327 | conf_data.set10('BMCWEB_INSECURE_ENABLE_HTTP_PUSH_STYLE_EVENTING', insecure_push_style_notification.enabled()) |
Ed Tanous | 0260d9d | 2021-02-07 19:31:07 +0000 | [diff] [blame] | 328 | conf_data.set('MESON_INSTALL_PREFIX', get_option('prefix')) |
Vivekanand Veeracholan | 54d1355 | 2021-06-14 19:16:36 -0700 | [diff] [blame] | 329 | conf_data.set('HTTPS_PORT', get_option('https_port')) |
Ed Tanous | 7531298 | 2021-02-11 14:26:02 -0800 | [diff] [blame] | 330 | configure_file(input: 'bmcweb_config.h.in', |
| 331 | output: 'bmcweb_config.h', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 332 | configuration: conf_data) |
| 333 | |
| 334 | # Configure and install systemd unit files |
| 335 | |
Patrick Williams | 6a77993 | 2021-10-12 20:08:44 -0500 | [diff] [blame] | 336 | systemd_system_unit_dir = systemd.get_variable(pkgconfig: 'systemdsystemunitdir') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 337 | |
| 338 | bindir = get_option('prefix') + '/' +get_option('bindir') |
| 339 | |
| 340 | summary({ |
| 341 | 'prefix' : get_option('prefix'), |
| 342 | 'bindir' : bindir, |
| 343 | 'systemd unit directory' : systemd_system_unit_dir |
| 344 | }, section : 'Directories') |
| 345 | |
Vivekanand Veeracholan | 54d1355 | 2021-06-14 19:16:36 -0700 | [diff] [blame] | 346 | configure_file(input : 'bmcweb.socket.in', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 347 | output : 'bmcweb.socket', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 348 | install_dir: systemd_system_unit_dir, |
Vivekanand Veeracholan | 54d1355 | 2021-06-14 19:16:36 -0700 | [diff] [blame] | 349 | configuration: conf_data, |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 350 | install : true) |
| 351 | |
| 352 | configure_file(input : 'bmcweb.service.in', |
| 353 | output : 'bmcweb.service', |
| 354 | install_dir: systemd_system_unit_dir, |
| 355 | configuration: conf_data, |
| 356 | install : true) |
| 357 | |
| 358 | # Copy pam-webserver to etc/pam.d |
| 359 | configure_file(input : 'pam-webserver', |
| 360 | output : 'webserver', |
| 361 | copy : true, |
| 362 | install_dir: '/etc/pam.d', |
| 363 | install : true) |
| 364 | |
| 365 | install_subdir('static', install_dir : 'share/www', strip_directory : true) |
| 366 | |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 367 | # Source files |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 368 | |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 369 | srcfiles_bmcweb = [ |
| 370 | 'redfish-core/src/error_messages.cpp', |
| 371 | 'redfish-core/src/utils/json_utils.cpp', |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 372 | 'src/boost_asio_ssl.cpp', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 373 | 'src/boost_asio.cpp', |
| 374 | 'src/boost_beast.cpp', |
| 375 | 'src/boost_url.cpp', |
Nan Zhou | 6384e32 | 2022-06-23 22:28:25 +0000 | [diff] [blame] | 376 | 'src/dbus_singleton.cpp', |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 377 | ] |
| 378 | |
| 379 | # Generate the bmcweb executable |
| 380 | executable( |
| 381 | 'bmcweb', |
| 382 | srcfiles_bmcweb + ['src/webserver_main.cpp'], |
| 383 | include_directories : incdir, |
| 384 | dependencies: bmcweb_dependencies, |
| 385 | link_args: '-Wl,--gc-sections', |
| 386 | install: true, |
| 387 | install_dir:bindir |
| 388 | ) |
| 389 | |
| 390 | srcfiles_unittest = [ |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 391 | 'http/ut/utility_test.cpp', |
Ed Tanous | 88a03c5 | 2022-03-14 10:16:07 -0700 | [diff] [blame] | 392 | 'http/ut/router_test.cpp', |
Nan Zhou | 322204a | 2022-07-03 06:07:21 +0000 | [diff] [blame] | 393 | 'include/google/google_service_root_test.cpp', |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 394 | 'include/ut/dbus_utility_test.cpp', |
| 395 | 'include/ut/http_utility_test.cpp', |
| 396 | 'include/ut/human_sort_test.cpp', |
Ed Tanous | c5ba4c2 | 2022-02-07 09:59:55 -0800 | [diff] [blame] | 397 | 'include/ut/multipart_test.cpp', |
Josh Lehan | 482c45a | 2022-03-29 17:10:44 -0700 | [diff] [blame] | 398 | 'include/ut/openbmc_dbus_rest_test.cpp', |
Ed Tanous | 7cf436c | 2022-03-22 23:53:51 -0700 | [diff] [blame] | 399 | 'redfish-core/include/utils/query_param_test.cpp', |
| 400 | 'redfish-core/lib/ut/service_root_test.cpp', |
Xiaochao Ma | 2973963 | 2021-03-02 15:53:13 +0800 | [diff] [blame^] | 401 | 'redfish-core/lib/ut/thermal_subsystem_test.cpp', |
Nan Zhou | cf7eba0 | 2022-07-21 23:53:20 +0000 | [diff] [blame] | 402 | 'redfish-core/lib/chassis_test.cpp', |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 403 | 'redfish-core/ut/configfile_test.cpp', |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 404 | 'redfish-core/ut/hex_utils_test.cpp', |
Nan Zhou | 774258e | 2022-07-03 22:22:47 +0000 | [diff] [blame] | 405 | 'redfish-core/ut/ip_utils_test.cpp', |
Willy Tu | 15ed678 | 2021-12-14 11:03:16 -0800 | [diff] [blame] | 406 | 'redfish-core/ut/json_utils_test.cpp', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 407 | 'redfish-core/ut/lock_test.cpp', |
| 408 | 'redfish-core/ut/privileges_test.cpp', |
Ed Tanous | c5ba4c2 | 2022-02-07 09:59:55 -0800 | [diff] [blame] | 409 | 'redfish-core/ut/registries_test.cpp', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 410 | 'redfish-core/ut/stl_utils_test.cpp', |
| 411 | 'redfish-core/ut/time_utils_test.cpp', |
Nan Zhou | 5ad7720 | 2022-06-13 22:33:55 +0000 | [diff] [blame] | 412 | 'src/crow_getroutes_test.cpp', |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 413 | ] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 414 | |
| 415 | if(get_option('tests').enabled()) |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 416 | # generate the test executable |
| 417 | ut_bin = executable( |
| 418 | 'bmcweb_unit_test', |
| 419 | srcfiles_unittest + srcfiles_bmcweb, |
| 420 | include_directories : incdir, |
| 421 | install_dir: bindir, |
| 422 | dependencies: bmcweb_dependencies + [ |
| 423 | gtest, |
| 424 | gmock, |
| 425 | ] |
| 426 | ) |
| 427 | test('bmcweb_unit_test', ut_bin) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 428 | endif |