1project('phosphor-bmc-code-mgmt', 'cpp', 2 default_options: [ 3 'buildtype=debugoptimized', 4 'cpp_std=c++23', 5 'warning_level=3', 6 'werror=true' 7 ], 8 meson_version: '>=1.1.1', 9 license: 'Apache-2.0', 10 version: '1.0') 11 12add_project_arguments( 13 '-DBOOST_SYSTEM_NO_DEPRECATED', 14 '-DBOOST_ERROR_CODE_HEADER_ONLY', 15 '-DBOOST_NO_RTTI', 16 '-DBOOST_NO_TYPEID', 17 '-DBOOST_ALL_NO_LIB', 18 '-DBOOST_ASIO_DISABLE_THREADS', 19 '-DBOOST_ASIO_NO_DEPRECATED', 20 language: 'cpp', 21) 22 23cpp = meson.get_compiler('cpp') 24 25conf = configuration_data() 26 27# DBus information 28conf.set_quoted('BMC_INVENTORY_INTERFACE', 'xyz.openbmc_project.Inventory.Item.Bmc') 29conf.set_quoted('BUSNAME_UPDATER', 'xyz.openbmc_project.Software.BMC.Updater') 30conf.set_quoted('DOWNLOAD_BUSNAME', 'xyz.openbmc_project.Software.Download') 31conf.set_quoted('FILEPATH_IFACE', 'xyz.openbmc_project.Common.FilePath') 32conf.set_quoted('INVENTORY_PATH', '/xyz/openbmc_project/inventory/') 33conf.set_quoted('MAPPER_BUSNAME', 'xyz.openbmc_project.ObjectMapper') 34conf.set_quoted('MAPPER_INTERFACE', 'xyz.openbmc_project.ObjectMapper') 35conf.set_quoted('MAPPER_PATH', '/xyz/openbmc_project/object_mapper') 36conf.set_quoted('SOFTWARE_OBJPATH', '/xyz/openbmc_project/software') 37conf.set_quoted('SYSTEMD_BUSNAME', 'org.freedesktop.systemd1') 38conf.set_quoted('SYSTEMD_PATH', '/org/freedesktop/systemd1') 39conf.set_quoted('SYSTEMD_INTERFACE', 'org.freedesktop.systemd1.Manager') 40conf.set_quoted('VERSION_BUSNAME', 'xyz.openbmc_project.Software.Version') 41conf.set_quoted('VERSION_IFACE', 'xyz.openbmc_project.Software.Version') 42conf.set_quoted('EXTENDED_VERSION_IFACE', 'xyz.openbmc_project.Software.ExtendedVersion') 43conf.set_quoted('COMPATIBLE_IFACE', 'xyz.openbmc_project.Inventory.Decorator.Compatible') 44 45# Names of the forward and reverse associations 46conf.set_quoted('ACTIVATION_FWD_ASSOCIATION', 'inventory') 47conf.set_quoted('ACTIVATION_REV_ASSOCIATION', 'activation') 48conf.set_quoted('ACTIVE_FWD_ASSOCIATION', 'active') 49conf.set_quoted('ACTIVE_REV_ASSOCIATION', 'software_version') 50conf.set_quoted('FUNCTIONAL_FWD_ASSOCIATION', 'functional') 51conf.set_quoted('FUNCTIONAL_REV_ASSOCIATION', 'software_version') 52conf.set_quoted('UPDATEABLE_FWD_ASSOCIATION', 'updateable') 53conf.set_quoted('UPDATEABLE_REV_ASSOCIATION', 'software_version') 54 55# Filesystem files and directories 56# The prefix path for the versioned read-only bmc partitions 57conf.set_quoted('BMC_ROFS_PREFIX', get_option('media-dir') + '/rofs-') 58# The name of the BMC table of contents file 59conf.set_quoted('OS_RELEASE_FILE', '/etc/os-release') 60# The dir where activation data is stored in files 61conf.set_quoted('PERSIST_DIR', '/var/lib/phosphor-bmc-code-mgmt/') 62 63# Supported BMC layout types 64conf.set('STATIC_LAYOUT', get_option('bmc-layout').contains('static')) 65conf.set('UBIFS_LAYOUT', get_option('bmc-layout').contains('ubi')) 66conf.set('MMC_LAYOUT', get_option('bmc-layout').contains('mmc')) 67 68# Configurable features 69conf.set('HOST_BIOS_UPGRADE', get_option('host-bios-upgrade').enabled()) 70conf.set('WANT_SIGNATURE_VERIFY', \ 71 get_option('verify-signature').enabled() or \ 72 get_option('verify-full-signature').enabled()) 73conf.set('WANT_SIGNATURE_FULL_VERIFY', get_option('verify-full-signature').enabled()) 74 75# Configurable variables 76conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed')) 77conf.set_quoted('HASH_FILE_NAME', get_option('hash-file-name')) 78conf.set_quoted('IMG_UPLOAD_DIR', get_option('img-upload-dir')) 79conf.set_quoted('MANIFEST_FILE_NAME', get_option('manifest-file-name')) 80conf.set_quoted('MEDIA_DIR', get_option('media-dir')) 81optional_array = get_option('optional-images') 82optional_images = '' 83foreach optiona_image : optional_array 84 optional_images = ' '.join([optional_images, optiona_image]) 85endforeach 86conf.set_quoted('OPTIONAL_IMAGES', optional_images) 87conf.set_quoted('PUBLICKEY_FILE_NAME', get_option('publickey-file-name')) 88conf.set_quoted('SIGNATURE_FILE_EXT', get_option('signature-file-ext')) 89conf.set_quoted('SIGNED_IMAGE_CONF_PATH', get_option('signed-image-conf-path')) 90conf.set_quoted('SYNC_LIST_DIR_PATH', get_option('sync-list-dir-path')) 91conf.set_quoted('SYNC_LIST_FILE_NAME', get_option('sync-list-file-name')) 92conf.set_quoted('BMC_MSL', get_option('bmc-msl')) 93conf.set_quoted('REGEX_BMC_MSL', get_option('regex-bmc-msl')) 94 95if get_option('host-bios-upgrade').enabled() 96 conf.set_quoted('BIOS_OBJPATH', get_option('bios-object-path')) 97endif 98 99if get_option('bmc-static-dual-image').enabled() 100 conf.set('BMC_STATIC_DUAL_IMAGE', get_option('bmc-static-dual-image').enabled()) 101 conf.set_quoted('ALT_ROFS_DIR', get_option('alt-rofs-dir')) 102 conf.set_quoted('ALT_RWFS', get_option('alt-rwfs-dir')) 103else 104 conf.set_quoted('ALT_RWFS', '/media/alt/var/persist') 105endif 106 107configure_file(output: 'config.h', configuration: conf) 108 109sdbusplus_dep = dependency('sdbusplus') 110sdbusplusplus_prog = find_program('sdbus++', native: true) 111sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true) 112 113pdi_dep = dependency('phosphor-dbus-interfaces') 114phosphor_logging_dep = dependency('phosphor-logging') 115 116cereal_dep = dependency('cereal', required: false) 117has_cereal = cpp.has_header_symbol( 118 'cereal/cereal.hpp', 119 'cereal::specialize', 120 dependencies: cereal_dep, 121 required: false) 122if not has_cereal 123 cereal_opts = import('cmake').subproject_options() 124 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'}) 125 cereal_proj = import('cmake').subproject( 126 'cereal', 127 options: cereal_opts, 128 required: false) 129 assert(cereal_proj.found(), 'cereal is required') 130 cereal_dep = cereal_proj.dependency('cereal') 131endif 132 133deps = [ 134 cereal_dep, 135 pdi_dep, 136 phosphor_logging_dep, 137 sdbusplus_dep, 138] 139 140ssl = dependency('openssl') 141 142systemd = dependency('systemd') 143systemd_system_unit_dir = systemd.get_variable('systemdsystemunitdir') 144 145unit_files = [ 146 'obmc-flash-bmc-setenv@.service.in', 147 'reboot-guard-disable.service.in', 148 'reboot-guard-enable.service.in', 149 'force-reboot.service.in', 150 'usr-local.mount.in', 151 'xyz.openbmc_project.Software.BMC.Updater.service.in', 152 'xyz.openbmc_project.Software.Download.service.in', 153 'xyz.openbmc_project.Software.Sync.service.in', 154 'xyz.openbmc_project.Software.Version.service.in' 155] 156 157subdir('xyz/openbmc_project/Software/Image') 158 159image_updater_sources = files( 160 'activation.cpp', 161 'images.cpp', 162 'item_updater.cpp', 163 'item_updater_main.cpp', 164 'serialize.cpp', 165 'version.cpp', 166 'utils.cpp', 167 'msl_verify.cpp' 168) 169 170if get_option('bmc-layout').contains('static') 171 image_updater_sources += files( 172 'static/flash.cpp', 173 'static/item_updater_helper.cpp' 174 ) 175elif get_option('bmc-layout').contains('ubi') 176 image_updater_sources += files( 177 'ubi/flash.cpp', 178 'ubi/item_updater_helper.cpp' 179 ) 180 181 unit_files += [ 182 'ubi/obmc-flash-bmc-cleanup.service.in', 183 'ubi/obmc-flash-bmc-mirroruboot.service.in', 184 'ubi/obmc-flash-bmc-ubiremount.service.in', 185 'ubi/obmc-flash-bmc-ubiro@.service.in', 186 'ubi/obmc-flash-bmc-ubiro-remove@.service.in', 187 'ubi/obmc-flash-bmc-ubirw.service.in', 188 'ubi/obmc-flash-bmc-ubirw-remove.service.in', 189 'ubi/obmc-flash-bmc-updateubootvars@.service.in' 190 ] 191elif get_option('bmc-layout').contains('mmc') 192 image_updater_sources += files( 193 'mmc/flash.cpp', 194 'mmc/item_updater_helper.cpp' 195 ) 196 197 unit_files += [ 198 'mmc/obmc-flash-mmc@.service.in', 199 'mmc/obmc-flash-mmc-mount.service.in', 200 'mmc/obmc-flash-mmc-remove@.service.in', 201 'mmc/obmc-flash-mmc-setprimary@.service.in', 202 'mmc/obmc-flash-mmc-umount.service.in', 203 'mmc/obmc-flash-mmc-mirroruboot.service.in', 204 ] 205endif 206 207if get_option('host-bios-upgrade').enabled() 208 unit_files += 'obmc-flash-host-bios@.service.in' 209endif 210 211if get_option('bmc-static-dual-image').enabled() 212 unit_files += [ 213 'static/obmc-flash-bmc-alt@.service.in', 214 'static/obmc-flash-bmc-static-mount-alt.service.in', 215 'static/obmc-flash-bmc-prepare-for-sync.service.in', 216 ] 217endif 218 219if get_option('sync-bmc-files').enabled() 220 executable( 221 'phosphor-sync-software-manager', 222 'sync_manager.cpp', 223 'sync_manager_main.cpp', 224 'sync_watch.cpp', 225 dependencies: deps, 226 install: true 227 ) 228 229 install_data('synclist', 230 install_dir: get_option('sysconfdir') 231 ) 232 233 install_data('sync-once.sh', 234 install_mode: 'rwxr-xr-x', 235 install_dir: get_option('bindir') 236 ) 237endif 238 239if (get_option('verify-signature').enabled() or \ 240 get_option('verify-full-signature').enabled()) 241 image_updater_sources += files( 242 'utils.cpp', 243 'image_verify.cpp', 244 'openssl_alloc.cpp' 245 ) 246endif 247 248executable( 249 'phosphor-download-manager', 250 'download_manager.cpp', 251 'download_manager_main.cpp', 252 dependencies: deps, 253 install: true 254) 255 256executable( 257 'phosphor-image-updater', 258 image_error_cpp, 259 image_error_hpp, 260 image_updater_sources, 261 dependencies: [deps, ssl], 262 install: true 263) 264 265executable( 266 'phosphor-version-software-manager', 267 image_error_cpp, 268 image_error_hpp, 269 'image_manager.cpp', 270 'image_manager_main.cpp', 271 'version.cpp', 272 'watch.cpp', 273 dependencies: [deps, ssl], 274 install: true 275) 276 277install_data('obmc-flash-bmc', 278 install_mode: 'rwxr-xr-x', 279 install_dir: get_option('bindir') 280) 281 282install_data('detect-slot-aspeed', 283 install_mode: 'rwxr-xr-x', 284 install_dir: get_option('bindir') 285) 286 287install_data('reset-cs0-aspeed', 288 install_mode: 'rwxr-xr-x', 289 install_dir: get_option('bindir') 290) 291 292install_data('software.conf', 293 install_dir: '/usr/lib/tmpfiles.d/' 294) 295 296foreach u : unit_files 297 configure_file( 298 input: u, 299 output: '@BASENAME@', 300 configuration: conf, 301 install: true, 302 install_dir: systemd_system_unit_dir, 303 ) 304endforeach 305 306# If test coverage of source files within the root directory are wanted, 307# need to define and build the tests from here 308build_tests = get_option('tests') 309if not build_tests.disabled() 310 gtest = dependency('gtest', main: true, disabler: true, required: build_tests) 311 include_srcs = declare_dependency(sources: [ 312 'utils.cpp', 313 'image_verify.cpp', 314 'images.cpp', 315 'version.cpp'] 316 ) 317 318 test('utest', 319 executable( 320 'utest', 321 './test/utest.cpp', 322 dependencies: [deps, gtest, include_srcs, ssl] 323 ) 324) 325endif 326 327if get_option('usb-code-update').enabled() 328 subdir('usb') 329endif 330 331if get_option('side-switch-on-boot').enabled() 332 subdir('side-switch') 333endif 334