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