Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 1 | project('bmcweb', 'cpp', |
| 2 | version : '1.0', |
Ed Tanous | 6107da1 | 2022-10-25 12:05:02 -0700 | [diff] [blame] | 3 | meson_version: '>=0.63.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 | |
Ed Tanous | f8ca6d7 | 2022-06-28 12:12:03 -0700 | [diff] [blame] | 44 | if(get_option('dns-resolver') == 'systemd-dbus') |
| 45 | add_project_arguments('-DBMCWEB_DBUS_DNS_RESOLVER', language : 'cpp') |
| 46 | endif |
| 47 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 48 | # Disable lto when compiling with no optimization |
| 49 | if(get_option('optimization') == '0') |
| 50 | add_project_arguments('-fno-lto', language: 'cpp') |
| 51 | message('Disabling lto & its supported features as optimization is disabled') |
| 52 | endif |
| 53 | |
| 54 | # Include Directories |
| 55 | |
Ed Tanous | cf2f932 | 2021-09-22 15:34:41 -0700 | [diff] [blame] | 56 | incdir = include_directories( |
| 57 | 'include', |
| 58 | 'redfish-core/include', |
| 59 | 'redfish-core/lib', |
| 60 | 'http' |
| 61 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 62 | |
| 63 | # Get the options and enable the respective features |
| 64 | ## create a MAP of "options : feature_flag" |
| 65 | |
| 66 | feature_map = { |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 67 | 'basic-auth' : '-DBMCWEB_ENABLE_BASIC_AUTHENTICATION', |
| 68 | 'cookie-auth' : '-DBMCWEB_ENABLE_COOKIE_AUTHENTICATION', |
| 69 | 'google-api' : '-DBMCWEB_ENABLE_GOOGLE_API', |
| 70 | 'host-serial-socket' : '-DBMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET', |
| 71 | 'ibm-management-console' : '-DBMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE', |
Nan Zhou | a43ea82 | 2022-05-27 00:42:44 +0000 | [diff] [blame] | 72 | 'insecure-disable-auth' : '-DBMCWEB_INSECURE_DISABLE_AUTHX', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 73 | 'insecure-disable-csrf' : '-DBMCWEB_INSECURE_DISABLE_CSRF_PREVENTION', |
| 74 | 'insecure-disable-ssl' : '-DBMCWEB_INSECURE_DISABLE_SSL', |
| 75 | 'insecure-push-style-notification' : '-DBMCWEB_INSECURE_ENABLE_HTTP_PUSH_STYLE_EVENTING', |
| 76 | 'insecure-tftp-update' : '-DBMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE', |
Ed Tanous | 1aa0c2b | 2022-02-08 12:24:30 +0100 | [diff] [blame] | 77 | 'insecure-ignore-content-type' : '-DBMCWEB_INSECURE_IGNORE_CONTENT_TYPE', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 78 | 'kvm' : '-DBMCWEB_ENABLE_KVM' , |
| 79 | 'mutual-tls-auth' : '-DBMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION', |
Carson Labrado | 7fb3356 | 2022-04-18 23:26:56 +0000 | [diff] [blame] | 80 | 'redfish-aggregation' : '-DBMCWEB_ENABLE_REDFISH_AGGREGATION', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 81 | 'redfish-allow-deprecated-power-thermal' : '-DBMCWEB_ALLOW_DEPRECATED_POWER_THERMAL', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 82 | 'redfish-bmc-journal' : '-DBMCWEB_ENABLE_REDFISH_BMC_JOURNAL', |
| 83 | 'redfish-cpu-log' : '-DBMCWEB_ENABLE_REDFISH_CPU_LOG', |
| 84 | 'redfish-dbus-log' : '-DBMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES', |
| 85 | 'redfish-dump-log' : '-DBMCWEB_ENABLE_REDFISH_DUMP_LOG', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 86 | 'redfish-host-logger' : '-DBMCWEB_ENABLE_REDFISH_HOST_LOGGER', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 87 | 'redfish-new-powersubsystem-thermalsubsystem' : '-DBMCWEB_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM', |
Gunnar Mills | 54dce7f | 2022-08-05 17:01:32 +0000 | [diff] [blame] | 88 | 'redfish-oem-manager-fan-data' : '-DBMCWEB_ENABLE_REDFISH_OEM_MANAGER_FAN_DATA', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 89 | 'redfish-provisioning-feature' : '-DBMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE', |
| 90 | 'redfish' : '-DBMCWEB_ENABLE_REDFISH', |
| 91 | 'rest' : '-DBMCWEB_ENABLE_DBUS_REST', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 92 | 'session-auth' : '-DBMCWEB_ENABLE_SESSION_AUTHENTICATION', |
| 93 | 'static-hosting' : '-DBMCWEB_ENABLE_STATIC_HOSTING', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 94 | 'vm-websocket' : '-DBMCWEB_ENABLE_VM_WEBSOCKET', |
| 95 | 'xtoken-auth' : '-DBMCWEB_ENABLE_XTOKEN_AUTHENTICATION', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 96 | #'vm-nbdproxy' : '-DBMCWEB_ENABLE_VM_NBDPROXY', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | # Get the options status and build a project summary to show which flags are |
| 100 | # being enabled during the configuration time. |
| 101 | |
| 102 | foreach option_key,option_value : feature_map |
| 103 | if(get_option(option_key).enabled()) |
| 104 | if(option_key == 'mutual-tls-auth' or option_key == 'insecure-disable-ssl') |
| 105 | if(get_option('insecure-disable-ssl').disabled() or get_option('mutual-tls-auth').disabled()) |
| 106 | add_project_arguments(option_value,language:'cpp') |
| 107 | summary(option_key,option_value, section : 'Enabled Features') |
| 108 | endif |
Nan Zhou | 3acced2 | 2022-07-12 23:21:02 +0000 | [diff] [blame] | 109 | elif (option_key in ['basic-auth', 'cookie-auth', 'session-auth', 'xtoken-auth', 'mutual-tls-auth']) |
| 110 | if (get_option('insecure-disable-auth').disabled()) |
| 111 | add_project_arguments(option_value, language:'cpp') |
| 112 | summary(option_key,option_value, section : 'Enabled Features') |
| 113 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 114 | else |
| 115 | summary(option_key,option_value, section : 'Enabled Features') |
| 116 | add_project_arguments(option_value,language:'cpp') |
| 117 | endif |
| 118 | else |
| 119 | if(option_key == 'insecure-disable-ssl') |
| 120 | summary('ssl','-DBMCWEB_ENABLE_SSL', section : 'Enabled Features') |
| 121 | add_project_arguments('-DBMCWEB_ENABLE_SSL', language : 'cpp') |
| 122 | endif |
| 123 | endif |
| 124 | endforeach |
| 125 | |
| 126 | if(get_option('tests').enabled()) |
| 127 | summary('unittest','NA', section : 'Enabled Features') |
| 128 | endif |
| 129 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 130 | # Add compiler arguments |
| 131 | |
| 132 | # -Wpedantic, -Wextra comes by default with warning level |
| 133 | add_project_arguments( |
| 134 | cxx.get_supported_arguments([ |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 135 | '-Wcast-align', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 136 | '-Wconversion', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 137 | '-Wformat=2', |
| 138 | '-Wold-style-cast', |
| 139 | '-Woverloaded-virtual', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 140 | '-Wsign-conversion', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 141 | '-Wunused', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 142 | '-Wno-attributes', |
| 143 | ]), |
| 144 | language: 'cpp' |
| 145 | ) |
| 146 | |
| 147 | if (cxx.get_id() == 'clang' and cxx.version().version_compare('>9.0')) |
| 148 | add_project_arguments( |
| 149 | cxx.get_supported_arguments([ |
| 150 | '-Weverything', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 151 | '-Wno-c++98-compat-pedantic', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 152 | '-Wno-c++98-compat', |
| 153 | '-Wno-documentation-unknown-command', |
| 154 | '-Wno-documentation', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 155 | '-Wno-exit-time-destructors', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 156 | '-Wno-global-constructors', |
| 157 | '-Wno-newline-eof', |
| 158 | '-Wno-padded', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 159 | '-Wno-shadow', |
| 160 | '-Wno-used-but-marked-unused', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 161 | '-Wno-weak-vtables', |
Ed Tanous | e6801eb | 2022-12-19 16:11:13 -0800 | [diff] [blame] | 162 | '-Wno-switch-enum', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 163 | ]), |
| 164 | language:'cpp') |
| 165 | endif |
| 166 | |
| 167 | # if compiler is gnu-gcc , and version is > 8.0 then we add few more |
| 168 | # compiler arguments , we know that will pass |
| 169 | |
| 170 | if (cxx.get_id() == 'gcc' and cxx.version().version_compare('>8.0')) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 171 | add_project_arguments( |
| 172 | cxx.get_supported_arguments([ |
| 173 | '-Wduplicated-cond', |
| 174 | '-Wduplicated-branches', |
| 175 | '-Wlogical-op', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 176 | '-Wnull-dereference', |
Ed Tanous | 079360a | 2022-06-29 10:05:19 -0700 | [diff] [blame] | 177 | '-Wunused-parameter', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 178 | '-Wdouble-promotion', |
Ed Tanous | 8a59281 | 2022-06-04 09:06:59 -0700 | [diff] [blame] | 179 | '-Wshadow', |
Ed Tanous | 30f11eb | 2022-05-25 10:42:15 -0700 | [diff] [blame] | 180 | '-Wno-psabi', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 181 | ]), |
| 182 | language:'cpp') |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 183 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 184 | |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 185 | if (get_option('buildtype') != 'plain') |
| 186 | if (get_option('b_lto') == true and get_option('optimization')!='0') |
| 187 | # Reduce the binary size by removing unnecessary |
| 188 | # dynamic symbol table entries |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 189 | |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 190 | add_project_arguments( |
| 191 | cxx.get_supported_arguments([ |
| 192 | '-fno-fat-lto-objects', |
| 193 | '-fvisibility=hidden', |
| 194 | '-fvisibility-inlines-hidden' |
| 195 | ]), |
| 196 | language: 'cpp') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 197 | |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 198 | if cxx.has_link_argument('-Wl,--exclude-libs,ALL') |
| 199 | add_project_link_arguments('-Wl,--exclude-libs,ALL', language: 'cpp') |
George Liu | e820493 | 2021-02-01 14:42:49 +0800 | [diff] [blame] | 200 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 201 | endif |
| 202 | endif |
| 203 | |
Myung Bae | 662aa6e | 2023-01-10 14:20:28 -0600 | [diff] [blame] | 204 | if( get_option('bmcweb-logging') != 'disabled' or \ |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 205 | get_option('buildtype').startswith('debug')) |
| 206 | add_project_arguments([ |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 207 | '-DBMCWEB_ENABLE_DEBUG' |
| 208 | ], |
| 209 | language : 'cpp') |
| 210 | |
Myung Bae | 662aa6e | 2023-01-10 14:20:28 -0600 | [diff] [blame] | 211 | summary('debug', '-DBMCWEB_ENABLE_DEBUG', section : 'Enabled Features') |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 212 | endif |
| 213 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 214 | # Set Compiler Security flags |
| 215 | |
| 216 | security_flags = [ |
Ed Tanous | cf2f932 | 2021-09-22 15:34:41 -0700 | [diff] [blame] | 217 | '-fstack-protector-strong', |
| 218 | '-fPIE', |
| 219 | '-fPIC', |
| 220 | '-D_FORTIFY_SOURCE=2', |
| 221 | '-Wformat', |
| 222 | '-Wformat-security' |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 223 | ] |
| 224 | |
| 225 | ## Add security flags for builds of type 'release','debugoptimized' and 'minsize' |
| 226 | |
| 227 | if not (get_option('buildtype') == 'plain' or get_option('buildtype').startswith('debug')) |
| 228 | add_project_arguments( |
| 229 | cxx.get_supported_arguments([ |
| 230 | security_flags |
| 231 | ]), |
| 232 | language: 'cpp') |
| 233 | endif |
| 234 | |
| 235 | # Boost dependency configuration |
| 236 | |
| 237 | add_project_arguments( |
| 238 | cxx.get_supported_arguments([ |
Ed Tanous | cf2f932 | 2021-09-22 15:34:41 -0700 | [diff] [blame] | 239 | '-DBOOST_ALL_NO_LIB', |
Ed Tanous | cf2f932 | 2021-09-22 15:34:41 -0700 | [diff] [blame] | 240 | '-DBOOST_ALLOW_DEPRECATED_HEADERS', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 241 | '-DBOOST_ASIO_DISABLE_THREADS', |
| 242 | '-DBOOST_ASIO_NO_DEPRECATED', |
| 243 | '-DBOOST_ASIO_SEPARATE_COMPILATION', |
| 244 | '-DBOOST_BEAST_SEPARATE_COMPILATION', |
Ed Tanous | 9e710e7 | 2022-03-12 17:40:04 -0800 | [diff] [blame] | 245 | '-DBOOST_EXCEPTION_DISABLE', |
Ed Tanous | ab6b6fe | 2022-08-02 20:28:15 -0700 | [diff] [blame] | 246 | '-DBOOST_URL_NO_SOURCE_LOCATION', |
Ed Tanous | 9e710e7 | 2022-03-12 17:40:04 -0800 | [diff] [blame] | 247 | '-DJSON_NOEXCEPTION', |
Ed Tanous | 209aa90 | 2022-08-02 21:11:06 -0700 | [diff] [blame] | 248 | '-DOPENSSL_NO_FILENAMES', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 249 | ]), |
| 250 | language : 'cpp') |
| 251 | |
| 252 | # Find the dependency modules, if not found use meson wrap to get them |
| 253 | # automatically during the configure step |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 254 | bmcweb_dependencies = [] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 255 | |
Nan Zhou | 8682c5a | 2021-11-13 11:00:07 -0800 | [diff] [blame] | 256 | pam = cxx.find_library('pam', required: true) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 257 | atomic = cxx.find_library('atomic', required: true) |
| 258 | openssl = dependency('openssl', required : true) |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 259 | bmcweb_dependencies += [pam, atomic, openssl] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 260 | |
Ed Tanous | 7bb985e | 2021-09-02 14:31:40 -0700 | [diff] [blame] | 261 | sdbusplus = dependency('sdbusplus', required : false, include_type: 'system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 262 | if not sdbusplus.found() |
| 263 | sdbusplus_proj = subproject('sdbusplus', required: true) |
| 264 | sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep') |
| 265 | sdbusplus = sdbusplus.as_system('system') |
| 266 | endif |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 267 | bmcweb_dependencies += sdbusplus |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 268 | |
Ed Tanous | c9374ff | 2023-05-26 09:42:08 -0700 | [diff] [blame] | 269 | tinyxml = dependency( |
| 270 | 'tinyxml2', |
Cody Smith | 3a097b2 | 2022-05-19 14:22:32 -0700 | [diff] [blame] | 271 | include_type: 'system', |
Ed Tanous | c9374ff | 2023-05-26 09:42:08 -0700 | [diff] [blame] | 272 | version: '>=9.0.0', |
Cody Smith | 3a097b2 | 2022-05-19 14:22:32 -0700 | [diff] [blame] | 273 | ) |
Ed Tanous | c9374ff | 2023-05-26 09:42:08 -0700 | [diff] [blame] | 274 | if not tinyxml.found() |
| 275 | tinyxml_proj = subproject('tinyxml2', required: true) |
| 276 | tinyxml = tinyxml_proj.get_variable('tinyxml_dep') |
| 277 | tinyxml = tinyxml.as_system('system') |
| 278 | endif |
Cody Smith | 3a097b2 | 2022-05-19 14:22:32 -0700 | [diff] [blame] | 279 | bmcweb_dependencies += tinyxml |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 280 | |
| 281 | systemd = dependency('systemd') |
| 282 | zlib = dependency('zlib') |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 283 | bmcweb_dependencies += [systemd, zlib] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 284 | |
Ed Tanous | 982dd79 | 2023-06-06 08:26:29 -0700 | [diff] [blame] | 285 | nlohmann_json = dependency('nlohmann_json', version: '>=3.9.2', required: false, include_type: 'system') |
Ed Tanous | c9374ff | 2023-05-26 09:42:08 -0700 | [diff] [blame] | 286 | if not nlohmann_json.found() |
Ed Tanous | 982dd79 | 2023-06-06 08:26:29 -0700 | [diff] [blame] | 287 | nlohmann_json_proj = subproject('nlohmann_json', required: true) |
Josh Lehan | 259df35 | 2021-10-07 15:20:02 -0700 | [diff] [blame] | 288 | nlohmann_json = nlohmann_json_proj.get_variable('nlohmann_json_dep') |
Ed Tanous | b00dcc2 | 2021-02-23 12:52:50 -0800 | [diff] [blame] | 289 | nlohmann_json = nlohmann_json.as_system('system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 290 | endif |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 291 | bmcweb_dependencies += nlohmann_json |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 292 | |
Ed Tanous | c9374ff | 2023-05-26 09:42:08 -0700 | [diff] [blame] | 293 | boost = dependency('boost',version : '>=1.82.0', required : false, include_type: 'system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 294 | if not boost.found() |
Ed Tanous | f165dee | 2022-10-25 11:55:49 -0700 | [diff] [blame] | 295 | boost = subproject('boost', required: true).get_variable('boost_dep') |
Ed Tanous | 6c7d53a | 2022-11-02 16:47:45 -0700 | [diff] [blame] | 296 | boost = boost.as_system('system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 297 | endif |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 298 | bmcweb_dependencies += boost |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 299 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 300 | if get_option('tests').enabled() |
Ed Tanous | c9374ff | 2023-05-26 09:42:08 -0700 | [diff] [blame] | 301 | gtest = dependency('gtest', main: true, disabler: true, required : false) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 302 | gmock = dependency('gmock', required : false) |
| 303 | if not gtest.found() and get_option('tests').enabled() |
| 304 | gtest_proj = subproject('gtest', required: true) |
| 305 | gtest = gtest_proj.get_variable('gtest_main_dep') |
| 306 | gmock = gtest_proj.get_variable('gmock_dep') |
| 307 | endif |
Ed Tanous | b00dcc2 | 2021-02-23 12:52:50 -0800 | [diff] [blame] | 308 | gtest = gtest.as_system('system') |
| 309 | gmock = gmock.as_system('system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 310 | endif |
| 311 | |
Patrick Williams | 4efe3e0 | 2023-04-12 08:05:58 -0500 | [diff] [blame] | 312 | systemd_system_unit_dir = systemd.get_variable('systemdsystemunitdir') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 313 | |
| 314 | bindir = get_option('prefix') + '/' +get_option('bindir') |
| 315 | |
| 316 | summary({ |
| 317 | 'prefix' : get_option('prefix'), |
| 318 | 'bindir' : bindir, |
| 319 | 'systemd unit directory' : systemd_system_unit_dir |
| 320 | }, section : 'Directories') |
| 321 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 322 | install_subdir('static', install_dir : 'share/www', strip_directory : true) |
| 323 | |
Nan Zhou | 307386e | 2022-10-12 20:29:34 +0000 | [diff] [blame] | 324 | # Config subdirectory |
| 325 | |
| 326 | subdir('config') |
| 327 | bmcweb_dependencies += conf_h_dep |
| 328 | |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 329 | # Source files |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 330 | fs = import('fs') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 331 | |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 332 | srcfiles_bmcweb = files( |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 333 | 'redfish-core/src/error_messages.cpp', |
Sui Chen | d1d411f | 2022-04-10 23:09:36 -0700 | [diff] [blame] | 334 | 'redfish-core/src/registries.cpp', |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 335 | 'redfish-core/src/utils/json_utils.cpp', |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 336 | 'src/boost_asio_ssl.cpp', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 337 | 'src/boost_asio.cpp', |
| 338 | 'src/boost_beast.cpp', |
| 339 | 'src/boost_url.cpp', |
Nan Zhou | 6384e32 | 2022-06-23 22:28:25 +0000 | [diff] [blame] | 340 | 'src/dbus_singleton.cpp', |
Ed Tanous | 61e349a | 2023-05-31 11:57:43 -0700 | [diff] [blame] | 341 | 'src/json_html_serializer.cpp', |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 342 | ) |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 343 | |
Ed Tanous | 42bbcd8 | 2023-01-07 18:04:28 -0800 | [diff] [blame] | 344 | bmcweblib = static_library( |
| 345 | 'bmcweblib', |
| 346 | srcfiles_bmcweb, |
| 347 | include_directories : incdir, |
| 348 | dependencies: bmcweb_dependencies, |
| 349 | ) |
| 350 | |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 351 | # Generate the bmcweb executable |
| 352 | executable( |
| 353 | 'bmcweb', |
Ed Tanous | 42bbcd8 | 2023-01-07 18:04:28 -0800 | [diff] [blame] | 354 | 'src/webserver_main.cpp', |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 355 | include_directories : incdir, |
| 356 | dependencies: bmcweb_dependencies, |
Ed Tanous | 42bbcd8 | 2023-01-07 18:04:28 -0800 | [diff] [blame] | 357 | link_with: bmcweblib, |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 358 | link_args: '-Wl,--gc-sections', |
| 359 | install: true, |
| 360 | install_dir:bindir |
| 361 | ) |
| 362 | |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 363 | srcfiles_unittest = files( |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 364 | 'test/http/crow_getroutes_test.cpp', |
| 365 | 'test/http/router_test.cpp', |
| 366 | 'test/http/utility_test.cpp', |
Ed Tanous | 2c9efc3 | 2022-07-31 22:08:26 -0700 | [diff] [blame] | 367 | 'test/http/verb_test.cpp', |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 368 | 'test/include/dbus_utility_test.cpp', |
| 369 | 'test/include/google/google_service_root_test.cpp', |
Ed Tanous | 5a60c56 | 2023-05-18 13:52:34 -0700 | [diff] [blame] | 370 | 'test/include/json_html_serializer.cpp', |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 371 | 'test/include/http_utility_test.cpp', |
| 372 | 'test/include/human_sort_test.cpp', |
| 373 | 'test/include/ibm/configfile_test.cpp', |
| 374 | 'test/include/ibm/lock_test.cpp', |
| 375 | 'test/include/multipart_test.cpp', |
| 376 | 'test/include/openbmc_dbus_rest_test.cpp', |
Ed Tanous | 50ebd4a | 2023-01-19 19:03:17 -0800 | [diff] [blame] | 377 | 'test/include/str_utility_test.cpp', |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 378 | 'test/redfish-core/include/privileges_test.cpp', |
Carson Labrado | 7e8890c | 2022-11-23 23:58:01 +0000 | [diff] [blame] | 379 | 'test/redfish-core/include/redfish_aggregator_test.cpp', |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 380 | 'test/redfish-core/include/registries_test.cpp', |
| 381 | 'test/redfish-core/include/utils/hex_utils_test.cpp', |
| 382 | 'test/redfish-core/include/utils/ip_utils_test.cpp', |
| 383 | 'test/redfish-core/include/utils/json_utils_test.cpp', |
| 384 | 'test/redfish-core/include/utils/query_param_test.cpp', |
| 385 | 'test/redfish-core/include/utils/stl_utils_test.cpp', |
| 386 | 'test/redfish-core/include/utils/time_utils_test.cpp', |
| 387 | 'test/redfish-core/lib/chassis_test.cpp', |
Ed Tanous | c71d612 | 2022-11-29 14:10:32 -0800 | [diff] [blame] | 388 | 'test/redfish-core/lib/sensors_test.cpp', |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 389 | 'test/redfish-core/lib/log_services_dump_test.cpp', |
| 390 | 'test/redfish-core/lib/service_root_test.cpp', |
| 391 | 'test/redfish-core/lib/thermal_subsystem_test.cpp', |
Chicago Duan | 77b3643 | 2021-02-05 15:48:26 +0800 | [diff] [blame] | 392 | 'test/redfish-core/lib/power_subsystem_test.cpp', |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 393 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 394 | |
| 395 | if(get_option('tests').enabled()) |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 396 | # generate the test executable |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 397 | foreach test_src : srcfiles_unittest |
| 398 | test_bin = executable( |
| 399 | fs.stem(test_src), |
Ed Tanous | 42bbcd8 | 2023-01-07 18:04:28 -0800 | [diff] [blame] | 400 | test_src, |
| 401 | link_with: bmcweblib, |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 402 | include_directories : incdir, |
| 403 | install_dir: bindir, |
| 404 | dependencies: bmcweb_dependencies + [ |
| 405 | gtest, |
| 406 | gmock, |
| 407 | ] |
| 408 | ) |
| 409 | test(fs.stem(test_src), test_bin) |
| 410 | endforeach |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 411 | endif |