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', |
Adriana Kobylak | 53a2739 | 2021-06-14 17:42:40 +0000 | [diff] [blame] | 128 | 'mmc/openpower-update-bios-attr-table.service', |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 129 | ] |
| 130 | endif |
| 131 | |
| 132 | if get_option('device-type') == 'static' |
| 133 | extra_sources += [ |
| 134 | 'static/item_updater_static.cpp', |
| 135 | 'static/activation_static.cpp', |
| 136 | ] |
| 137 | extra_unit_files += [ |
| 138 | 'openpower-pnor-update@.service', |
| 139 | ] |
| 140 | endif |
| 141 | |
| 142 | if build_verify_signature |
| 143 | extra_sources += [ |
| 144 | 'image_verify.cpp' |
| 145 | ] |
| 146 | endif |
| 147 | |
| 148 | if build_vpnor |
| 149 | extra_scripts += [ |
| 150 | 'vpnor/obmc-vpnor-util', |
| 151 | ] |
| 152 | extra_unit_files += [ |
| 153 | 'vpnor/obmc-vpnor-check-clearvolatile@.service', |
| 154 | 'vpnor/obmc-vpnor-enable-clearvolatile@.service', |
| 155 | 'vpnor/obmc-vpnor-updatesymlinks.service', |
| 156 | ] |
| 157 | endif |
| 158 | |
| 159 | executable( |
| 160 | 'openpower-update-manager', |
| 161 | [ |
| 162 | 'activation.cpp', |
Brad Bishop | 099543e | 2020-11-09 15:37:58 -0500 | [diff] [blame] | 163 | 'functions.cpp', |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 164 | 'version.cpp', |
| 165 | 'item_updater.cpp', |
| 166 | 'item_updater_main.cpp', |
| 167 | 'utils.cpp', |
| 168 | ] + extra_sources, |
| 169 | dependencies: [ |
| 170 | dependency('libcrypto'), |
| 171 | dependency('libsystemd'), |
| 172 | dependency('openssl'), |
| 173 | dependency('phosphor-dbus-interfaces'), |
| 174 | dependency('phosphor-logging'), |
| 175 | dependency('sdbusplus'), |
Brad Bishop | 0283f7c | 2020-11-09 10:09:26 -0500 | [diff] [blame] | 176 | dependency('sdeventplus'), |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 177 | ], |
| 178 | install: true |
| 179 | ) |
| 180 | |
| 181 | executable( |
| 182 | 'openpower-pnor-msl', |
| 183 | [ |
| 184 | 'msl_verify.cpp', |
| 185 | 'msl_verify_main.cpp', |
| 186 | ], |
| 187 | dependencies: [ |
| 188 | dependency('libsystemd'), |
| 189 | dependency('phosphor-dbus-interfaces'), |
| 190 | dependency('phosphor-logging'), |
| 191 | dependency('sdbusplus'), |
| 192 | ], |
| 193 | install: true |
| 194 | ) |
| 195 | |
| 196 | foreach s : extra_scripts |
| 197 | configure_file( |
| 198 | input: s, |
| 199 | copy: true, |
| 200 | install: true, |
| 201 | install_mode: 'rwxr-xr-x', |
| 202 | install_dir: get_option('bindir'), |
| 203 | output: '@BASENAME@' |
| 204 | ) |
| 205 | endforeach |
| 206 | |
| 207 | unit_files = [ |
| 208 | 'op-pnor-msl.service', |
| 209 | 'org.open_power.Software.Host.Updater.service', |
| 210 | ] + extra_unit_files |
| 211 | |
Adriana Kobylak | 067876a | 2021-04-26 19:36:39 +0000 | [diff] [blame] | 212 | systemd_system_unit_dir = dependency('systemd').get_variable( |
| 213 | pkgconfig: 'systemdsystemunitdir', |
| 214 | pkgconfig_define: ['prefix', get_option('prefix')]) |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 215 | foreach u : unit_files |
| 216 | configure_file( |
| 217 | input: u, |
| 218 | copy: true, |
| 219 | install: true, |
| 220 | install_dir: systemd_system_unit_dir, |
| 221 | output: '@BASENAME@.service' |
| 222 | ) |
| 223 | endforeach |
| 224 | |
Adriana Kobylak | 067876a | 2021-04-26 19:36:39 +0000 | [diff] [blame] | 225 | dbus_system_bus_services_dir = dependency('dbus-1').get_variable( |
| 226 | pkgconfig: 'system_bus_services_dir', |
| 227 | pkgconfig_define: ['prefix', get_option('prefix')]) |
Brad Bishop | 671a7da | 2020-11-15 13:31:05 -0500 | [diff] [blame] | 228 | dbus_policy_dir = run_command( |
| 229 | 'realpath', |
| 230 | join_paths(dbus_system_bus_services_dir, '..', 'system.d')).stdout().strip() |
| 231 | |
| 232 | install_data( |
| 233 | 'dbus/org.open_power.Software.Host.Updater.conf', |
| 234 | install_dir: dbus_policy_dir) |
| 235 | |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 236 | if not get_option('tests').disabled() |
Adriana Kobylak | 588a9fa | 2021-06-22 14:28:45 +0000 | [diff] [blame] | 237 | oe_sdk = get_option('oe-sdk') |
| 238 | if oe_sdk.enabled() |
| 239 | # Setup OE SYSROOT |
| 240 | OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip() |
| 241 | if OECORE_TARGET_SYSROOT == '' |
| 242 | error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.') |
| 243 | endif |
| 244 | message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT) |
| 245 | rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib']) |
| 246 | ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip() |
| 247 | dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so] |
| 248 | else |
| 249 | dynamic_linker = [] |
| 250 | endif |
| 251 | |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 252 | test( |
| 253 | 'utest', |
| 254 | executable( |
| 255 | 'utest', |
| 256 | 'activation.cpp', |
| 257 | 'version.cpp', |
| 258 | 'item_updater.cpp', |
| 259 | 'image_verify.cpp', |
| 260 | 'utils.cpp', |
| 261 | 'msl_verify.cpp', |
| 262 | 'ubi/activation_ubi.cpp', |
| 263 | 'ubi/item_updater_ubi.cpp', |
| 264 | 'ubi/serialize.cpp', |
| 265 | 'ubi/watch.cpp', |
| 266 | 'static/item_updater_static.cpp', |
| 267 | 'static/activation_static.cpp', |
| 268 | 'test/test_signature.cpp', |
| 269 | 'test/test_version.cpp', |
| 270 | 'test/test_item_updater_static.cpp', |
| 271 | 'msl_verify.cpp', |
| 272 | dependencies: [ |
| 273 | dependency('libcrypto'), |
| 274 | dependency('gtest', main: true), |
| 275 | dependency('openssl'), |
| 276 | dependency('phosphor-logging'), |
| 277 | dependency('phosphor-dbus-interfaces'), |
| 278 | ], |
| 279 | implicit_include_directories: false, |
| 280 | include_directories: '.', |
| 281 | ) |
| 282 | ) |
Brad Bishop | 099543e | 2020-11-09 15:37:58 -0500 | [diff] [blame] | 283 | test( |
| 284 | 'test_functions', |
| 285 | executable( |
| 286 | 'test_functions', |
| 287 | 'test/test_functions.cpp', |
| 288 | 'functions.cpp', |
| 289 | dependencies: [ |
| 290 | dependency('gtest', main: true), |
| 291 | dependency('sdbusplus'), |
| 292 | dependency('sdeventplus'), |
| 293 | ], |
| 294 | ) |
| 295 | ) |
Brad Bishop | a0fa15b | 2020-11-06 14:42:24 -0500 | [diff] [blame] | 296 | endif |