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()) |
| 57 | |
| 58 | # Configurable variables |
| 59 | conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed')) |
| 60 | conf.set_quoted('HASH_FILE_NAME', get_option('hash-file-name')) |
| 61 | conf.set_quoted('IMG_UPLOAD_DIR', get_option('img-upload-dir')) |
| 62 | conf.set_quoted('MANIFEST_FILE_NAME', get_option('manifest-file-name')) |
| 63 | conf.set_quoted('MEDIA_DIR', get_option('media-dir')) |
Adriana Kobylak | 73609bb | 2020-06-18 15:05:40 -0500 | [diff] [blame] | 64 | optional_array = get_option('optional-images') |
| 65 | optional_images = '' |
| 66 | foreach optiona_image : optional_array |
| 67 | optional_images = ' '.join([optional_images, optiona_image]) |
| 68 | endforeach |
| 69 | conf.set_quoted('OPTIONAL_IMAGES', optional_images) |
Adriana Kobylak | 0af80a4 | 2020-05-05 13:32:10 -0500 | [diff] [blame] | 70 | conf.set_quoted('PUBLICKEY_FILE_NAME', get_option('publickey-file-name')) |
| 71 | conf.set_quoted('SIGNATURE_FILE_EXT', get_option('signature-file-ext')) |
| 72 | conf.set_quoted('SIGNED_IMAGE_CONF_PATH', get_option('signed-image-conf-path')) |
| 73 | conf.set_quoted('SYNC_LIST_DIR_PATH', get_option('sync-list-dir-path')) |
| 74 | conf.set_quoted('SYNC_LIST_FILE_NAME', get_option('sync-list-file-name')) |
| 75 | |
| 76 | configure_file(output: 'config.h', configuration: conf) |
Adriana Kobylak | 113492e | 2020-05-05 13:45:45 -0500 | [diff] [blame] | 77 | |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 78 | deps = [ |
| 79 | dependency('phosphor-dbus-interfaces'), |
| 80 | dependency('phosphor-logging'), |
| 81 | dependency('sdbusplus') |
| 82 | ] |
| 83 | |
| 84 | ssl = dependency('openssl') |
| 85 | |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 86 | systemd = dependency('systemd') |
| 87 | systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir') |
| 88 | |
| 89 | unit_files = [ |
Adriana Kobylak | 436be81 | 2020-06-17 09:44:56 -0500 | [diff] [blame] | 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' |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 99 | ] |
| 100 | |
Adriana Kobylak | 113492e | 2020-05-05 13:45:45 -0500 | [diff] [blame] | 101 | sdbuspp = find_program('sdbus++') |
| 102 | subdir('xyz/openbmc_project/Software/Image') |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 103 | |
| 104 | image_updater_sources = files( |
| 105 | 'activation.cpp', |
Adriana Kobylak | 73609bb | 2020-06-18 15:05:40 -0500 | [diff] [blame] | 106 | 'images.cpp', |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 107 | 'item_updater.cpp', |
| 108 | 'item_updater_main.cpp', |
| 109 | 'serialize.cpp', |
| 110 | 'version.cpp', |
| 111 | 'utils.cpp' |
| 112 | ) |
| 113 | |
| 114 | if get_option('bmc-layout').contains('static') |
Adriana Kobylak | 436be81 | 2020-06-17 09:44:56 -0500 | [diff] [blame] | 115 | image_updater_sources += files( |
| 116 | 'static/flash.cpp', |
| 117 | 'static/item_updater_helper.cpp' |
| 118 | ) |
Adriana Kobylak | 86013f3 | 2020-05-13 12:12:38 -0500 | [diff] [blame] | 119 | elif get_option('bmc-layout').contains('ubi') |
Adriana Kobylak | 436be81 | 2020-06-17 09:44:56 -0500 | [diff] [blame] | 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 | ] |
Adriana Kobylak | 86013f3 | 2020-05-13 12:12:38 -0500 | [diff] [blame] | 135 | elif get_option('bmc-layout').contains('mmc') |
Adriana Kobylak | 436be81 | 2020-06-17 09:44:56 -0500 | [diff] [blame] | 136 | image_updater_sources += files( |
| 137 | 'mmc/flash.cpp', |
| 138 | 'mmc/item_updater_helper.cpp' |
| 139 | ) |
Adriana Kobylak | 70f5bc0 | 2020-05-13 14:08:14 -0500 | [diff] [blame] | 140 | |
| 141 | unit_files += [ |
| 142 | 'mmc/obmc-flash-mmc@.service.in', |
Adriana Kobylak | d7fbc1e | 2020-06-06 07:46:40 -0500 | [diff] [blame] | 143 | 'mmc/obmc-flash-mmc-mount.service.in', |
Adriana Kobylak | 70f5bc0 | 2020-05-13 14:08:14 -0500 | [diff] [blame] | 144 | 'mmc/obmc-flash-mmc-remove@.service.in', |
Adriana Kobylak | 3412435 | 2020-05-22 09:40:40 -0500 | [diff] [blame] | 145 | 'mmc/obmc-flash-mmc-setprimary@.service.in', |
Adriana Kobylak | d7fbc1e | 2020-06-06 07:46:40 -0500 | [diff] [blame] | 146 | 'mmc/obmc-flash-mmc-umount.service.in', |
Adriana Kobylak | 70f5bc0 | 2020-05-13 14:08:14 -0500 | [diff] [blame] | 147 | ] |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 148 | endif |
| 149 | |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 150 | if get_option('host-bios-upgrade').enabled() |
Adriana Kobylak | 436be81 | 2020-06-17 09:44:56 -0500 | [diff] [blame] | 151 | unit_files += 'obmc-flash-host-bios@.service.in' |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 152 | endif |
| 153 | |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 154 | if 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 | ) |
Adriana Kobylak | 817209f | 2020-05-07 09:52:03 -0500 | [diff] [blame] | 163 | |
| 164 | install_data('synclist', |
| 165 | install_dir: get_option('sysconfdir') |
| 166 | ) |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 167 | endif |
| 168 | |
| 169 | if get_option('verify-signature').enabled() |
| 170 | image_updater_sources += files( |
| 171 | 'image_verify.cpp', |
| 172 | 'openssl_alloc.cpp' |
| 173 | ) |
| 174 | endif |
| 175 | |
| 176 | executable( |
| 177 | 'phosphor-download-manager', |
| 178 | 'download_manager.cpp', |
| 179 | 'download_manager_main.cpp', |
| 180 | dependencies: deps, |
| 181 | install: true |
| 182 | ) |
| 183 | |
| 184 | executable( |
| 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 | |
| 193 | executable( |
| 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 | ) |
Adriana Kobylak | 817209f | 2020-05-07 09:52:03 -0500 | [diff] [blame] | 204 | |
| 205 | install_data('obmc-flash-bmc', |
| 206 | install_mode: 'rwxr-xr-x', |
| 207 | install_dir: get_option('bindir') |
| 208 | ) |
| 209 | |
| 210 | install_data('software.conf', |
| 211 | install_dir: '/usr/lib/tmpfiles.d/' |
| 212 | ) |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 213 | |
| 214 | foreach u : unit_files |
| 215 | configure_file( |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 216 | input: u, |
Adriana Kobylak | 436be81 | 2020-06-17 09:44:56 -0500 | [diff] [blame] | 217 | output: '@BASENAME@', |
| 218 | configuration: conf, |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 219 | install: true, |
| 220 | install_dir: systemd_system_unit_dir, |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 221 | ) |
| 222 | endforeach |
Adriana Kobylak | 78e72d9 | 2020-05-05 14:01:54 -0500 | [diff] [blame] | 223 | |
| 224 | # If test coverage of source files within the root directory are wanted, |
| 225 | # need to define and build the tests from here |
| 226 | build_tests = get_option('tests') |
| 227 | if 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', |
Adriana Kobylak | 73609bb | 2020-06-18 15:05:40 -0500 | [diff] [blame] | 246 | 'images.cpp', |
Adriana Kobylak | 78e72d9 | 2020-05-05 14:01:54 -0500 | [diff] [blame] | 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 | ) |
| 259 | endif |