Adriana Kobylak | 0af80a4 | 2020-05-05 13:32:10 -0500 | [diff] [blame] | 1 | project('phosphor-bmc-code-mgmt', 'cpp', |
| 2 | default_options: [ |
Gunnar Mills | f7a69e1 | 2020-06-15 12:16:51 -0500 | [diff] [blame] | 3 | 'buildtype=debugoptimized', |
| 4 | 'cpp_std=c++17', |
Adriana Kobylak | 0af80a4 | 2020-05-05 13:32:10 -0500 | [diff] [blame] | 5 | 'warning_level=3', |
Gunnar Mills | f7a69e1 | 2020-06-15 12:16:51 -0500 | [diff] [blame] | 6 | 'werror=true' |
Adriana Kobylak | 0af80a4 | 2020-05-05 13:32:10 -0500 | [diff] [blame] | 7 | ], |
| 8 | license: 'Apache-2.0', |
| 9 | version: '1.0') |
| 10 | |
| 11 | conf = configuration_data() |
| 12 | |
| 13 | # DBus information |
| 14 | conf.set_quoted('BMC_INVENTORY_INTERFACE', 'xyz.openbmc_project.Inventory.Item.Bmc') |
| 15 | conf.set_quoted('BUSNAME_UPDATER', 'xyz.openbmc_project.Software.BMC.Updater') |
| 16 | conf.set_quoted('DOWNLOAD_BUSNAME', 'xyz.openbmc_project.Software.Download') |
| 17 | conf.set_quoted('FILEPATH_IFACE', 'xyz.openbmc_project.Common.FilePath') |
| 18 | conf.set_quoted('INVENTORY_PATH', '/xyz/openbmc_project/inventory/') |
| 19 | conf.set_quoted('MAPPER_BUSNAME', 'xyz.openbmc_project.ObjectMapper') |
| 20 | conf.set_quoted('MAPPER_INTERFACE', 'xyz.openbmc_project.ObjectMapper') |
| 21 | conf.set_quoted('MAPPER_PATH', '/xyz/openbmc_project/object_mapper') |
| 22 | conf.set_quoted('SOFTWARE_OBJPATH', '/xyz/openbmc_project/software') |
| 23 | conf.set_quoted('SYSTEMD_BUSNAME', 'org.freedesktop.systemd1') |
| 24 | conf.set_quoted('SYSTEMD_PATH', '/org/freedesktop/systemd1') |
| 25 | conf.set_quoted('SYSTEMD_INTERFACE', 'org.freedesktop.systemd1.Manager') |
| 26 | conf.set_quoted('VERSION_BUSNAME', 'xyz.openbmc_project.Software.Version') |
| 27 | conf.set_quoted('VERSION_IFACE', 'xyz.openbmc_project.Software.Version') |
| 28 | |
| 29 | # Names of the forward and reverse associations |
| 30 | conf.set_quoted('ACTIVATION_FWD_ASSOCIATION', 'inventory') |
| 31 | conf.set_quoted('ACTIVATION_REV_ASSOCIATION', 'activation') |
| 32 | conf.set_quoted('ACTIVE_FWD_ASSOCIATION', 'active') |
| 33 | conf.set_quoted('ACTIVE_REV_ASSOCIATION', 'software_version') |
| 34 | conf.set_quoted('FUNCTIONAL_FWD_ASSOCIATION', 'functional') |
| 35 | conf.set_quoted('FUNCTIONAL_REV_ASSOCIATION', 'software_version') |
| 36 | conf.set_quoted('UPDATEABLE_FWD_ASSOCIATION', 'updateable') |
| 37 | conf.set_quoted('UPDATEABLE_REV_ASSOCIATION', 'software_version') |
| 38 | |
| 39 | # Filesystem files and directories |
| 40 | # The path of the alt rwfs overlay |
| 41 | conf.set_quoted('ALT_RWFS', '/media/alt/var/persist') |
| 42 | # The prefix path for the versioned read-only bmc partitions |
| 43 | conf.set_quoted('BMC_ROFS_PREFIX', get_option('media-dir') + '/rofs-') |
| 44 | # The name of the BMC table of contents file |
| 45 | conf.set_quoted('OS_RELEASE_FILE', '/etc/os-release') |
| 46 | # The dir where activation data is stored in files |
| 47 | conf.set_quoted('PERSIST_DIR', '/var/lib/phosphor-bmc-code-mgmt/') |
| 48 | |
| 49 | # Supported BMC layout types |
| 50 | conf.set('STATIC_LAYOUT', get_option('bmc-layout').contains('static')) |
| 51 | conf.set('UBIFS_LAYOUT', get_option('bmc-layout').contains('ubi')) |
| 52 | |
| 53 | # Configurable features |
| 54 | conf.set('HOST_BIOS_UPGRADE', get_option('host-bios-upgrade').enabled()) |
| 55 | conf.set('WANT_SIGNATURE_VERIFY', get_option('verify-signature').enabled()) |
| 56 | |
| 57 | # Configurable variables |
| 58 | conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed')) |
| 59 | conf.set_quoted('HASH_FILE_NAME', get_option('hash-file-name')) |
| 60 | conf.set_quoted('IMG_UPLOAD_DIR', get_option('img-upload-dir')) |
| 61 | conf.set_quoted('MANIFEST_FILE_NAME', get_option('manifest-file-name')) |
| 62 | conf.set_quoted('MEDIA_DIR', get_option('media-dir')) |
| 63 | conf.set_quoted('PUBLICKEY_FILE_NAME', get_option('publickey-file-name')) |
| 64 | conf.set_quoted('SIGNATURE_FILE_EXT', get_option('signature-file-ext')) |
| 65 | conf.set_quoted('SIGNED_IMAGE_CONF_PATH', get_option('signed-image-conf-path')) |
| 66 | conf.set_quoted('SYNC_LIST_DIR_PATH', get_option('sync-list-dir-path')) |
| 67 | conf.set_quoted('SYNC_LIST_FILE_NAME', get_option('sync-list-file-name')) |
| 68 | |
| 69 | configure_file(output: 'config.h', configuration: conf) |
Adriana Kobylak | 113492e | 2020-05-05 13:45:45 -0500 | [diff] [blame] | 70 | |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 71 | deps = [ |
| 72 | dependency('phosphor-dbus-interfaces'), |
| 73 | dependency('phosphor-logging'), |
| 74 | dependency('sdbusplus') |
| 75 | ] |
| 76 | |
| 77 | ssl = dependency('openssl') |
| 78 | |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 79 | systemd = dependency('systemd') |
| 80 | systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir') |
| 81 | |
| 82 | unit_files = [ |
Adriana Kobylak | 436be81 | 2020-06-17 09:44:56 -0500 | [diff] [blame^] | 83 | 'obmc-flash-bmc-setenv@.service.in', |
| 84 | 'reboot-guard-disable.service.in', |
| 85 | 'reboot-guard-enable.service.in', |
| 86 | 'force-reboot.service.in', |
| 87 | 'usr-local.mount.in', |
| 88 | 'xyz.openbmc_project.Software.BMC.Updater.service.in', |
| 89 | 'xyz.openbmc_project.Software.Download.service.in', |
| 90 | 'xyz.openbmc_project.Software.Sync.service.in', |
| 91 | 'xyz.openbmc_project.Software.Version.service.in' |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 92 | ] |
| 93 | |
Adriana Kobylak | 113492e | 2020-05-05 13:45:45 -0500 | [diff] [blame] | 94 | sdbuspp = find_program('sdbus++') |
| 95 | subdir('xyz/openbmc_project/Software/Image') |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 96 | |
| 97 | image_updater_sources = files( |
| 98 | 'activation.cpp', |
| 99 | 'item_updater.cpp', |
| 100 | 'item_updater_main.cpp', |
| 101 | 'serialize.cpp', |
| 102 | 'version.cpp', |
| 103 | 'utils.cpp' |
| 104 | ) |
| 105 | |
| 106 | if get_option('bmc-layout').contains('static') |
Adriana Kobylak | 436be81 | 2020-06-17 09:44:56 -0500 | [diff] [blame^] | 107 | image_updater_sources += files( |
| 108 | 'static/flash.cpp', |
| 109 | 'static/item_updater_helper.cpp' |
| 110 | ) |
Adriana Kobylak | 86013f3 | 2020-05-13 12:12:38 -0500 | [diff] [blame] | 111 | elif get_option('bmc-layout').contains('ubi') |
Adriana Kobylak | 436be81 | 2020-06-17 09:44:56 -0500 | [diff] [blame^] | 112 | image_updater_sources += files( |
| 113 | 'ubi/flash.cpp', |
| 114 | 'ubi/item_updater_helper.cpp' |
| 115 | ) |
| 116 | |
| 117 | unit_files += [ |
| 118 | 'ubi/obmc-flash-bmc-cleanup.service.in', |
| 119 | 'ubi/obmc-flash-bmc-mirroruboot.service.in', |
| 120 | 'ubi/obmc-flash-bmc-ubiremount.service.in', |
| 121 | 'ubi/obmc-flash-bmc-ubiro@.service.in', |
| 122 | 'ubi/obmc-flash-bmc-ubiro-remove@.service.in', |
| 123 | 'ubi/obmc-flash-bmc-ubirw.service.in', |
| 124 | 'ubi/obmc-flash-bmc-ubirw-remove.service.in', |
| 125 | 'ubi/obmc-flash-bmc-updateubootvars@.service.in' |
| 126 | ] |
Adriana Kobylak | 86013f3 | 2020-05-13 12:12:38 -0500 | [diff] [blame] | 127 | elif get_option('bmc-layout').contains('mmc') |
Adriana Kobylak | 436be81 | 2020-06-17 09:44:56 -0500 | [diff] [blame^] | 128 | image_updater_sources += files( |
| 129 | 'mmc/flash.cpp', |
| 130 | 'mmc/item_updater_helper.cpp' |
| 131 | ) |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 132 | endif |
| 133 | |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 134 | if get_option('host-bios-upgrade').enabled() |
Adriana Kobylak | 436be81 | 2020-06-17 09:44:56 -0500 | [diff] [blame^] | 135 | unit_files += 'obmc-flash-host-bios@.service.in' |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 136 | endif |
| 137 | |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 138 | if get_option('sync-bmc-files').enabled() |
| 139 | executable( |
| 140 | 'phosphor-sync-software-manager', |
| 141 | 'sync_manager.cpp', |
| 142 | 'sync_manager_main.cpp', |
| 143 | 'sync_watch.cpp', |
| 144 | dependencies: deps, |
| 145 | install: true |
| 146 | ) |
Adriana Kobylak | 817209f | 2020-05-07 09:52:03 -0500 | [diff] [blame] | 147 | |
| 148 | install_data('synclist', |
| 149 | install_dir: get_option('sysconfdir') |
| 150 | ) |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 151 | endif |
| 152 | |
| 153 | if get_option('verify-signature').enabled() |
| 154 | image_updater_sources += files( |
| 155 | 'image_verify.cpp', |
| 156 | 'openssl_alloc.cpp' |
| 157 | ) |
| 158 | endif |
| 159 | |
| 160 | executable( |
| 161 | 'phosphor-download-manager', |
| 162 | 'download_manager.cpp', |
| 163 | 'download_manager_main.cpp', |
| 164 | dependencies: deps, |
| 165 | install: true |
| 166 | ) |
| 167 | |
| 168 | executable( |
| 169 | 'phosphor-image-updater', |
| 170 | image_error_cpp, |
| 171 | image_error_hpp, |
| 172 | image_updater_sources, |
| 173 | dependencies: [deps, ssl], |
| 174 | install: true |
| 175 | ) |
| 176 | |
| 177 | executable( |
| 178 | 'phosphor-version-software-manager', |
| 179 | image_error_cpp, |
| 180 | image_error_hpp, |
| 181 | 'image_manager.cpp', |
| 182 | 'image_manager_main.cpp', |
| 183 | 'version.cpp', |
| 184 | 'watch.cpp', |
| 185 | dependencies: [deps, ssl], |
| 186 | install: true |
| 187 | ) |
Adriana Kobylak | 817209f | 2020-05-07 09:52:03 -0500 | [diff] [blame] | 188 | |
| 189 | install_data('obmc-flash-bmc', |
| 190 | install_mode: 'rwxr-xr-x', |
| 191 | install_dir: get_option('bindir') |
| 192 | ) |
| 193 | |
| 194 | install_data('software.conf', |
| 195 | install_dir: '/usr/lib/tmpfiles.d/' |
| 196 | ) |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 197 | |
| 198 | foreach u : unit_files |
| 199 | configure_file( |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 200 | input: u, |
Adriana Kobylak | 436be81 | 2020-06-17 09:44:56 -0500 | [diff] [blame^] | 201 | output: '@BASENAME@', |
| 202 | configuration: conf, |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 203 | install: true, |
| 204 | install_dir: systemd_system_unit_dir, |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 205 | ) |
| 206 | endforeach |
Adriana Kobylak | 78e72d9 | 2020-05-05 14:01:54 -0500 | [diff] [blame] | 207 | |
| 208 | # If test coverage of source files within the root directory are wanted, |
| 209 | # need to define and build the tests from here |
| 210 | build_tests = get_option('tests') |
| 211 | if not build_tests.disabled() |
| 212 | oe_sdk = get_option('oe-sdk') |
| 213 | if oe_sdk.enabled() |
| 214 | # Setup OE SYSROOT |
| 215 | OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip() |
| 216 | if OECORE_TARGET_SYSROOT == '' |
| 217 | error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.') |
| 218 | endif |
| 219 | message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT) |
| 220 | rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib']) |
| 221 | ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip() |
| 222 | dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so] |
| 223 | else |
| 224 | dynamic_linker = [] |
| 225 | endif |
| 226 | |
| 227 | gtest = dependency('gtest', main: true, disabler: true, required: build_tests) |
| 228 | include_srcs = declare_dependency(sources: [ |
| 229 | 'image_verify.cpp', |
| 230 | 'version.cpp'] |
| 231 | ) |
| 232 | |
| 233 | test('utest', |
| 234 | executable( |
| 235 | 'utest', |
| 236 | './test/utest.cpp', |
| 237 | link_args: dynamic_linker, |
| 238 | build_rpath: get_option('oe-sdk').enabled() ? rpath : '', |
| 239 | dependencies: [deps, gtest, include_srcs, ssl] |
| 240 | ) |
| 241 | ) |
| 242 | endif |