blob: 201f0b95255521dc4070009d093a00384bdd4b08 [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 Williams40267022021-08-26 16:48:42 -05004 'cpp_std=c++20',
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 Williams40267022021-08-26 16:48:42 -05008 meson_version: '>= 0.57.0',
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')
Adriana Kobylak0af80a42020-05-05 13:32:10 -050043
44# Names of the forward and reverse associations
45conf.set_quoted('ACTIVATION_FWD_ASSOCIATION', 'inventory')
46conf.set_quoted('ACTIVATION_REV_ASSOCIATION', 'activation')
47conf.set_quoted('ACTIVE_FWD_ASSOCIATION', 'active')
48conf.set_quoted('ACTIVE_REV_ASSOCIATION', 'software_version')
49conf.set_quoted('FUNCTIONAL_FWD_ASSOCIATION', 'functional')
50conf.set_quoted('FUNCTIONAL_REV_ASSOCIATION', 'software_version')
51conf.set_quoted('UPDATEABLE_FWD_ASSOCIATION', 'updateable')
52conf.set_quoted('UPDATEABLE_REV_ASSOCIATION', 'software_version')
53
54# Filesystem files and directories
Adriana Kobylak0af80a42020-05-05 13:32:10 -050055# The prefix path for the versioned read-only bmc partitions
56conf.set_quoted('BMC_ROFS_PREFIX', get_option('media-dir') + '/rofs-')
57# The name of the BMC table of contents file
58conf.set_quoted('OS_RELEASE_FILE', '/etc/os-release')
59# The dir where activation data is stored in files
60conf.set_quoted('PERSIST_DIR', '/var/lib/phosphor-bmc-code-mgmt/')
61
62# Supported BMC layout types
63conf.set('STATIC_LAYOUT', get_option('bmc-layout').contains('static'))
64conf.set('UBIFS_LAYOUT', get_option('bmc-layout').contains('ubi'))
Adriana Kobylak70f5bc02020-05-13 14:08:14 -050065conf.set('MMC_LAYOUT', get_option('bmc-layout').contains('mmc'))
Adriana Kobylak0af80a42020-05-05 13:32:10 -050066
67# Configurable features
68conf.set('HOST_BIOS_UPGRADE', get_option('host-bios-upgrade').enabled())
Adriana Kobylak42bd9932021-01-28 09:45:24 -060069conf.set('WANT_SIGNATURE_VERIFY', \
70 get_option('verify-signature').enabled() or \
71 get_option('verify-full-signature').enabled())
George Liu0a06e972020-12-17 09:17:04 +080072conf.set('WANT_SIGNATURE_FULL_VERIFY', get_option('verify-full-signature').enabled())
Adriana Kobylak0af80a42020-05-05 13:32:10 -050073
74# Configurable variables
75conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed'))
76conf.set_quoted('HASH_FILE_NAME', get_option('hash-file-name'))
77conf.set_quoted('IMG_UPLOAD_DIR', get_option('img-upload-dir'))
78conf.set_quoted('MANIFEST_FILE_NAME', get_option('manifest-file-name'))
79conf.set_quoted('MEDIA_DIR', get_option('media-dir'))
Adriana Kobylak73609bb2020-06-18 15:05:40 -050080optional_array = get_option('optional-images')
81optional_images = ''
82foreach optiona_image : optional_array
83 optional_images = ' '.join([optional_images, optiona_image])
84endforeach
85conf.set_quoted('OPTIONAL_IMAGES', optional_images)
Adriana Kobylak0af80a42020-05-05 13:32:10 -050086conf.set_quoted('PUBLICKEY_FILE_NAME', get_option('publickey-file-name'))
87conf.set_quoted('SIGNATURE_FILE_EXT', get_option('signature-file-ext'))
88conf.set_quoted('SIGNED_IMAGE_CONF_PATH', get_option('signed-image-conf-path'))
89conf.set_quoted('SYNC_LIST_DIR_PATH', get_option('sync-list-dir-path'))
90conf.set_quoted('SYNC_LIST_FILE_NAME', get_option('sync-list-file-name'))
Miguel Gomez21dad042020-06-26 20:54:48 +000091conf.set_quoted('BMC_MSL', get_option('bmc-msl'))
92conf.set_quoted('REGEX_BMC_MSL', get_option('regex-bmc-msl'))
93
Lei YU6e9fb1d2021-02-19 18:01:40 +080094if get_option('host-bios-upgrade').enabled()
95 conf.set_quoted('BIOS_OBJPATH', get_option('bios-object-path'))
96endif
Adriana Kobylak0af80a42020-05-05 13:32:10 -050097
Lei YU63769642021-12-10 16:15:04 +080098if get_option('bmc-static-dual-image').enabled()
99 conf.set('BMC_STATIC_DUAL_IMAGE', get_option('bmc-static-dual-image').enabled())
100 conf.set_quoted('ALT_ROFS_DIR', get_option('alt-rofs-dir'))
Lei YUcc9b41a2021-12-15 14:07:16 +0800101 conf.set_quoted('ALT_RWFS', get_option('alt-rwfs-dir'))
102else
103 conf.set_quoted('ALT_RWFS', '/media/alt/var/persist')
Lei YU63769642021-12-10 16:15:04 +0800104endif
105
Adriana Kobylak0af80a42020-05-05 13:32:10 -0500106configure_file(output: 'config.h', configuration: conf)
Adriana Kobylak113492e2020-05-05 13:45:45 -0500107
Patrick Williams40267022021-08-26 16:48:42 -0500108sdbusplus_dep = dependency('sdbusplus', required: false)
109sdbusplus_proj = dependency('', required: false)
110if not sdbusplus_dep.found() or sdbusplus_dep.type_name() == 'internal'
111 sdbusplus_proj = subproject('sdbusplus')
112endif
113if not sdbusplus_dep.found()
114 sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep')
115endif
116
117if sdbusplus_proj.found()
118 sdbusplusplus_prog = sdbusplus_proj.get_variable('sdbusplusplus_prog')
119 sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable(
120 'sdbuspp_gen_meson_prog')
121else
122 sdbusplusplus_prog = find_program('sdbus++', native: true)
123 sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true)
124endif
125
126cereal_dep = dependency('cereal', required: false)
127has_cereal = cpp.has_header_symbol(
128 'cereal/cereal.hpp',
129 'cereal::specialize',
130 dependencies: cereal_dep,
131 required: false)
132if not has_cereal
133 cereal_opts = import('cmake').subproject_options()
134 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
135 cereal_proj = import('cmake').subproject(
136 'cereal',
137 options: cereal_opts,
138 required: false)
139 assert(cereal_proj.found(), 'cereal is required')
140 cereal_dep = cereal_proj.dependency('cereal')
141endif
142
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500143deps = [
Patrick Williams40267022021-08-26 16:48:42 -0500144 dependency(
145 'phosphor-dbus-interfaces',
146 fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep'],
147 ),
148 dependency(
149 'phosphor-logging',
150 fallback: ['phosphor-logging', 'phosphor_logging_dep'],
151 ),
152 sdbusplus_dep,
153 cereal_dep,
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500154]
155
156ssl = dependency('openssl')
157
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500158systemd = dependency('systemd')
Lei YU3d8ab812021-12-24 10:35:47 +0800159systemd_system_unit_dir = systemd.get_variable(pkgconfig : 'systemdsystemunitdir')
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500160
161unit_files = [
Adriana Kobylak436be812020-06-17 09:44:56 -0500162 'obmc-flash-bmc-setenv@.service.in',
163 'reboot-guard-disable.service.in',
164 'reboot-guard-enable.service.in',
165 'force-reboot.service.in',
166 'usr-local.mount.in',
167 'xyz.openbmc_project.Software.BMC.Updater.service.in',
168 'xyz.openbmc_project.Software.Download.service.in',
169 'xyz.openbmc_project.Software.Sync.service.in',
170 'xyz.openbmc_project.Software.Version.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500171]
172
Adriana Kobylak113492e2020-05-05 13:45:45 -0500173subdir('xyz/openbmc_project/Software/Image')
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500174
175image_updater_sources = files(
176 'activation.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500177 'images.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500178 'item_updater.cpp',
179 'item_updater_main.cpp',
180 'serialize.cpp',
181 'version.cpp',
Miguel Gomez21dad042020-06-26 20:54:48 +0000182 'utils.cpp',
183 'msl_verify.cpp'
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500184)
185
186if get_option('bmc-layout').contains('static')
Adriana Kobylak436be812020-06-17 09:44:56 -0500187 image_updater_sources += files(
188 'static/flash.cpp',
189 'static/item_updater_helper.cpp'
190 )
Adriana Kobylak86013f32020-05-13 12:12:38 -0500191elif get_option('bmc-layout').contains('ubi')
Adriana Kobylak436be812020-06-17 09:44:56 -0500192 image_updater_sources += files(
193 'ubi/flash.cpp',
194 'ubi/item_updater_helper.cpp'
195 )
196
197 unit_files += [
198 'ubi/obmc-flash-bmc-cleanup.service.in',
199 'ubi/obmc-flash-bmc-mirroruboot.service.in',
200 'ubi/obmc-flash-bmc-ubiremount.service.in',
201 'ubi/obmc-flash-bmc-ubiro@.service.in',
202 'ubi/obmc-flash-bmc-ubiro-remove@.service.in',
203 'ubi/obmc-flash-bmc-ubirw.service.in',
204 'ubi/obmc-flash-bmc-ubirw-remove.service.in',
205 'ubi/obmc-flash-bmc-updateubootvars@.service.in'
206 ]
Adriana Kobylak86013f32020-05-13 12:12:38 -0500207elif get_option('bmc-layout').contains('mmc')
Adriana Kobylak436be812020-06-17 09:44:56 -0500208 image_updater_sources += files(
209 'mmc/flash.cpp',
210 'mmc/item_updater_helper.cpp'
211 )
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500212
213 unit_files += [
214 'mmc/obmc-flash-mmc@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500215 'mmc/obmc-flash-mmc-mount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500216 'mmc/obmc-flash-mmc-remove@.service.in',
Adriana Kobylak34124352020-05-22 09:40:40 -0500217 'mmc/obmc-flash-mmc-setprimary@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500218 'mmc/obmc-flash-mmc-umount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500219 ]
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500220endif
221
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500222if get_option('host-bios-upgrade').enabled()
Adriana Kobylak436be812020-06-17 09:44:56 -0500223 unit_files += 'obmc-flash-host-bios@.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500224endif
225
Lei YU63769642021-12-10 16:15:04 +0800226if get_option('bmc-static-dual-image').enabled()
Lei YU84749672021-12-15 14:31:10 +0800227 unit_files += [
Lei YU554757b2022-03-21 11:05:50 +0800228 'static/obmc-flash-bmc-alt@.service.in',
Lei YU84749672021-12-15 14:31:10 +0800229 'static/obmc-flash-bmc-static-mount-alt.service.in',
230 'static/obmc-flash-bmc-prepare-for-sync.service.in',
231 ]
Lei YU63769642021-12-10 16:15:04 +0800232endif
233
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500234if get_option('sync-bmc-files').enabled()
235 executable(
236 'phosphor-sync-software-manager',
237 'sync_manager.cpp',
238 'sync_manager_main.cpp',
239 'sync_watch.cpp',
240 dependencies: deps,
241 install: true
242 )
Adriana Kobylak817209f2020-05-07 09:52:03 -0500243
244 install_data('synclist',
245 install_dir: get_option('sysconfdir')
246 )
Lei YU84749672021-12-15 14:31:10 +0800247
248 install_data('sync-once.sh',
249 install_mode: 'rwxr-xr-x',
250 install_dir: get_option('bindir')
251 )
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500252endif
253
Adriana Kobylak42bd9932021-01-28 09:45:24 -0600254if (get_option('verify-signature').enabled() or \
255 get_option('verify-full-signature').enabled())
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500256 image_updater_sources += files(
George Liu0a06e972020-12-17 09:17:04 +0800257 'utils.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500258 'image_verify.cpp',
259 'openssl_alloc.cpp'
260 )
261endif
262
263executable(
264 'phosphor-download-manager',
265 'download_manager.cpp',
266 'download_manager_main.cpp',
267 dependencies: deps,
268 install: true
269)
270
271executable(
272 'phosphor-image-updater',
273 image_error_cpp,
274 image_error_hpp,
275 image_updater_sources,
276 dependencies: [deps, ssl],
277 install: true
278)
279
280executable(
281 'phosphor-version-software-manager',
282 image_error_cpp,
283 image_error_hpp,
284 'image_manager.cpp',
285 'image_manager_main.cpp',
286 'version.cpp',
287 'watch.cpp',
288 dependencies: [deps, ssl],
289 install: true
290)
Adriana Kobylak817209f2020-05-07 09:52:03 -0500291
292install_data('obmc-flash-bmc',
293 install_mode: 'rwxr-xr-x',
294 install_dir: get_option('bindir')
295)
296
Lei YU531fbc22021-12-10 20:03:18 +0800297install_data('detect-slot-aspeed',
298 install_mode: 'rwxr-xr-x',
299 install_dir: get_option('bindir')
300)
301
Lei YU984cef52021-12-17 11:28:21 +0800302install_data('reset-cs0-aspeed',
303 install_mode: 'rwxr-xr-x',
304 install_dir: get_option('bindir')
305)
306
Adriana Kobylak817209f2020-05-07 09:52:03 -0500307install_data('software.conf',
308 install_dir: '/usr/lib/tmpfiles.d/'
309)
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500310
311foreach u : unit_files
312 configure_file(
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500313 input: u,
Adriana Kobylak436be812020-06-17 09:44:56 -0500314 output: '@BASENAME@',
315 configuration: conf,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500316 install: true,
317 install_dir: systemd_system_unit_dir,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500318 )
319endforeach
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500320
321# If test coverage of source files within the root directory are wanted,
322# need to define and build the tests from here
323build_tests = get_option('tests')
324if not build_tests.disabled()
325 oe_sdk = get_option('oe-sdk')
326 if oe_sdk.enabled()
327 # Setup OE SYSROOT
328 OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
329 if OECORE_TARGET_SYSROOT == ''
330 error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
331 endif
332 message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
333 rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
334 ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
335 dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
336 else
337 dynamic_linker = []
338 endif
339
340 gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
341 include_srcs = declare_dependency(sources: [
George Liu0a06e972020-12-17 09:17:04 +0800342 'utils.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500343 'image_verify.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500344 'images.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500345 'version.cpp']
346 )
347
348 test('utest',
349 executable(
350 'utest',
351 './test/utest.cpp',
352 link_args: dynamic_linker,
353 build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
354 dependencies: [deps, gtest, include_srcs, ssl]
355 )
356)
357endif
George Liucc742332021-10-20 16:25:55 +0800358
359if get_option('usb-code-update').enabled()
360 subdir('usb')
361endif