1project('phosphor-bmc-code-mgmt', 'cpp', 2 default_options: [ 3 'buildtype=debugoptimized', 4 'cpp_std=c++17', 5 'warning_level=3', 6 'werror=true' 7 ], 8 license: 'Apache-2.0', 9 version: '1.0') 10 11conf = configuration_data() 12 13# DBus information 14conf.set_quoted('BMC_INVENTORY_INTERFACE', 'xyz.openbmc_project.Inventory.Item.Bmc') 15conf.set_quoted('BUSNAME_UPDATER', 'xyz.openbmc_project.Software.BMC.Updater') 16conf.set_quoted('DOWNLOAD_BUSNAME', 'xyz.openbmc_project.Software.Download') 17conf.set_quoted('FILEPATH_IFACE', 'xyz.openbmc_project.Common.FilePath') 18conf.set_quoted('INVENTORY_PATH', '/xyz/openbmc_project/inventory/') 19conf.set_quoted('MAPPER_BUSNAME', 'xyz.openbmc_project.ObjectMapper') 20conf.set_quoted('MAPPER_INTERFACE', 'xyz.openbmc_project.ObjectMapper') 21conf.set_quoted('MAPPER_PATH', '/xyz/openbmc_project/object_mapper') 22conf.set_quoted('SOFTWARE_OBJPATH', '/xyz/openbmc_project/software') 23conf.set_quoted('SYSTEMD_BUSNAME', 'org.freedesktop.systemd1') 24conf.set_quoted('SYSTEMD_PATH', '/org/freedesktop/systemd1') 25conf.set_quoted('SYSTEMD_INTERFACE', 'org.freedesktop.systemd1.Manager') 26conf.set_quoted('VERSION_BUSNAME', 'xyz.openbmc_project.Software.Version') 27conf.set_quoted('VERSION_IFACE', 'xyz.openbmc_project.Software.Version') 28conf.set_quoted('EXTENDED_VERSION_IFACE', 'xyz.openbmc_project.Software.ExtendedVersion') 29 30# Names of the forward and reverse associations 31conf.set_quoted('ACTIVATION_FWD_ASSOCIATION', 'inventory') 32conf.set_quoted('ACTIVATION_REV_ASSOCIATION', 'activation') 33conf.set_quoted('ACTIVE_FWD_ASSOCIATION', 'active') 34conf.set_quoted('ACTIVE_REV_ASSOCIATION', 'software_version') 35conf.set_quoted('FUNCTIONAL_FWD_ASSOCIATION', 'functional') 36conf.set_quoted('FUNCTIONAL_REV_ASSOCIATION', 'software_version') 37conf.set_quoted('UPDATEABLE_FWD_ASSOCIATION', 'updateable') 38conf.set_quoted('UPDATEABLE_REV_ASSOCIATION', 'software_version') 39 40# Filesystem files and directories 41# The path of the alt rwfs overlay 42conf.set_quoted('ALT_RWFS', '/media/alt/var/persist') 43# The prefix path for the versioned read-only bmc partitions 44conf.set_quoted('BMC_ROFS_PREFIX', get_option('media-dir') + '/rofs-') 45# The name of the BMC table of contents file 46conf.set_quoted('OS_RELEASE_FILE', '/etc/os-release') 47# The dir where activation data is stored in files 48conf.set_quoted('PERSIST_DIR', '/var/lib/phosphor-bmc-code-mgmt/') 49 50# Supported BMC layout types 51conf.set('STATIC_LAYOUT', get_option('bmc-layout').contains('static')) 52conf.set('UBIFS_LAYOUT', get_option('bmc-layout').contains('ubi')) 53conf.set('MMC_LAYOUT', get_option('bmc-layout').contains('mmc')) 54 55# Configurable features 56conf.set('HOST_BIOS_UPGRADE', get_option('host-bios-upgrade').enabled()) 57conf.set('WANT_SIGNATURE_VERIFY', \ 58 get_option('verify-signature').enabled() or \ 59 get_option('verify-full-signature').enabled()) 60conf.set('WANT_SIGNATURE_FULL_VERIFY', get_option('verify-full-signature').enabled()) 61 62# Configurable variables 63conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed')) 64conf.set_quoted('HASH_FILE_NAME', get_option('hash-file-name')) 65conf.set_quoted('IMG_UPLOAD_DIR', get_option('img-upload-dir')) 66conf.set_quoted('MANIFEST_FILE_NAME', get_option('manifest-file-name')) 67conf.set_quoted('MEDIA_DIR', get_option('media-dir')) 68optional_array = get_option('optional-images') 69optional_images = '' 70foreach optiona_image : optional_array 71 optional_images = ' '.join([optional_images, optiona_image]) 72endforeach 73conf.set_quoted('OPTIONAL_IMAGES', optional_images) 74conf.set_quoted('PUBLICKEY_FILE_NAME', get_option('publickey-file-name')) 75conf.set_quoted('SIGNATURE_FILE_EXT', get_option('signature-file-ext')) 76conf.set_quoted('SIGNED_IMAGE_CONF_PATH', get_option('signed-image-conf-path')) 77conf.set_quoted('SYNC_LIST_DIR_PATH', get_option('sync-list-dir-path')) 78conf.set_quoted('SYNC_LIST_FILE_NAME', get_option('sync-list-file-name')) 79conf.set_quoted('BMC_MSL', get_option('bmc-msl')) 80conf.set_quoted('REGEX_BMC_MSL', get_option('regex-bmc-msl')) 81 82if get_option('host-bios-upgrade').enabled() 83 conf.set_quoted('BIOS_OBJPATH', get_option('bios-object-path')) 84endif 85 86configure_file(output: 'config.h', configuration: conf) 87 88deps = [ 89 dependency('phosphor-dbus-interfaces'), 90 dependency('phosphor-logging'), 91 dependency('sdbusplus') 92] 93 94ssl = dependency('openssl') 95 96systemd = dependency('systemd') 97systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir') 98 99unit_files = [ 100 'obmc-flash-bmc-setenv@.service.in', 101 'reboot-guard-disable.service.in', 102 'reboot-guard-enable.service.in', 103 'force-reboot.service.in', 104 'usr-local.mount.in', 105 'xyz.openbmc_project.Software.BMC.Updater.service.in', 106 'xyz.openbmc_project.Software.Download.service.in', 107 'xyz.openbmc_project.Software.Sync.service.in', 108 'xyz.openbmc_project.Software.Version.service.in' 109] 110 111sdbuspp = find_program('sdbus++') 112subdir('xyz/openbmc_project/Software/Image') 113 114image_updater_sources = files( 115 'activation.cpp', 116 'images.cpp', 117 'item_updater.cpp', 118 'item_updater_main.cpp', 119 'serialize.cpp', 120 'version.cpp', 121 'utils.cpp', 122 'msl_verify.cpp' 123) 124 125if get_option('bmc-layout').contains('static') 126 image_updater_sources += files( 127 'static/flash.cpp', 128 'static/item_updater_helper.cpp' 129 ) 130elif get_option('bmc-layout').contains('ubi') 131 image_updater_sources += files( 132 'ubi/flash.cpp', 133 'ubi/item_updater_helper.cpp' 134 ) 135 136 unit_files += [ 137 'ubi/obmc-flash-bmc-cleanup.service.in', 138 'ubi/obmc-flash-bmc-mirroruboot.service.in', 139 'ubi/obmc-flash-bmc-ubiremount.service.in', 140 'ubi/obmc-flash-bmc-ubiro@.service.in', 141 'ubi/obmc-flash-bmc-ubiro-remove@.service.in', 142 'ubi/obmc-flash-bmc-ubirw.service.in', 143 'ubi/obmc-flash-bmc-ubirw-remove.service.in', 144 'ubi/obmc-flash-bmc-updateubootvars@.service.in' 145 ] 146elif get_option('bmc-layout').contains('mmc') 147 image_updater_sources += files( 148 'mmc/flash.cpp', 149 'mmc/item_updater_helper.cpp' 150 ) 151 152 unit_files += [ 153 'mmc/obmc-flash-mmc@.service.in', 154 'mmc/obmc-flash-mmc-mount.service.in', 155 'mmc/obmc-flash-mmc-remove@.service.in', 156 'mmc/obmc-flash-mmc-setprimary@.service.in', 157 'mmc/obmc-flash-mmc-umount.service.in', 158 ] 159endif 160 161if get_option('host-bios-upgrade').enabled() 162 unit_files += 'obmc-flash-host-bios@.service.in' 163endif 164 165if get_option('sync-bmc-files').enabled() 166 executable( 167 'phosphor-sync-software-manager', 168 'sync_manager.cpp', 169 'sync_manager_main.cpp', 170 'sync_watch.cpp', 171 dependencies: deps, 172 install: true 173 ) 174 175 install_data('synclist', 176 install_dir: get_option('sysconfdir') 177 ) 178endif 179 180if (get_option('verify-signature').enabled() or \ 181 get_option('verify-full-signature').enabled()) 182 image_updater_sources += files( 183 'utils.cpp', 184 'image_verify.cpp', 185 'openssl_alloc.cpp' 186 ) 187endif 188 189executable( 190 'phosphor-download-manager', 191 'download_manager.cpp', 192 'download_manager_main.cpp', 193 dependencies: deps, 194 install: true 195) 196 197executable( 198 'phosphor-image-updater', 199 image_error_cpp, 200 image_error_hpp, 201 image_updater_sources, 202 dependencies: [deps, ssl], 203 install: true 204) 205 206executable( 207 'phosphor-version-software-manager', 208 image_error_cpp, 209 image_error_hpp, 210 'image_manager.cpp', 211 'image_manager_main.cpp', 212 'version.cpp', 213 'watch.cpp', 214 dependencies: [deps, ssl], 215 install: true 216) 217 218install_data('obmc-flash-bmc', 219 install_mode: 'rwxr-xr-x', 220 install_dir: get_option('bindir') 221) 222 223install_data('software.conf', 224 install_dir: '/usr/lib/tmpfiles.d/' 225) 226 227foreach u : unit_files 228 configure_file( 229 input: u, 230 output: '@BASENAME@', 231 configuration: conf, 232 install: true, 233 install_dir: systemd_system_unit_dir, 234 ) 235endforeach 236 237# If test coverage of source files within the root directory are wanted, 238# need to define and build the tests from here 239build_tests = get_option('tests') 240if not build_tests.disabled() 241 oe_sdk = get_option('oe-sdk') 242 if oe_sdk.enabled() 243 # Setup OE SYSROOT 244 OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip() 245 if OECORE_TARGET_SYSROOT == '' 246 error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.') 247 endif 248 message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT) 249 rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib']) 250 ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip() 251 dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so] 252 else 253 dynamic_linker = [] 254 endif 255 256 gtest = dependency('gtest', main: true, disabler: true, required: build_tests) 257 include_srcs = declare_dependency(sources: [ 258 'utils.cpp', 259 'image_verify.cpp', 260 'images.cpp', 261 'version.cpp'] 262 ) 263 264 test('utest', 265 executable( 266 'utest', 267 './test/utest.cpp', 268 link_args: dynamic_linker, 269 build_rpath: get_option('oe-sdk').enabled() ? rpath : '', 270 dependencies: [deps, gtest, include_srcs, ssl] 271 ) 272) 273endif 274