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