blob: e4808d0061b5c706417cf118f65263408153d22c [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
Patrick Williams83d7d402023-11-29 06:43:55 -060069conf.set('HOST_BIOS_UPGRADE', get_option('host-bios-upgrade').allowed())
70conf.set('WANT_SIGNATURE_VERIFY', get_option('verify-signature').allowed())
Adriana Kobylak0af80a42020-05-05 13:32:10 -050071
72# Configurable variables
73conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed'))
74conf.set_quoted('HASH_FILE_NAME', get_option('hash-file-name'))
75conf.set_quoted('IMG_UPLOAD_DIR', get_option('img-upload-dir'))
76conf.set_quoted('MANIFEST_FILE_NAME', get_option('manifest-file-name'))
77conf.set_quoted('MEDIA_DIR', get_option('media-dir'))
Adriana Kobylak73609bb2020-06-18 15:05:40 -050078optional_array = get_option('optional-images')
79optional_images = ''
80foreach optiona_image : optional_array
81 optional_images = ' '.join([optional_images, optiona_image])
82endforeach
83conf.set_quoted('OPTIONAL_IMAGES', optional_images)
Adriana Kobylak0af80a42020-05-05 13:32:10 -050084conf.set_quoted('PUBLICKEY_FILE_NAME', get_option('publickey-file-name'))
85conf.set_quoted('SIGNATURE_FILE_EXT', get_option('signature-file-ext'))
86conf.set_quoted('SIGNED_IMAGE_CONF_PATH', get_option('signed-image-conf-path'))
87conf.set_quoted('SYNC_LIST_DIR_PATH', get_option('sync-list-dir-path'))
88conf.set_quoted('SYNC_LIST_FILE_NAME', get_option('sync-list-file-name'))
Miguel Gomez21dad042020-06-26 20:54:48 +000089conf.set_quoted('BMC_MSL', get_option('bmc-msl'))
90conf.set_quoted('REGEX_BMC_MSL', get_option('regex-bmc-msl'))
91
Patrick Williams83d7d402023-11-29 06:43:55 -060092if get_option('host-bios-upgrade').allowed()
Lei YU6e9fb1d2021-02-19 18:01:40 +080093 conf.set_quoted('BIOS_OBJPATH', get_option('bios-object-path'))
94endif
Adriana Kobylak0af80a42020-05-05 13:32:10 -050095
Patrick Williams83d7d402023-11-29 06:43:55 -060096if get_option('bmc-static-dual-image').allowed()
97 conf.set('BMC_STATIC_DUAL_IMAGE', get_option('bmc-static-dual-image').allowed())
Lei YU63769642021-12-10 16:15:04 +080098 conf.set_quoted('ALT_ROFS_DIR', get_option('alt-rofs-dir'))
Lei YUcc9b41a2021-12-15 14:07:16 +080099 conf.set_quoted('ALT_RWFS', get_option('alt-rwfs-dir'))
100else
101 conf.set_quoted('ALT_RWFS', '/media/alt/var/persist')
Lei YU63769642021-12-10 16:15:04 +0800102endif
103
Adriana Kobylak0af80a42020-05-05 13:32:10 -0500104configure_file(output: 'config.h', configuration: conf)
Adriana Kobylak113492e2020-05-05 13:45:45 -0500105
Konstantin Aladyshevfa34e222024-04-02 17:12:40 +0300106boost_dep = dependency('boost')
107
Patrick Williamsc026f6c2022-03-21 09:37:14 -0500108sdbusplus_dep = dependency('sdbusplus')
109sdbusplusplus_prog = find_program('sdbus++', native: true)
110sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true)
Patrick Williams40267022021-08-26 16:48:42 -0500111
Patrick Williamsc026f6c2022-03-21 09:37:14 -0500112pdi_dep = dependency('phosphor-dbus-interfaces')
113phosphor_logging_dep = dependency('phosphor-logging')
Patrick Williams40267022021-08-26 16:48:42 -0500114
115cereal_dep = dependency('cereal', required: false)
116has_cereal = cpp.has_header_symbol(
117 'cereal/cereal.hpp',
118 'cereal::specialize',
119 dependencies: cereal_dep,
120 required: false)
121if not has_cereal
122 cereal_opts = import('cmake').subproject_options()
Konstantin Aladyshevd2d57bb2024-04-02 17:05:10 +0300123 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'})
Patrick Williams40267022021-08-26 16:48:42 -0500124 cereal_proj = import('cmake').subproject(
125 'cereal',
126 options: cereal_opts,
127 required: false)
128 assert(cereal_proj.found(), 'cereal is required')
129 cereal_dep = cereal_proj.dependency('cereal')
130endif
131
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500132deps = [
Patrick Williams40267022021-08-26 16:48:42 -0500133 cereal_dep,
Patrick Williamsc026f6c2022-03-21 09:37:14 -0500134 pdi_dep,
135 phosphor_logging_dep,
136 sdbusplus_dep,
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500137]
138
139ssl = dependency('openssl')
140
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500141systemd = dependency('systemd')
Patrick Williamse80b5bc2023-04-12 08:01:05 -0500142systemd_system_unit_dir = systemd.get_variable('systemdsystemunitdir')
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500143
144unit_files = [
Adriana Kobylak436be812020-06-17 09:44:56 -0500145 'obmc-flash-bmc-setenv@.service.in',
146 'reboot-guard-disable.service.in',
147 'reboot-guard-enable.service.in',
148 'force-reboot.service.in',
149 'usr-local.mount.in',
150 'xyz.openbmc_project.Software.BMC.Updater.service.in',
151 'xyz.openbmc_project.Software.Download.service.in',
152 'xyz.openbmc_project.Software.Sync.service.in',
153 'xyz.openbmc_project.Software.Version.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500154]
155
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500156image_updater_sources = files(
157 'activation.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500158 'images.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500159 'item_updater.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500160 'serialize.cpp',
161 'version.cpp',
Miguel Gomez21dad042020-06-26 20:54:48 +0000162 'utils.cpp',
163 'msl_verify.cpp'
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500164)
165
166if get_option('bmc-layout').contains('static')
Adriana Kobylak436be812020-06-17 09:44:56 -0500167 image_updater_sources += files(
168 'static/flash.cpp',
169 'static/item_updater_helper.cpp'
170 )
Adriana Kobylak86013f32020-05-13 12:12:38 -0500171elif get_option('bmc-layout').contains('ubi')
Adriana Kobylak436be812020-06-17 09:44:56 -0500172 image_updater_sources += files(
173 'ubi/flash.cpp',
174 'ubi/item_updater_helper.cpp'
175 )
176
177 unit_files += [
178 'ubi/obmc-flash-bmc-cleanup.service.in',
179 'ubi/obmc-flash-bmc-mirroruboot.service.in',
180 'ubi/obmc-flash-bmc-ubiremount.service.in',
181 'ubi/obmc-flash-bmc-ubiro@.service.in',
182 'ubi/obmc-flash-bmc-ubiro-remove@.service.in',
183 'ubi/obmc-flash-bmc-ubirw.service.in',
184 'ubi/obmc-flash-bmc-ubirw-remove.service.in',
185 'ubi/obmc-flash-bmc-updateubootvars@.service.in'
186 ]
Adriana Kobylak86013f32020-05-13 12:12:38 -0500187elif get_option('bmc-layout').contains('mmc')
Adriana Kobylak436be812020-06-17 09:44:56 -0500188 image_updater_sources += files(
189 'mmc/flash.cpp',
190 'mmc/item_updater_helper.cpp'
191 )
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500192
193 unit_files += [
194 'mmc/obmc-flash-mmc@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500195 'mmc/obmc-flash-mmc-mount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500196 'mmc/obmc-flash-mmc-remove@.service.in',
Adriana Kobylak34124352020-05-22 09:40:40 -0500197 'mmc/obmc-flash-mmc-setprimary@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500198 'mmc/obmc-flash-mmc-umount.service.in',
Lakshmi Yadlapati87c5b5b2022-11-15 18:14:12 -0600199 'mmc/obmc-flash-mmc-mirroruboot.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500200 ]
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500201endif
202
Patrick Williams83d7d402023-11-29 06:43:55 -0600203if get_option('host-bios-upgrade').allowed()
Adriana Kobylak436be812020-06-17 09:44:56 -0500204 unit_files += 'obmc-flash-host-bios@.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500205endif
206
Patrick Williams83d7d402023-11-29 06:43:55 -0600207if get_option('bmc-static-dual-image').allowed()
Lei YU84749672021-12-15 14:31:10 +0800208 unit_files += [
Lei YU554757b2022-03-21 11:05:50 +0800209 'static/obmc-flash-bmc-alt@.service.in',
Lei YU84749672021-12-15 14:31:10 +0800210 'static/obmc-flash-bmc-static-mount-alt.service.in',
211 'static/obmc-flash-bmc-prepare-for-sync.service.in',
212 ]
Lei YU63769642021-12-10 16:15:04 +0800213endif
214
Patrick Williams83d7d402023-11-29 06:43:55 -0600215if get_option('sync-bmc-files').allowed()
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500216 executable(
217 'phosphor-sync-software-manager',
218 'sync_manager.cpp',
219 'sync_manager_main.cpp',
220 'sync_watch.cpp',
221 dependencies: deps,
222 install: true
223 )
Adriana Kobylak817209f2020-05-07 09:52:03 -0500224
225 install_data('synclist',
226 install_dir: get_option('sysconfdir')
227 )
Lei YU84749672021-12-15 14:31:10 +0800228
229 install_data('sync-once.sh',
230 install_mode: 'rwxr-xr-x',
231 install_dir: get_option('bindir')
232 )
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500233endif
234
Patrick Williams83d7d402023-11-29 06:43:55 -0600235if (get_option('verify-signature').allowed())
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500236 image_updater_sources += files(
George Liu0a06e972020-12-17 09:17:04 +0800237 'utils.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500238 'image_verify.cpp',
239 'openssl_alloc.cpp'
240 )
241endif
242
243executable(
244 'phosphor-download-manager',
245 'download_manager.cpp',
246 'download_manager_main.cpp',
247 dependencies: deps,
248 install: true
249)
250
Jagpal Singh Gill2431e7f2024-04-07 23:51:12 -0700251software_common_sources = files(
Jagpal Singh Gill6d131aa2024-04-07 23:56:48 -0700252 'software_utils.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500253)
254
Jagpal Singh Gillcc498782024-02-29 15:16:36 -0800255if get_option('software-update-dbus-interface').allowed()
Jagpal Singh Gill6d131aa2024-04-07 23:56:48 -0700256 image_updater_sources += files(
257 'update_manager.cpp'
258 )
259
Jagpal Singh Gillcc498782024-02-29 15:16:36 -0800260 executable(
261 'phosphor-software-manager',
262 'software_manager.cpp',
Jagpal Singh Gill2431e7f2024-04-07 23:51:12 -0700263 image_updater_sources,
264 software_common_sources,
Jagpal Singh Gillcc498782024-02-29 15:16:36 -0800265 dependencies: [deps, ssl],
266 install: true
267 )
268 unit_files += [
269 'xyz.openbmc_project.Software.Manager.service.in'
270 ]
271endif
272
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500273executable(
Jagpal Singh Gill6d131aa2024-04-07 23:56:48 -0700274 'phosphor-image-updater',
275 image_updater_sources,
276 software_common_sources,
277 'item_updater_main.cpp',
278 dependencies: [deps, ssl, boost_dep],
279 install: true
280)
281
282executable(
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500283 'phosphor-version-software-manager',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500284 'image_manager.cpp',
285 'image_manager_main.cpp',
286 'version.cpp',
287 'watch.cpp',
Jagpal Singh Gill2431e7f2024-04-07 23:51:12 -0700288 software_common_sources,
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500289 dependencies: [deps, ssl],
290 install: true
291)
Adriana Kobylak817209f2020-05-07 09:52:03 -0500292
293install_data('obmc-flash-bmc',
294 install_mode: 'rwxr-xr-x',
295 install_dir: get_option('bindir')
296)
297
Lei YU531fbc22021-12-10 20:03:18 +0800298install_data('detect-slot-aspeed',
299 install_mode: 'rwxr-xr-x',
300 install_dir: get_option('bindir')
301)
302
Lei YU984cef52021-12-17 11:28:21 +0800303install_data('reset-cs0-aspeed',
304 install_mode: 'rwxr-xr-x',
305 install_dir: get_option('bindir')
306)
307
Adriana Kobylak817209f2020-05-07 09:52:03 -0500308install_data('software.conf',
309 install_dir: '/usr/lib/tmpfiles.d/'
310)
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500311
312foreach u : unit_files
313 configure_file(
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500314 input: u,
Adriana Kobylak436be812020-06-17 09:44:56 -0500315 output: '@BASENAME@',
316 configuration: conf,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500317 install: true,
318 install_dir: systemd_system_unit_dir,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500319 )
320endforeach
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500321
322# If test coverage of source files within the root directory are wanted,
323# need to define and build the tests from here
324build_tests = get_option('tests')
325if not build_tests.disabled()
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500326 gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
327 include_srcs = declare_dependency(sources: [
George Liu0a06e972020-12-17 09:17:04 +0800328 'utils.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500329 'image_verify.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500330 'images.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500331 'version.cpp']
332 )
333
334 test('utest',
335 executable(
336 'utest',
337 './test/utest.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500338 dependencies: [deps, gtest, include_srcs, ssl]
339 )
340)
341endif
George Liucc742332021-10-20 16:25:55 +0800342
Patrick Williams83d7d402023-11-29 06:43:55 -0600343if get_option('usb-code-update').allowed()
George Liucc742332021-10-20 16:25:55 +0800344 subdir('usb')
345endif
Andrew Geissler70d72f82022-03-23 13:15:05 -0500346
Patrick Williams83d7d402023-11-29 06:43:55 -0600347if get_option('side-switch-on-boot').allowed()
Andrew Geissler70d72f82022-03-23 13:15:05 -0500348 subdir('side-switch')
349endif