Adriana Kobylak | 0af80a4 | 2020-05-05 13:32:10 -0500 | [diff] [blame] | 1 | project('phosphor-bmc-code-mgmt', 'cpp', |
| 2 | default_options: [ |
Gunnar Mills | f7a69e1 | 2020-06-15 12:16:51 -0500 | [diff] [blame] | 3 | 'buildtype=debugoptimized', |
| 4 | 'cpp_std=c++17', |
Adriana Kobylak | 0af80a4 | 2020-05-05 13:32:10 -0500 | [diff] [blame] | 5 | 'warning_level=3', |
Gunnar Mills | f7a69e1 | 2020-06-15 12:16:51 -0500 | [diff] [blame] | 6 | 'werror=true' |
Adriana Kobylak | 0af80a4 | 2020-05-05 13:32:10 -0500 | [diff] [blame] | 7 | ], |
| 8 | license: 'Apache-2.0', |
| 9 | version: '1.0') |
| 10 | |
| 11 | conf = configuration_data() |
| 12 | |
| 13 | # DBus information |
| 14 | conf.set_quoted('BMC_INVENTORY_INTERFACE', 'xyz.openbmc_project.Inventory.Item.Bmc') |
| 15 | conf.set_quoted('BUSNAME_UPDATER', 'xyz.openbmc_project.Software.BMC.Updater') |
| 16 | conf.set_quoted('DOWNLOAD_BUSNAME', 'xyz.openbmc_project.Software.Download') |
| 17 | conf.set_quoted('FILEPATH_IFACE', 'xyz.openbmc_project.Common.FilePath') |
| 18 | conf.set_quoted('INVENTORY_PATH', '/xyz/openbmc_project/inventory/') |
| 19 | conf.set_quoted('MAPPER_BUSNAME', 'xyz.openbmc_project.ObjectMapper') |
| 20 | conf.set_quoted('MAPPER_INTERFACE', 'xyz.openbmc_project.ObjectMapper') |
| 21 | conf.set_quoted('MAPPER_PATH', '/xyz/openbmc_project/object_mapper') |
| 22 | conf.set_quoted('SOFTWARE_OBJPATH', '/xyz/openbmc_project/software') |
| 23 | conf.set_quoted('SYSTEMD_BUSNAME', 'org.freedesktop.systemd1') |
| 24 | conf.set_quoted('SYSTEMD_PATH', '/org/freedesktop/systemd1') |
| 25 | conf.set_quoted('SYSTEMD_INTERFACE', 'org.freedesktop.systemd1.Manager') |
| 26 | conf.set_quoted('VERSION_BUSNAME', 'xyz.openbmc_project.Software.Version') |
| 27 | conf.set_quoted('VERSION_IFACE', 'xyz.openbmc_project.Software.Version') |
Chanh Nguyen | 1fd6ddd | 2021-01-06 11:09:09 +0700 | [diff] [blame] | 28 | conf.set_quoted('EXTENDED_VERSION_IFACE', 'xyz.openbmc_project.Software.ExtendedVersion') |
Adriana Kobylak | 0af80a4 | 2020-05-05 13:32:10 -0500 | [diff] [blame] | 29 | |
| 30 | # Names of the forward and reverse associations |
| 31 | conf.set_quoted('ACTIVATION_FWD_ASSOCIATION', 'inventory') |
| 32 | conf.set_quoted('ACTIVATION_REV_ASSOCIATION', 'activation') |
| 33 | conf.set_quoted('ACTIVE_FWD_ASSOCIATION', 'active') |
| 34 | conf.set_quoted('ACTIVE_REV_ASSOCIATION', 'software_version') |
| 35 | conf.set_quoted('FUNCTIONAL_FWD_ASSOCIATION', 'functional') |
| 36 | conf.set_quoted('FUNCTIONAL_REV_ASSOCIATION', 'software_version') |
| 37 | conf.set_quoted('UPDATEABLE_FWD_ASSOCIATION', 'updateable') |
| 38 | conf.set_quoted('UPDATEABLE_REV_ASSOCIATION', 'software_version') |
| 39 | |
| 40 | # Filesystem files and directories |
| 41 | # The path of the alt rwfs overlay |
| 42 | conf.set_quoted('ALT_RWFS', '/media/alt/var/persist') |
| 43 | # The prefix path for the versioned read-only bmc partitions |
| 44 | conf.set_quoted('BMC_ROFS_PREFIX', get_option('media-dir') + '/rofs-') |
| 45 | # The name of the BMC table of contents file |
| 46 | conf.set_quoted('OS_RELEASE_FILE', '/etc/os-release') |
| 47 | # The dir where activation data is stored in files |
| 48 | conf.set_quoted('PERSIST_DIR', '/var/lib/phosphor-bmc-code-mgmt/') |
| 49 | |
| 50 | # Supported BMC layout types |
| 51 | conf.set('STATIC_LAYOUT', get_option('bmc-layout').contains('static')) |
| 52 | conf.set('UBIFS_LAYOUT', get_option('bmc-layout').contains('ubi')) |
Adriana Kobylak | 70f5bc0 | 2020-05-13 14:08:14 -0500 | [diff] [blame] | 53 | conf.set('MMC_LAYOUT', get_option('bmc-layout').contains('mmc')) |
Adriana Kobylak | 0af80a4 | 2020-05-05 13:32:10 -0500 | [diff] [blame] | 54 | |
| 55 | # Configurable features |
| 56 | conf.set('HOST_BIOS_UPGRADE', get_option('host-bios-upgrade').enabled()) |
Adriana Kobylak | 42bd993 | 2021-01-28 09:45:24 -0600 | [diff] [blame] | 57 | conf.set('WANT_SIGNATURE_VERIFY', \ |
| 58 | get_option('verify-signature').enabled() or \ |
| 59 | get_option('verify-full-signature').enabled()) |
George Liu | 0a06e97 | 2020-12-17 09:17:04 +0800 | [diff] [blame] | 60 | conf.set('WANT_SIGNATURE_FULL_VERIFY', get_option('verify-full-signature').enabled()) |
Adriana Kobylak | 0af80a4 | 2020-05-05 13:32:10 -0500 | [diff] [blame] | 61 | |
| 62 | # Configurable variables |
| 63 | conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed')) |
| 64 | conf.set_quoted('HASH_FILE_NAME', get_option('hash-file-name')) |
| 65 | conf.set_quoted('IMG_UPLOAD_DIR', get_option('img-upload-dir')) |
| 66 | conf.set_quoted('MANIFEST_FILE_NAME', get_option('manifest-file-name')) |
| 67 | conf.set_quoted('MEDIA_DIR', get_option('media-dir')) |
Adriana Kobylak | 73609bb | 2020-06-18 15:05:40 -0500 | [diff] [blame] | 68 | optional_array = get_option('optional-images') |
| 69 | optional_images = '' |
| 70 | foreach optiona_image : optional_array |
| 71 | optional_images = ' '.join([optional_images, optiona_image]) |
| 72 | endforeach |
| 73 | conf.set_quoted('OPTIONAL_IMAGES', optional_images) |
Adriana Kobylak | 0af80a4 | 2020-05-05 13:32:10 -0500 | [diff] [blame] | 74 | conf.set_quoted('PUBLICKEY_FILE_NAME', get_option('publickey-file-name')) |
| 75 | conf.set_quoted('SIGNATURE_FILE_EXT', get_option('signature-file-ext')) |
| 76 | conf.set_quoted('SIGNED_IMAGE_CONF_PATH', get_option('signed-image-conf-path')) |
| 77 | conf.set_quoted('SYNC_LIST_DIR_PATH', get_option('sync-list-dir-path')) |
| 78 | conf.set_quoted('SYNC_LIST_FILE_NAME', get_option('sync-list-file-name')) |
Miguel Gomez | 21dad04 | 2020-06-26 20:54:48 +0000 | [diff] [blame] | 79 | conf.set_quoted('BMC_MSL', get_option('bmc-msl')) |
| 80 | conf.set_quoted('REGEX_BMC_MSL', get_option('regex-bmc-msl')) |
| 81 | |
Lei YU | 6e9fb1d | 2021-02-19 18:01:40 +0800 | [diff] [blame] | 82 | if get_option('host-bios-upgrade').enabled() |
| 83 | conf.set_quoted('BIOS_OBJPATH', get_option('bios-object-path')) |
| 84 | endif |
Adriana Kobylak | 0af80a4 | 2020-05-05 13:32:10 -0500 | [diff] [blame] | 85 | |
| 86 | configure_file(output: 'config.h', configuration: conf) |
Adriana Kobylak | 113492e | 2020-05-05 13:45:45 -0500 | [diff] [blame] | 87 | |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 88 | deps = [ |
| 89 | dependency('phosphor-dbus-interfaces'), |
| 90 | dependency('phosphor-logging'), |
| 91 | dependency('sdbusplus') |
| 92 | ] |
| 93 | |
| 94 | ssl = dependency('openssl') |
| 95 | |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 96 | systemd = dependency('systemd') |
| 97 | systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir') |
| 98 | |
| 99 | unit_files = [ |
Adriana Kobylak | 436be81 | 2020-06-17 09:44:56 -0500 | [diff] [blame] | 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' |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 109 | ] |
| 110 | |
Adriana Kobylak | 113492e | 2020-05-05 13:45:45 -0500 | [diff] [blame] | 111 | sdbuspp = find_program('sdbus++') |
| 112 | subdir('xyz/openbmc_project/Software/Image') |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 113 | |
| 114 | image_updater_sources = files( |
| 115 | 'activation.cpp', |
Adriana Kobylak | 73609bb | 2020-06-18 15:05:40 -0500 | [diff] [blame] | 116 | 'images.cpp', |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 117 | 'item_updater.cpp', |
| 118 | 'item_updater_main.cpp', |
| 119 | 'serialize.cpp', |
| 120 | 'version.cpp', |
Miguel Gomez | 21dad04 | 2020-06-26 20:54:48 +0000 | [diff] [blame] | 121 | 'utils.cpp', |
| 122 | 'msl_verify.cpp' |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 123 | ) |
| 124 | |
| 125 | if get_option('bmc-layout').contains('static') |
Adriana Kobylak | 436be81 | 2020-06-17 09:44:56 -0500 | [diff] [blame] | 126 | image_updater_sources += files( |
| 127 | 'static/flash.cpp', |
| 128 | 'static/item_updater_helper.cpp' |
| 129 | ) |
Adriana Kobylak | 86013f3 | 2020-05-13 12:12:38 -0500 | [diff] [blame] | 130 | elif get_option('bmc-layout').contains('ubi') |
Adriana Kobylak | 436be81 | 2020-06-17 09:44:56 -0500 | [diff] [blame] | 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 | ] |
Adriana Kobylak | 86013f3 | 2020-05-13 12:12:38 -0500 | [diff] [blame] | 146 | elif get_option('bmc-layout').contains('mmc') |
Adriana Kobylak | 436be81 | 2020-06-17 09:44:56 -0500 | [diff] [blame] | 147 | image_updater_sources += files( |
| 148 | 'mmc/flash.cpp', |
| 149 | 'mmc/item_updater_helper.cpp' |
| 150 | ) |
Adriana Kobylak | 70f5bc0 | 2020-05-13 14:08:14 -0500 | [diff] [blame] | 151 | |
| 152 | unit_files += [ |
| 153 | 'mmc/obmc-flash-mmc@.service.in', |
Adriana Kobylak | d7fbc1e | 2020-06-06 07:46:40 -0500 | [diff] [blame] | 154 | 'mmc/obmc-flash-mmc-mount.service.in', |
Adriana Kobylak | 70f5bc0 | 2020-05-13 14:08:14 -0500 | [diff] [blame] | 155 | 'mmc/obmc-flash-mmc-remove@.service.in', |
Adriana Kobylak | 3412435 | 2020-05-22 09:40:40 -0500 | [diff] [blame] | 156 | 'mmc/obmc-flash-mmc-setprimary@.service.in', |
Adriana Kobylak | d7fbc1e | 2020-06-06 07:46:40 -0500 | [diff] [blame] | 157 | 'mmc/obmc-flash-mmc-umount.service.in', |
Adriana Kobylak | 70f5bc0 | 2020-05-13 14:08:14 -0500 | [diff] [blame] | 158 | ] |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 159 | endif |
| 160 | |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 161 | if get_option('host-bios-upgrade').enabled() |
Adriana Kobylak | 436be81 | 2020-06-17 09:44:56 -0500 | [diff] [blame] | 162 | unit_files += 'obmc-flash-host-bios@.service.in' |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 163 | endif |
| 164 | |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 165 | if 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 | ) |
Adriana Kobylak | 817209f | 2020-05-07 09:52:03 -0500 | [diff] [blame] | 174 | |
| 175 | install_data('synclist', |
| 176 | install_dir: get_option('sysconfdir') |
| 177 | ) |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 178 | endif |
| 179 | |
Adriana Kobylak | 42bd993 | 2021-01-28 09:45:24 -0600 | [diff] [blame] | 180 | if (get_option('verify-signature').enabled() or \ |
| 181 | get_option('verify-full-signature').enabled()) |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 182 | image_updater_sources += files( |
George Liu | 0a06e97 | 2020-12-17 09:17:04 +0800 | [diff] [blame] | 183 | 'utils.cpp', |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 184 | 'image_verify.cpp', |
| 185 | 'openssl_alloc.cpp' |
| 186 | ) |
| 187 | endif |
| 188 | |
| 189 | executable( |
| 190 | 'phosphor-download-manager', |
| 191 | 'download_manager.cpp', |
| 192 | 'download_manager_main.cpp', |
| 193 | dependencies: deps, |
| 194 | install: true |
| 195 | ) |
| 196 | |
| 197 | executable( |
| 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 | |
| 206 | executable( |
| 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 | ) |
Adriana Kobylak | 817209f | 2020-05-07 09:52:03 -0500 | [diff] [blame] | 217 | |
| 218 | install_data('obmc-flash-bmc', |
| 219 | install_mode: 'rwxr-xr-x', |
| 220 | install_dir: get_option('bindir') |
| 221 | ) |
| 222 | |
| 223 | install_data('software.conf', |
| 224 | install_dir: '/usr/lib/tmpfiles.d/' |
| 225 | ) |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 226 | |
| 227 | foreach u : unit_files |
| 228 | configure_file( |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 229 | input: u, |
Adriana Kobylak | 436be81 | 2020-06-17 09:44:56 -0500 | [diff] [blame] | 230 | output: '@BASENAME@', |
| 231 | configuration: conf, |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 232 | install: true, |
| 233 | install_dir: systemd_system_unit_dir, |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 234 | ) |
| 235 | endforeach |
Adriana Kobylak | 78e72d9 | 2020-05-05 14:01:54 -0500 | [diff] [blame] | 236 | |
| 237 | # If test coverage of source files within the root directory are wanted, |
| 238 | # need to define and build the tests from here |
| 239 | build_tests = get_option('tests') |
| 240 | if 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: [ |
George Liu | 0a06e97 | 2020-12-17 09:17:04 +0800 | [diff] [blame] | 258 | 'utils.cpp', |
Adriana Kobylak | 78e72d9 | 2020-05-05 14:01:54 -0500 | [diff] [blame] | 259 | 'image_verify.cpp', |
Adriana Kobylak | 73609bb | 2020-06-18 15:05:40 -0500 | [diff] [blame] | 260 | 'images.cpp', |
Adriana Kobylak | 78e72d9 | 2020-05-05 14:01:54 -0500 | [diff] [blame] | 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 | ) |
| 273 | endif |