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