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 = [ |
| 83 | 'obmc-flash-bmc-setenv@.service', |
| 84 | 'reboot-guard-disable.service', |
| 85 | 'reboot-guard-enable.service', |
| 86 | 'force-reboot.service', |
| 87 | 'usr-local.mount', |
| 88 | 'xyz.openbmc_project.Software.BMC.Updater.service', |
| 89 | 'xyz.openbmc_project.Software.Download.service', |
| 90 | 'xyz.openbmc_project.Software.Sync.service', |
| 91 | 'xyz.openbmc_project.Software.Version.service' |
| 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') |
| 107 | subdir('static') |
Adriana Kobylak | 86013f3 | 2020-05-13 12:12:38 -0500 | [diff] [blame] | 108 | elif get_option('bmc-layout').contains('ubi') |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 109 | subdir('ubi') |
Adriana Kobylak | 86013f3 | 2020-05-13 12:12:38 -0500 | [diff] [blame] | 110 | elif get_option('bmc-layout').contains('mmc') |
| 111 | subdir('mmc') |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 112 | endif |
| 113 | |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 114 | if get_option('host-bios-upgrade').enabled() |
| 115 | unit_files += 'obmc-flash-host-bios@.service' |
| 116 | endif |
| 117 | |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 118 | if get_option('sync-bmc-files').enabled() |
| 119 | executable( |
| 120 | 'phosphor-sync-software-manager', |
| 121 | 'sync_manager.cpp', |
| 122 | 'sync_manager_main.cpp', |
| 123 | 'sync_watch.cpp', |
| 124 | dependencies: deps, |
| 125 | install: true |
| 126 | ) |
Adriana Kobylak | 817209f | 2020-05-07 09:52:03 -0500 | [diff] [blame] | 127 | |
| 128 | install_data('synclist', |
| 129 | install_dir: get_option('sysconfdir') |
| 130 | ) |
Adriana Kobylak | e0aa780 | 2020-05-05 13:54:49 -0500 | [diff] [blame] | 131 | endif |
| 132 | |
| 133 | if get_option('verify-signature').enabled() |
| 134 | image_updater_sources += files( |
| 135 | 'image_verify.cpp', |
| 136 | 'openssl_alloc.cpp' |
| 137 | ) |
| 138 | endif |
| 139 | |
| 140 | executable( |
| 141 | 'phosphor-download-manager', |
| 142 | 'download_manager.cpp', |
| 143 | 'download_manager_main.cpp', |
| 144 | dependencies: deps, |
| 145 | install: true |
| 146 | ) |
| 147 | |
| 148 | executable( |
| 149 | 'phosphor-image-updater', |
| 150 | image_error_cpp, |
| 151 | image_error_hpp, |
| 152 | image_updater_sources, |
| 153 | dependencies: [deps, ssl], |
| 154 | install: true |
| 155 | ) |
| 156 | |
| 157 | executable( |
| 158 | 'phosphor-version-software-manager', |
| 159 | image_error_cpp, |
| 160 | image_error_hpp, |
| 161 | 'image_manager.cpp', |
| 162 | 'image_manager_main.cpp', |
| 163 | 'version.cpp', |
| 164 | 'watch.cpp', |
| 165 | dependencies: [deps, ssl], |
| 166 | install: true |
| 167 | ) |
Adriana Kobylak | 817209f | 2020-05-07 09:52:03 -0500 | [diff] [blame] | 168 | |
| 169 | install_data('obmc-flash-bmc', |
| 170 | install_mode: 'rwxr-xr-x', |
| 171 | install_dir: get_option('bindir') |
| 172 | ) |
| 173 | |
| 174 | install_data('software.conf', |
| 175 | install_dir: '/usr/lib/tmpfiles.d/' |
| 176 | ) |
Adriana Kobylak | 29a0d90 | 2020-05-05 13:59:49 -0500 | [diff] [blame] | 177 | |
| 178 | foreach u : unit_files |
| 179 | configure_file( |
| 180 | copy: true, |
| 181 | input: u, |
| 182 | install: true, |
| 183 | install_dir: systemd_system_unit_dir, |
| 184 | output: u, |
| 185 | ) |
| 186 | endforeach |
Adriana Kobylak | 78e72d9 | 2020-05-05 14:01:54 -0500 | [diff] [blame] | 187 | |
| 188 | # If test coverage of source files within the root directory are wanted, |
| 189 | # need to define and build the tests from here |
| 190 | build_tests = get_option('tests') |
| 191 | if not build_tests.disabled() |
| 192 | oe_sdk = get_option('oe-sdk') |
| 193 | if oe_sdk.enabled() |
| 194 | # Setup OE SYSROOT |
| 195 | OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip() |
| 196 | if OECORE_TARGET_SYSROOT == '' |
| 197 | error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.') |
| 198 | endif |
| 199 | message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT) |
| 200 | rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib']) |
| 201 | ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip() |
| 202 | dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so] |
| 203 | else |
| 204 | dynamic_linker = [] |
| 205 | endif |
| 206 | |
| 207 | gtest = dependency('gtest', main: true, disabler: true, required: build_tests) |
| 208 | include_srcs = declare_dependency(sources: [ |
| 209 | 'image_verify.cpp', |
| 210 | 'version.cpp'] |
| 211 | ) |
| 212 | |
| 213 | test('utest', |
| 214 | executable( |
| 215 | 'utest', |
| 216 | './test/utest.cpp', |
| 217 | link_args: dynamic_linker, |
| 218 | build_rpath: get_option('oe-sdk').enabled() ? rpath : '', |
| 219 | dependencies: [deps, gtest, include_srcs, ssl] |
| 220 | ) |
| 221 | ) |
| 222 | endif |