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