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