Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 1 | project( |
| 2 | 'openpower-pnor-code-mgmt', |
| 3 | 'cpp', |
| 4 | default_options: [ |
| 5 | 'warning_level=3', |
| 6 | 'werror=true', |
Adriana Kobylak | 067876a | 2021-04-26 19:36:39 +0000 | [diff] [blame] | 7 | 'cpp_std=c++20', |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 8 | 'buildtype=debugoptimized', |
| 9 | 'b_ndebug=if-release', |
| 10 | 'b_lto=true', |
| 11 | ], |
| 12 | license: 'Apache-2.0', |
| 13 | version: '1.0', |
Adriana Kobylak | 067876a | 2021-04-26 19:36:39 +0000 | [diff] [blame] | 14 | meson_version: '>=0.57.0', |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 15 | ) |
| 16 | |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 17 | if(get_option('buildtype') == 'minsize') |
| 18 | add_project_arguments('-DNDEBUG', language : 'cpp') |
| 19 | endif |
| 20 | |
| 21 | # Disable lto when compiling with no optimization |
| 22 | if(get_option('optimization') == '0') |
| 23 | add_project_arguments('-fno-lto', language: 'cpp') |
| 24 | message('Disabling lto because optimization is disabled') |
| 25 | endif |
| 26 | |
Brad Bishop | 099543e | 2020-11-09 15:37:58 -0500 | [diff] [blame] | 27 | cxx = meson.get_compiler('cpp') |
| 28 | |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 29 | extra_sources = [] |
| 30 | extra_unit_files = [] |
| 31 | extra_scripts = [] |
| 32 | |
| 33 | build_vpnor = get_option('vpnor').enabled() |
Adriana Kobylak | 6fc7fcd | 2021-10-18 18:47:55 +0000 | [diff] [blame] | 34 | build_pldm = get_option('pldm').enabled() |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 35 | build_verify_signature = get_option('verify-signature').enabled() |
| 36 | |
Brad Bishop | 099543e | 2020-11-09 15:37:58 -0500 | [diff] [blame] | 37 | if not cxx.has_header('CLI/CLI.hpp') |
| 38 | error('Could not find CLI.hpp') |
| 39 | endif |
| 40 | |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 41 | summary('building for device type', '@0@'.format(get_option('device-type'))) |
| 42 | summary('building vpnor', build_vpnor) |
Adriana Kobylak | 6fc7fcd | 2021-10-18 18:47:55 +0000 | [diff] [blame] | 43 | summary('building pldm', build_pldm) |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 44 | summary('building signature verify', build_verify_signature) |
| 45 | |
| 46 | subs = configuration_data() |
| 47 | subs.set_quoted('ACTIVATION_FWD_ASSOCIATION', 'inventory') |
| 48 | subs.set_quoted('ACTIVATION_REV_ASSOCIATION', 'activation') |
| 49 | subs.set_quoted('ACTIVE_FWD_ASSOCIATION', 'active') |
| 50 | subs.set('ACTIVE_PNOR_MAX_ALLOWED', 2) |
| 51 | subs.set_quoted('ACTIVE_REV_ASSOCIATION', 'software_version') |
| 52 | subs.set_quoted('ASSOCIATIONS_INTERFACE', 'xyz.openbmc_project.Association.Definitions') |
Brad Bishop | 7c053c3 | 2020-11-16 12:58:11 -0500 | [diff] [blame] | 53 | subs.set_quoted('BUSNAME_UPDATER', 'org.open_power.Software.Host.Updater') |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 54 | subs.set_quoted('CHASSIS_STATE_OBJ', 'xyz.openbmc_project.State.Chassis') |
| 55 | subs.set_quoted('CHASSIS_STATE_OFF', 'xyz.openbmc_project.State.Chassis.PowerState.Off') |
| 56 | subs.set_quoted('CHASSIS_STATE_PATH', '/xyz/openbmc_project/state/chassis0') |
| 57 | subs.set_quoted('FILEPATH_IFACE', 'xyz.openbmc_project.Common.FilePath') |
| 58 | subs.set_quoted('FUNCTIONAL_FWD_ASSOCIATION', 'functional') |
| 59 | subs.set_quoted('FUNCTIONAL_REV_ASSOCIATION', 'software_version') |
| 60 | subs.set_quoted('HASH_FILE_NAME', 'hashfunc') |
| 61 | subs.set_quoted('HOST_INVENTORY_PATH', '/xyz/openbmc_project/inventory/system/chassis') |
| 62 | subs.set_quoted('IMG_DIR', '/tmp/images') |
| 63 | subs.set_quoted('MANIFEST_FILE', 'MANIFEST') |
| 64 | subs.set_quoted('MAPPER_BUSNAME', 'xyz.openbmc_project.ObjectMapper') |
| 65 | subs.set_quoted('MAPPER_INTERFACE', 'xyz.openbmc_project.ObjectMapper') |
| 66 | subs.set_quoted('MAPPER_PATH', '/xyz/openbmc_project/object_mapper') |
| 67 | subs.set_quoted('MEDIA_DIR', '/media/') |
| 68 | subs.set('MMC_LAYOUT', get_option('device-type') == 'mmc') |
| 69 | subs.set_quoted('PERSIST_DIR', '/var/lib/obmc/openpower-pnor-code-mgmt/') |
| 70 | subs.set_quoted('PNOR_ACTIVE_PATH', '/var/lib/phosphor-software-manager/pnor/') |
| 71 | subs.set_quoted('PNOR_MSL', get_option('msl')) |
| 72 | subs.set_quoted('PNOR_PRSV', '/media/pnor-prsv') |
| 73 | subs.set_quoted('PNOR_PRSV_ACTIVE_PATH', '/var/lib/phosphor-software-manager/pnor/prsv') |
| 74 | subs.set_quoted('PNOR_RO_ACTIVE_PATH', '/var/lib/phosphor-software-manager/pnor/ro') |
| 75 | subs.set_quoted('PNOR_RO_PREFIX', '/media/pnor-ro-') |
| 76 | subs.set_quoted('PNOR_RW_ACTIVE_PATH', '/var/lib/phosphor-software-manager/pnor/rw') |
| 77 | subs.set_quoted('PNOR_RW_PREFIX', '/media/pnor-rw-') |
| 78 | subs.set_quoted('PNOR_SIGNED_IMAGE_CONF_PATH', '/etc/activationdata/') |
| 79 | subs.set_quoted('PNOR_TOC_FILE', 'pnor.toc') |
| 80 | subs.set_quoted('PNOR_VERSION_PARTITION', 'VERSION') |
| 81 | subs.set_quoted('PUBLICKEY_FILE_NAME', 'publickey') |
| 82 | subs.set_quoted('SIGNATURE_FILE_EXT', '.sig') |
| 83 | subs.set_quoted('SOFTWARE_OBJPATH', '/xyz/openbmc_project/software') |
| 84 | subs.set_quoted('SYSTEMD_BUSNAME', 'org.freedesktop.systemd1') |
| 85 | subs.set_quoted('SYSTEMD_INTERFACE', 'org.freedesktop.systemd1.Manager') |
| 86 | subs.set_quoted('SYSTEMD_PATH', '/org/freedesktop/systemd1') |
| 87 | subs.set_quoted('SYSTEMD_PROPERTY_INTERFACE', 'org.freedesktop.DBus.Properties') |
| 88 | subs.set('UBIFS_LAYOUT', get_option('device-type') == 'ubi') |
| 89 | subs.set_quoted('UPDATEABLE_FWD_ASSOCIATION', 'updateable') |
| 90 | subs.set_quoted('UPDATEABLE_REV_ASSOCIATION', 'software_version') |
| 91 | subs.set_quoted('VERSION_IFACE', 'xyz.openbmc_project.Software.Version') |
| 92 | subs.set('WANT_SIGNATURE_VERIFY', build_verify_signature) |
| 93 | configure_file( |
| 94 | output: 'config.h', |
| 95 | configuration: subs) |
| 96 | |
| 97 | if get_option('device-type') == 'ubi' |
| 98 | extra_sources += [ |
| 99 | 'ubi/activation_ubi.cpp', |
| 100 | 'ubi/item_updater_ubi.cpp', |
| 101 | 'ubi/serialize.cpp', |
| 102 | 'ubi/watch.cpp', |
| 103 | ] |
| 104 | extra_scripts += [ |
| 105 | 'ubi/obmc-flash-bios', |
| 106 | ] |
| 107 | extra_unit_files += [ |
| 108 | 'ubi/obmc-flash-bios-cleanup.service', |
| 109 | 'ubi/obmc-flash-bios-ubiattach.service', |
| 110 | 'ubi/obmc-flash-bios-ubimount@.service', |
| 111 | 'ubi/obmc-flash-bios-ubipatch.service', |
| 112 | 'ubi/obmc-flash-bios-ubiremount.service', |
| 113 | 'ubi/obmc-flash-bios-ubiumount-ro@.service', |
| 114 | 'ubi/obmc-flash-bios-ubiumount-rw@.service', |
| 115 | ] |
| 116 | endif |
| 117 | |
| 118 | if get_option('device-type') == 'mmc' |
| 119 | extra_sources += [ |
| 120 | 'mmc/activation_mmc.cpp', |
| 121 | 'mmc/item_updater_mmc.cpp', |
| 122 | ] |
| 123 | extra_scripts += [ |
| 124 | 'mmc/obmc-flash-bios', |
| 125 | ] |
| 126 | extra_unit_files += [ |
| 127 | 'mmc/obmc-flash-bios-init.service', |
| 128 | 'mmc/obmc-flash-bios-patch.service', |
Isaac Kurth | 514a094 | 2021-10-19 21:17:44 +0000 | [diff] [blame] | 129 | 'mmc/openpower-bios-factory-reset.service', |
Adriana Kobylak | 6fc7fcd | 2021-10-18 18:47:55 +0000 | [diff] [blame] | 130 | ] |
| 131 | endif |
| 132 | |
| 133 | if build_pldm |
| 134 | extra_unit_files += [ |
Adriana Kobylak | ac5aec1 | 2021-06-22 16:22:17 +0000 | [diff] [blame] | 135 | 'mmc/openpower-process-host-firmware.service', |
Adriana Kobylak | 53a2739 | 2021-06-14 17:42:40 +0000 | [diff] [blame] | 136 | 'mmc/openpower-update-bios-attr-table.service', |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 137 | ] |
| 138 | endif |
| 139 | |
| 140 | if get_option('device-type') == 'static' |
| 141 | extra_sources += [ |
| 142 | 'static/item_updater_static.cpp', |
| 143 | 'static/activation_static.cpp', |
| 144 | ] |
| 145 | extra_unit_files += [ |
| 146 | 'openpower-pnor-update@.service', |
| 147 | ] |
| 148 | endif |
| 149 | |
| 150 | if build_verify_signature |
| 151 | extra_sources += [ |
| 152 | 'image_verify.cpp' |
| 153 | ] |
| 154 | endif |
| 155 | |
| 156 | if build_vpnor |
| 157 | extra_scripts += [ |
| 158 | 'vpnor/obmc-vpnor-util', |
| 159 | ] |
| 160 | extra_unit_files += [ |
| 161 | 'vpnor/obmc-vpnor-check-clearvolatile@.service', |
| 162 | 'vpnor/obmc-vpnor-enable-clearvolatile@.service', |
| 163 | 'vpnor/obmc-vpnor-updatesymlinks.service', |
| 164 | ] |
| 165 | endif |
| 166 | |
| 167 | executable( |
| 168 | 'openpower-update-manager', |
| 169 | [ |
| 170 | 'activation.cpp', |
Brad Bishop | 099543e | 2020-11-09 15:37:58 -0500 | [diff] [blame] | 171 | 'functions.cpp', |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 172 | 'version.cpp', |
| 173 | 'item_updater.cpp', |
| 174 | 'item_updater_main.cpp', |
| 175 | 'utils.cpp', |
| 176 | ] + extra_sources, |
| 177 | dependencies: [ |
| 178 | dependency('libcrypto'), |
| 179 | dependency('libsystemd'), |
| 180 | dependency('openssl'), |
| 181 | dependency('phosphor-dbus-interfaces'), |
| 182 | dependency('phosphor-logging'), |
| 183 | dependency('sdbusplus'), |
Brad Bishop | 0283f7c | 2020-11-09 10:09:26 -0500 | [diff] [blame] | 184 | dependency('sdeventplus'), |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 185 | ], |
| 186 | install: true |
| 187 | ) |
| 188 | |
| 189 | executable( |
| 190 | 'openpower-pnor-msl', |
| 191 | [ |
| 192 | 'msl_verify.cpp', |
| 193 | 'msl_verify_main.cpp', |
| 194 | ], |
| 195 | dependencies: [ |
| 196 | dependency('libsystemd'), |
| 197 | dependency('phosphor-dbus-interfaces'), |
| 198 | dependency('phosphor-logging'), |
| 199 | dependency('sdbusplus'), |
| 200 | ], |
| 201 | install: true |
| 202 | ) |
| 203 | |
| 204 | foreach s : extra_scripts |
| 205 | configure_file( |
| 206 | input: s, |
| 207 | copy: true, |
| 208 | install: true, |
| 209 | install_mode: 'rwxr-xr-x', |
| 210 | install_dir: get_option('bindir'), |
| 211 | output: '@BASENAME@' |
| 212 | ) |
| 213 | endforeach |
| 214 | |
| 215 | unit_files = [ |
| 216 | 'op-pnor-msl.service', |
| 217 | 'org.open_power.Software.Host.Updater.service', |
| 218 | ] + extra_unit_files |
| 219 | |
Adriana Kobylak | 067876a | 2021-04-26 19:36:39 +0000 | [diff] [blame] | 220 | systemd_system_unit_dir = dependency('systemd').get_variable( |
| 221 | pkgconfig: 'systemdsystemunitdir', |
| 222 | pkgconfig_define: ['prefix', get_option('prefix')]) |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 223 | foreach u : unit_files |
| 224 | configure_file( |
| 225 | input: u, |
| 226 | copy: true, |
| 227 | install: true, |
| 228 | install_dir: systemd_system_unit_dir, |
| 229 | output: '@BASENAME@.service' |
| 230 | ) |
| 231 | endforeach |
| 232 | |
Adriana Kobylak | 067876a | 2021-04-26 19:36:39 +0000 | [diff] [blame] | 233 | dbus_system_bus_services_dir = dependency('dbus-1').get_variable( |
| 234 | pkgconfig: 'system_bus_services_dir', |
| 235 | pkgconfig_define: ['prefix', get_option('prefix')]) |
Brad Bishop | 671a7da | 2020-11-15 13:31:05 -0500 | [diff] [blame] | 236 | dbus_policy_dir = run_command( |
| 237 | 'realpath', |
| 238 | join_paths(dbus_system_bus_services_dir, '..', 'system.d')).stdout().strip() |
| 239 | |
| 240 | install_data( |
| 241 | 'dbus/org.open_power.Software.Host.Updater.conf', |
| 242 | install_dir: dbus_policy_dir) |
| 243 | |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 244 | if not get_option('tests').disabled() |
Adriana Kobylak | 588a9fa | 2021-06-22 14:28:45 +0000 | [diff] [blame] | 245 | oe_sdk = get_option('oe-sdk') |
| 246 | if oe_sdk.enabled() |
| 247 | # Setup OE SYSROOT |
| 248 | OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip() |
| 249 | if OECORE_TARGET_SYSROOT == '' |
| 250 | error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.') |
| 251 | endif |
| 252 | message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT) |
| 253 | rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib']) |
| 254 | ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip() |
| 255 | dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so] |
| 256 | else |
| 257 | dynamic_linker = [] |
| 258 | endif |
| 259 | |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 260 | test( |
| 261 | 'utest', |
| 262 | executable( |
| 263 | 'utest', |
| 264 | 'activation.cpp', |
| 265 | 'version.cpp', |
| 266 | 'item_updater.cpp', |
| 267 | 'image_verify.cpp', |
| 268 | 'utils.cpp', |
| 269 | 'msl_verify.cpp', |
| 270 | 'ubi/activation_ubi.cpp', |
| 271 | 'ubi/item_updater_ubi.cpp', |
| 272 | 'ubi/serialize.cpp', |
| 273 | 'ubi/watch.cpp', |
| 274 | 'static/item_updater_static.cpp', |
| 275 | 'static/activation_static.cpp', |
| 276 | 'test/test_signature.cpp', |
| 277 | 'test/test_version.cpp', |
| 278 | 'test/test_item_updater_static.cpp', |
| 279 | 'msl_verify.cpp', |
| 280 | dependencies: [ |
| 281 | dependency('libcrypto'), |
| 282 | dependency('gtest', main: true), |
| 283 | dependency('openssl'), |
| 284 | dependency('phosphor-logging'), |
| 285 | dependency('phosphor-dbus-interfaces'), |
| 286 | ], |
| 287 | implicit_include_directories: false, |
| 288 | include_directories: '.', |
| 289 | ) |
| 290 | ) |
Brad Bishop | 099543e | 2020-11-09 15:37:58 -0500 | [diff] [blame] | 291 | test( |
| 292 | 'test_functions', |
| 293 | executable( |
| 294 | 'test_functions', |
| 295 | 'test/test_functions.cpp', |
| 296 | 'functions.cpp', |
| 297 | dependencies: [ |
| 298 | dependency('gtest', main: true), |
Adriana Kobylak | 2b78eb0 | 2022-04-06 19:38:47 +0000 | [diff] [blame] | 299 | dependency('phosphor-dbus-interfaces'), |
Brad Bishop | 099543e | 2020-11-09 15:37:58 -0500 | [diff] [blame] | 300 | dependency('sdbusplus'), |
| 301 | dependency('sdeventplus'), |
| 302 | ], |
| 303 | ) |
| 304 | ) |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 305 | endif |