blob: 7338236bed3ec414834f8279518d3169d0181bc8 [file] [log] [blame]
Adriana Kobylak0af80a42020-05-05 13:32:10 -05001project('phosphor-bmc-code-mgmt', 'cpp',
2 default_options: [
Gunnar Millsf7a69e12020-06-15 12:16:51 -05003 'buildtype=debugoptimized',
Patrick Williamsb9ecb2b2023-07-12 11:15:11 -05004 'cpp_std=c++23',
Adriana Kobylak0af80a42020-05-05 13:32:10 -05005 'warning_level=3',
Gunnar Millsf7a69e12020-06-15 12:16:51 -05006 'werror=true'
Adriana Kobylak0af80a42020-05-05 13:32:10 -05007 ],
Patrick Williamsb9ecb2b2023-07-12 11:15:11 -05008 meson_version: '>=1.1.1',
Adriana Kobylak0af80a42020-05-05 13:32:10 -05009 license: 'Apache-2.0',
10 version: '1.0')
11
Lei YU25868182021-05-14 14:50:51 +080012add_project_arguments(
13 '-DBOOST_SYSTEM_NO_DEPRECATED',
14 '-DBOOST_ERROR_CODE_HEADER_ONLY',
15 '-DBOOST_NO_RTTI',
16 '-DBOOST_NO_TYPEID',
17 '-DBOOST_ALL_NO_LIB',
18 '-DBOOST_ASIO_DISABLE_THREADS',
19 '-DBOOST_ASIO_NO_DEPRECATED',
20 language: 'cpp',
21)
22
Patrick Williams40267022021-08-26 16:48:42 -050023cpp = meson.get_compiler('cpp')
24
Adriana Kobylak0af80a42020-05-05 13:32:10 -050025conf = configuration_data()
26
27# DBus information
28conf.set_quoted('BMC_INVENTORY_INTERFACE', 'xyz.openbmc_project.Inventory.Item.Bmc')
29conf.set_quoted('BUSNAME_UPDATER', 'xyz.openbmc_project.Software.BMC.Updater')
30conf.set_quoted('DOWNLOAD_BUSNAME', 'xyz.openbmc_project.Software.Download')
31conf.set_quoted('FILEPATH_IFACE', 'xyz.openbmc_project.Common.FilePath')
32conf.set_quoted('INVENTORY_PATH', '/xyz/openbmc_project/inventory/')
33conf.set_quoted('MAPPER_BUSNAME', 'xyz.openbmc_project.ObjectMapper')
34conf.set_quoted('MAPPER_INTERFACE', 'xyz.openbmc_project.ObjectMapper')
35conf.set_quoted('MAPPER_PATH', '/xyz/openbmc_project/object_mapper')
36conf.set_quoted('SOFTWARE_OBJPATH', '/xyz/openbmc_project/software')
37conf.set_quoted('SYSTEMD_BUSNAME', 'org.freedesktop.systemd1')
38conf.set_quoted('SYSTEMD_PATH', '/org/freedesktop/systemd1')
39conf.set_quoted('SYSTEMD_INTERFACE', 'org.freedesktop.systemd1.Manager')
40conf.set_quoted('VERSION_BUSNAME', 'xyz.openbmc_project.Software.Version')
41conf.set_quoted('VERSION_IFACE', 'xyz.openbmc_project.Software.Version')
Chanh Nguyen1fd6ddd2021-01-06 11:09:09 +070042conf.set_quoted('EXTENDED_VERSION_IFACE', 'xyz.openbmc_project.Software.ExtendedVersion')
Justin Ledford054bb0b2022-03-15 15:46:58 -070043conf.set_quoted('COMPATIBLE_IFACE', 'xyz.openbmc_project.Inventory.Decorator.Compatible')
Adriana Kobylak0af80a42020-05-05 13:32:10 -050044
45# Names of the forward and reverse associations
46conf.set_quoted('ACTIVATION_FWD_ASSOCIATION', 'inventory')
47conf.set_quoted('ACTIVATION_REV_ASSOCIATION', 'activation')
48conf.set_quoted('ACTIVE_FWD_ASSOCIATION', 'active')
49conf.set_quoted('ACTIVE_REV_ASSOCIATION', 'software_version')
50conf.set_quoted('FUNCTIONAL_FWD_ASSOCIATION', 'functional')
51conf.set_quoted('FUNCTIONAL_REV_ASSOCIATION', 'software_version')
52conf.set_quoted('UPDATEABLE_FWD_ASSOCIATION', 'updateable')
53conf.set_quoted('UPDATEABLE_REV_ASSOCIATION', 'software_version')
54
55# Filesystem files and directories
Adriana Kobylak0af80a42020-05-05 13:32:10 -050056# The prefix path for the versioned read-only bmc partitions
57conf.set_quoted('BMC_ROFS_PREFIX', get_option('media-dir') + '/rofs-')
58# The name of the BMC table of contents file
59conf.set_quoted('OS_RELEASE_FILE', '/etc/os-release')
60# The dir where activation data is stored in files
61conf.set_quoted('PERSIST_DIR', '/var/lib/phosphor-bmc-code-mgmt/')
62
63# Supported BMC layout types
64conf.set('STATIC_LAYOUT', get_option('bmc-layout').contains('static'))
65conf.set('UBIFS_LAYOUT', get_option('bmc-layout').contains('ubi'))
Adriana Kobylak70f5bc02020-05-13 14:08:14 -050066conf.set('MMC_LAYOUT', get_option('bmc-layout').contains('mmc'))
Adriana Kobylak0af80a42020-05-05 13:32:10 -050067
68# Configurable features
69conf.set('HOST_BIOS_UPGRADE', get_option('host-bios-upgrade').enabled())
Adriana Kobylak42bd9932021-01-28 09:45:24 -060070conf.set('WANT_SIGNATURE_VERIFY', \
71 get_option('verify-signature').enabled() or \
72 get_option('verify-full-signature').enabled())
George Liu0a06e972020-12-17 09:17:04 +080073conf.set('WANT_SIGNATURE_FULL_VERIFY', get_option('verify-full-signature').enabled())
Adriana Kobylak0af80a42020-05-05 13:32:10 -050074
75# Configurable variables
76conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed'))
77conf.set_quoted('HASH_FILE_NAME', get_option('hash-file-name'))
78conf.set_quoted('IMG_UPLOAD_DIR', get_option('img-upload-dir'))
79conf.set_quoted('MANIFEST_FILE_NAME', get_option('manifest-file-name'))
80conf.set_quoted('MEDIA_DIR', get_option('media-dir'))
Adriana Kobylak73609bb2020-06-18 15:05:40 -050081optional_array = get_option('optional-images')
82optional_images = ''
83foreach optiona_image : optional_array
84 optional_images = ' '.join([optional_images, optiona_image])
85endforeach
86conf.set_quoted('OPTIONAL_IMAGES', optional_images)
Adriana Kobylak0af80a42020-05-05 13:32:10 -050087conf.set_quoted('PUBLICKEY_FILE_NAME', get_option('publickey-file-name'))
88conf.set_quoted('SIGNATURE_FILE_EXT', get_option('signature-file-ext'))
89conf.set_quoted('SIGNED_IMAGE_CONF_PATH', get_option('signed-image-conf-path'))
90conf.set_quoted('SYNC_LIST_DIR_PATH', get_option('sync-list-dir-path'))
91conf.set_quoted('SYNC_LIST_FILE_NAME', get_option('sync-list-file-name'))
Miguel Gomez21dad042020-06-26 20:54:48 +000092conf.set_quoted('BMC_MSL', get_option('bmc-msl'))
93conf.set_quoted('REGEX_BMC_MSL', get_option('regex-bmc-msl'))
94
Lei YU6e9fb1d2021-02-19 18:01:40 +080095if get_option('host-bios-upgrade').enabled()
96 conf.set_quoted('BIOS_OBJPATH', get_option('bios-object-path'))
97endif
Adriana Kobylak0af80a42020-05-05 13:32:10 -050098
Lei YU63769642021-12-10 16:15:04 +080099if get_option('bmc-static-dual-image').enabled()
100 conf.set('BMC_STATIC_DUAL_IMAGE', get_option('bmc-static-dual-image').enabled())
101 conf.set_quoted('ALT_ROFS_DIR', get_option('alt-rofs-dir'))
Lei YUcc9b41a2021-12-15 14:07:16 +0800102 conf.set_quoted('ALT_RWFS', get_option('alt-rwfs-dir'))
103else
104 conf.set_quoted('ALT_RWFS', '/media/alt/var/persist')
Lei YU63769642021-12-10 16:15:04 +0800105endif
106
Adriana Kobylak0af80a42020-05-05 13:32:10 -0500107configure_file(output: 'config.h', configuration: conf)
Adriana Kobylak113492e2020-05-05 13:45:45 -0500108
Patrick Williamsc026f6c2022-03-21 09:37:14 -0500109sdbusplus_dep = dependency('sdbusplus')
110sdbusplusplus_prog = find_program('sdbus++', native: true)
111sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true)
Patrick Williams40267022021-08-26 16:48:42 -0500112
Patrick Williamsc026f6c2022-03-21 09:37:14 -0500113pdi_dep = dependency('phosphor-dbus-interfaces')
114phosphor_logging_dep = dependency('phosphor-logging')
Patrick Williams40267022021-08-26 16:48:42 -0500115
116cereal_dep = dependency('cereal', required: false)
117has_cereal = cpp.has_header_symbol(
118 'cereal/cereal.hpp',
119 'cereal::specialize',
120 dependencies: cereal_dep,
121 required: false)
122if not has_cereal
123 cereal_opts = import('cmake').subproject_options()
124 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
125 cereal_proj = import('cmake').subproject(
126 'cereal',
127 options: cereal_opts,
128 required: false)
129 assert(cereal_proj.found(), 'cereal is required')
130 cereal_dep = cereal_proj.dependency('cereal')
131endif
132
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500133deps = [
Patrick Williams40267022021-08-26 16:48:42 -0500134 cereal_dep,
Patrick Williamsc026f6c2022-03-21 09:37:14 -0500135 pdi_dep,
136 phosphor_logging_dep,
137 sdbusplus_dep,
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500138]
139
140ssl = dependency('openssl')
141
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500142systemd = dependency('systemd')
Patrick Williamse80b5bc2023-04-12 08:01:05 -0500143systemd_system_unit_dir = systemd.get_variable('systemdsystemunitdir')
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500144
145unit_files = [
Adriana Kobylak436be812020-06-17 09:44:56 -0500146 'obmc-flash-bmc-setenv@.service.in',
147 'reboot-guard-disable.service.in',
148 'reboot-guard-enable.service.in',
149 'force-reboot.service.in',
150 'usr-local.mount.in',
151 'xyz.openbmc_project.Software.BMC.Updater.service.in',
152 'xyz.openbmc_project.Software.Download.service.in',
153 'xyz.openbmc_project.Software.Sync.service.in',
154 'xyz.openbmc_project.Software.Version.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500155]
156
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500157image_updater_sources = files(
158 'activation.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500159 'images.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500160 'item_updater.cpp',
161 'item_updater_main.cpp',
162 'serialize.cpp',
163 'version.cpp',
Miguel Gomez21dad042020-06-26 20:54:48 +0000164 'utils.cpp',
165 'msl_verify.cpp'
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500166)
167
168if get_option('bmc-layout').contains('static')
Adriana Kobylak436be812020-06-17 09:44:56 -0500169 image_updater_sources += files(
170 'static/flash.cpp',
171 'static/item_updater_helper.cpp'
172 )
Adriana Kobylak86013f32020-05-13 12:12:38 -0500173elif get_option('bmc-layout').contains('ubi')
Adriana Kobylak436be812020-06-17 09:44:56 -0500174 image_updater_sources += files(
175 'ubi/flash.cpp',
176 'ubi/item_updater_helper.cpp'
177 )
178
179 unit_files += [
180 'ubi/obmc-flash-bmc-cleanup.service.in',
181 'ubi/obmc-flash-bmc-mirroruboot.service.in',
182 'ubi/obmc-flash-bmc-ubiremount.service.in',
183 'ubi/obmc-flash-bmc-ubiro@.service.in',
184 'ubi/obmc-flash-bmc-ubiro-remove@.service.in',
185 'ubi/obmc-flash-bmc-ubirw.service.in',
186 'ubi/obmc-flash-bmc-ubirw-remove.service.in',
187 'ubi/obmc-flash-bmc-updateubootvars@.service.in'
188 ]
Adriana Kobylak86013f32020-05-13 12:12:38 -0500189elif get_option('bmc-layout').contains('mmc')
Adriana Kobylak436be812020-06-17 09:44:56 -0500190 image_updater_sources += files(
191 'mmc/flash.cpp',
192 'mmc/item_updater_helper.cpp'
193 )
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500194
195 unit_files += [
196 'mmc/obmc-flash-mmc@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500197 'mmc/obmc-flash-mmc-mount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500198 'mmc/obmc-flash-mmc-remove@.service.in',
Adriana Kobylak34124352020-05-22 09:40:40 -0500199 'mmc/obmc-flash-mmc-setprimary@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500200 'mmc/obmc-flash-mmc-umount.service.in',
Lakshmi Yadlapati87c5b5b2022-11-15 18:14:12 -0600201 'mmc/obmc-flash-mmc-mirroruboot.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500202 ]
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500203endif
204
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500205if get_option('host-bios-upgrade').enabled()
Adriana Kobylak436be812020-06-17 09:44:56 -0500206 unit_files += 'obmc-flash-host-bios@.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500207endif
208
Lei YU63769642021-12-10 16:15:04 +0800209if get_option('bmc-static-dual-image').enabled()
Lei YU84749672021-12-15 14:31:10 +0800210 unit_files += [
Lei YU554757b2022-03-21 11:05:50 +0800211 'static/obmc-flash-bmc-alt@.service.in',
Lei YU84749672021-12-15 14:31:10 +0800212 'static/obmc-flash-bmc-static-mount-alt.service.in',
213 'static/obmc-flash-bmc-prepare-for-sync.service.in',
214 ]
Lei YU63769642021-12-10 16:15:04 +0800215endif
216
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500217if get_option('sync-bmc-files').enabled()
218 executable(
219 'phosphor-sync-software-manager',
220 'sync_manager.cpp',
221 'sync_manager_main.cpp',
222 'sync_watch.cpp',
223 dependencies: deps,
224 install: true
225 )
Adriana Kobylak817209f2020-05-07 09:52:03 -0500226
227 install_data('synclist',
228 install_dir: get_option('sysconfdir')
229 )
Lei YU84749672021-12-15 14:31:10 +0800230
231 install_data('sync-once.sh',
232 install_mode: 'rwxr-xr-x',
233 install_dir: get_option('bindir')
234 )
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500235endif
236
Adriana Kobylak42bd9932021-01-28 09:45:24 -0600237if (get_option('verify-signature').enabled() or \
238 get_option('verify-full-signature').enabled())
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500239 image_updater_sources += files(
George Liu0a06e972020-12-17 09:17:04 +0800240 'utils.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500241 'image_verify.cpp',
242 'openssl_alloc.cpp'
243 )
244endif
245
246executable(
247 'phosphor-download-manager',
248 'download_manager.cpp',
249 'download_manager_main.cpp',
250 dependencies: deps,
251 install: true
252)
253
254executable(
255 'phosphor-image-updater',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500256 image_updater_sources,
257 dependencies: [deps, ssl],
258 install: true
259)
260
261executable(
262 'phosphor-version-software-manager',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500263 'image_manager.cpp',
264 'image_manager_main.cpp',
265 'version.cpp',
266 'watch.cpp',
267 dependencies: [deps, ssl],
268 install: true
269)
Adriana Kobylak817209f2020-05-07 09:52:03 -0500270
271install_data('obmc-flash-bmc',
272 install_mode: 'rwxr-xr-x',
273 install_dir: get_option('bindir')
274)
275
Lei YU531fbc22021-12-10 20:03:18 +0800276install_data('detect-slot-aspeed',
277 install_mode: 'rwxr-xr-x',
278 install_dir: get_option('bindir')
279)
280
Lei YU984cef52021-12-17 11:28:21 +0800281install_data('reset-cs0-aspeed',
282 install_mode: 'rwxr-xr-x',
283 install_dir: get_option('bindir')
284)
285
Adriana Kobylak817209f2020-05-07 09:52:03 -0500286install_data('software.conf',
287 install_dir: '/usr/lib/tmpfiles.d/'
288)
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500289
290foreach u : unit_files
291 configure_file(
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500292 input: u,
Adriana Kobylak436be812020-06-17 09:44:56 -0500293 output: '@BASENAME@',
294 configuration: conf,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500295 install: true,
296 install_dir: systemd_system_unit_dir,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500297 )
298endforeach
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500299
300# If test coverage of source files within the root directory are wanted,
301# need to define and build the tests from here
302build_tests = get_option('tests')
303if not build_tests.disabled()
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500304 gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
305 include_srcs = declare_dependency(sources: [
George Liu0a06e972020-12-17 09:17:04 +0800306 'utils.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500307 'image_verify.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500308 'images.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500309 'version.cpp']
310 )
311
312 test('utest',
313 executable(
314 'utest',
315 './test/utest.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500316 dependencies: [deps, gtest, include_srcs, ssl]
317 )
318)
319endif
George Liucc742332021-10-20 16:25:55 +0800320
321if get_option('usb-code-update').enabled()
322 subdir('usb')
323endif
Andrew Geissler70d72f82022-03-23 13:15:05 -0500324
325if get_option('side-switch-on-boot').enabled()
326 subdir('side-switch')
327endif