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