1project( 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 16if get_option('cpp_std') != 'c++17' 17 error('This project requires c++17') 18endif 19 20if(get_option('buildtype') == 'minsize') 21 add_project_arguments('-DNDEBUG', language : 'cpp') 22endif 23 24# Disable lto when compiling with no optimization 25if(get_option('optimization') == '0') 26 add_project_arguments('-fno-lto', language: 'cpp') 27 message('Disabling lto because optimization is disabled') 28endif 29 30cxx = meson.get_compiler('cpp') 31 32extra_sources = [] 33extra_unit_files = [] 34extra_scripts = [] 35 36build_vpnor = get_option('vpnor').enabled() 37build_verify_signature = get_option('verify-signature').enabled() 38 39if not cxx.has_header('CLI/CLI.hpp') 40 error('Could not find CLI.hpp') 41endif 42 43summary('building for device type', '@0@'.format(get_option('device-type'))) 44summary('building vpnor', build_vpnor) 45summary('building signature verify', build_verify_signature) 46 47subs = configuration_data() 48subs.set_quoted('ACTIVATION_FWD_ASSOCIATION', 'inventory') 49subs.set_quoted('ACTIVATION_REV_ASSOCIATION', 'activation') 50subs.set_quoted('ACTIVE_FWD_ASSOCIATION', 'active') 51subs.set('ACTIVE_PNOR_MAX_ALLOWED', 2) 52subs.set_quoted('ACTIVE_REV_ASSOCIATION', 'software_version') 53subs.set_quoted('ASSOCIATIONS_INTERFACE', 'xyz.openbmc_project.Association.Definitions') 54subs.set_quoted('BUSNAME_UPDATER', 'org.open_power.Software.Host.Updater') 55subs.set_quoted('CHASSIS_STATE_OBJ', 'xyz.openbmc_project.State.Chassis') 56subs.set_quoted('CHASSIS_STATE_OFF', 'xyz.openbmc_project.State.Chassis.PowerState.Off') 57subs.set_quoted('CHASSIS_STATE_PATH', '/xyz/openbmc_project/state/chassis0') 58subs.set_quoted('FILEPATH_IFACE', 'xyz.openbmc_project.Common.FilePath') 59subs.set_quoted('FUNCTIONAL_FWD_ASSOCIATION', 'functional') 60subs.set_quoted('FUNCTIONAL_REV_ASSOCIATION', 'software_version') 61subs.set_quoted('HASH_FILE_NAME', 'hashfunc') 62subs.set_quoted('HOST_INVENTORY_PATH', '/xyz/openbmc_project/inventory/system/chassis') 63subs.set_quoted('IMG_DIR', '/tmp/images') 64subs.set_quoted('MANIFEST_FILE', 'MANIFEST') 65subs.set_quoted('MAPPER_BUSNAME', 'xyz.openbmc_project.ObjectMapper') 66subs.set_quoted('MAPPER_INTERFACE', 'xyz.openbmc_project.ObjectMapper') 67subs.set_quoted('MAPPER_PATH', '/xyz/openbmc_project/object_mapper') 68subs.set_quoted('MEDIA_DIR', '/media/') 69subs.set('MMC_LAYOUT', get_option('device-type') == 'mmc') 70subs.set_quoted('PERSIST_DIR', '/var/lib/obmc/openpower-pnor-code-mgmt/') 71subs.set_quoted('PNOR_ACTIVE_PATH', '/var/lib/phosphor-software-manager/pnor/') 72subs.set_quoted('PNOR_MSL', get_option('msl')) 73subs.set_quoted('PNOR_PRSV', '/media/pnor-prsv') 74subs.set_quoted('PNOR_PRSV_ACTIVE_PATH', '/var/lib/phosphor-software-manager/pnor/prsv') 75subs.set_quoted('PNOR_RO_ACTIVE_PATH', '/var/lib/phosphor-software-manager/pnor/ro') 76subs.set_quoted('PNOR_RO_PREFIX', '/media/pnor-ro-') 77subs.set_quoted('PNOR_RW_ACTIVE_PATH', '/var/lib/phosphor-software-manager/pnor/rw') 78subs.set_quoted('PNOR_RW_PREFIX', '/media/pnor-rw-') 79subs.set_quoted('PNOR_SIGNED_IMAGE_CONF_PATH', '/etc/activationdata/') 80subs.set_quoted('PNOR_TOC_FILE', 'pnor.toc') 81subs.set_quoted('PNOR_VERSION_PARTITION', 'VERSION') 82subs.set_quoted('PUBLICKEY_FILE_NAME', 'publickey') 83subs.set_quoted('SIGNATURE_FILE_EXT', '.sig') 84subs.set_quoted('SOFTWARE_OBJPATH', '/xyz/openbmc_project/software') 85subs.set_quoted('SYSTEMD_BUSNAME', 'org.freedesktop.systemd1') 86subs.set_quoted('SYSTEMD_INTERFACE', 'org.freedesktop.systemd1.Manager') 87subs.set_quoted('SYSTEMD_PATH', '/org/freedesktop/systemd1') 88subs.set_quoted('SYSTEMD_PROPERTY_INTERFACE', 'org.freedesktop.DBus.Properties') 89subs.set('UBIFS_LAYOUT', get_option('device-type') == 'ubi') 90subs.set_quoted('UPDATEABLE_FWD_ASSOCIATION', 'updateable') 91subs.set_quoted('UPDATEABLE_REV_ASSOCIATION', 'software_version') 92subs.set_quoted('VERSION_IFACE', 'xyz.openbmc_project.Software.Version') 93subs.set('WANT_SIGNATURE_VERIFY', build_verify_signature) 94configure_file( 95 output: 'config.h', 96 configuration: subs) 97 98if 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 ] 117endif 118 119if 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 ] 131endif 132 133if 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 ] 141endif 142 143if build_verify_signature 144 extra_sources += [ 145 'image_verify.cpp' 146 ] 147endif 148 149if 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 ] 158endif 159 160executable( 161 'openpower-update-manager', 162 [ 163 'activation.cpp', 164 'functions.cpp', 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'), 177 dependency('sdeventplus'), 178 ], 179 install: true 180) 181 182executable( 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 197foreach 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 ) 206endforeach 207 208unit_files = [ 209 'op-pnor-msl.service', 210 'org.open_power.Software.Host.Updater.service', 211] + extra_unit_files 212 213systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable( 214 'systemdsystemunitdir', 215 define_variable: ['prefix', get_option('prefix')]) 216foreach 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 ) 224endforeach 225 226dbus_system_bus_services_dir = dependency('dbus-1').get_pkgconfig_variable( 227 'system_bus_services_dir', 228 define_variable: ['prefix', get_option('prefix')]) 229dbus_policy_dir = run_command( 230 'realpath', 231 join_paths(dbus_system_bus_services_dir, '..', 'system.d')).stdout().strip() 232 233install_data( 234 'dbus/org.open_power.Software.Host.Updater.conf', 235 install_dir: dbus_policy_dir) 236 237if 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 ) 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 ) 282endif 283