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