blob: 51f0abaff2b9c47af6f496495eb05d746f84caff [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
55# The path of the alt rwfs overlay
56conf.set_quoted('ALT_RWFS', '/media/alt/var/persist')
57# The prefix path for the versioned read-only bmc partitions
58conf.set_quoted('BMC_ROFS_PREFIX', get_option('media-dir') + '/rofs-')
59# The name of the BMC table of contents file
60conf.set_quoted('OS_RELEASE_FILE', '/etc/os-release')
61# The dir where activation data is stored in files
62conf.set_quoted('PERSIST_DIR', '/var/lib/phosphor-bmc-code-mgmt/')
63
64# Supported BMC layout types
65conf.set('STATIC_LAYOUT', get_option('bmc-layout').contains('static'))
66conf.set('UBIFS_LAYOUT', get_option('bmc-layout').contains('ubi'))
Adriana Kobylak70f5bc02020-05-13 14:08:14 -050067conf.set('MMC_LAYOUT', get_option('bmc-layout').contains('mmc'))
Adriana Kobylak0af80a42020-05-05 13:32:10 -050068
69# Configurable features
70conf.set('HOST_BIOS_UPGRADE', get_option('host-bios-upgrade').enabled())
Adriana Kobylak42bd9932021-01-28 09:45:24 -060071conf.set('WANT_SIGNATURE_VERIFY', \
72 get_option('verify-signature').enabled() or \
73 get_option('verify-full-signature').enabled())
George Liu0a06e972020-12-17 09:17:04 +080074conf.set('WANT_SIGNATURE_FULL_VERIFY', get_option('verify-full-signature').enabled())
Adriana Kobylak0af80a42020-05-05 13:32:10 -050075
76# Configurable variables
77conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed'))
78conf.set_quoted('HASH_FILE_NAME', get_option('hash-file-name'))
79conf.set_quoted('IMG_UPLOAD_DIR', get_option('img-upload-dir'))
80conf.set_quoted('MANIFEST_FILE_NAME', get_option('manifest-file-name'))
81conf.set_quoted('MEDIA_DIR', get_option('media-dir'))
Adriana Kobylak73609bb2020-06-18 15:05:40 -050082optional_array = get_option('optional-images')
83optional_images = ''
84foreach optiona_image : optional_array
85 optional_images = ' '.join([optional_images, optiona_image])
86endforeach
87conf.set_quoted('OPTIONAL_IMAGES', optional_images)
Adriana Kobylak0af80a42020-05-05 13:32:10 -050088conf.set_quoted('PUBLICKEY_FILE_NAME', get_option('publickey-file-name'))
89conf.set_quoted('SIGNATURE_FILE_EXT', get_option('signature-file-ext'))
90conf.set_quoted('SIGNED_IMAGE_CONF_PATH', get_option('signed-image-conf-path'))
91conf.set_quoted('SYNC_LIST_DIR_PATH', get_option('sync-list-dir-path'))
92conf.set_quoted('SYNC_LIST_FILE_NAME', get_option('sync-list-file-name'))
Miguel Gomez21dad042020-06-26 20:54:48 +000093conf.set_quoted('BMC_MSL', get_option('bmc-msl'))
94conf.set_quoted('REGEX_BMC_MSL', get_option('regex-bmc-msl'))
95
Lei YU6e9fb1d2021-02-19 18:01:40 +080096if get_option('host-bios-upgrade').enabled()
97 conf.set_quoted('BIOS_OBJPATH', get_option('bios-object-path'))
98endif
Adriana Kobylak0af80a42020-05-05 13:32:10 -050099
Lei YU63769642021-12-10 16:15:04 +0800100if get_option('bmc-static-dual-image').enabled()
101 conf.set('BMC_STATIC_DUAL_IMAGE', get_option('bmc-static-dual-image').enabled())
102 conf.set_quoted('ALT_ROFS_DIR', get_option('alt-rofs-dir'))
103endif
104
Adriana Kobylak0af80a42020-05-05 13:32:10 -0500105configure_file(output: 'config.h', configuration: conf)
Adriana Kobylak113492e2020-05-05 13:45:45 -0500106
Patrick Williams40267022021-08-26 16:48:42 -0500107sdbusplus_dep = dependency('sdbusplus', required: false)
108sdbusplus_proj = dependency('', required: false)
109if not sdbusplus_dep.found() or sdbusplus_dep.type_name() == 'internal'
110 sdbusplus_proj = subproject('sdbusplus')
111endif
112if not sdbusplus_dep.found()
113 sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep')
114endif
115
116if sdbusplus_proj.found()
117 sdbusplusplus_prog = sdbusplus_proj.get_variable('sdbusplusplus_prog')
118 sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable(
119 'sdbuspp_gen_meson_prog')
120else
121 sdbusplusplus_prog = find_program('sdbus++', native: true)
122 sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true)
123endif
124
125cereal_dep = dependency('cereal', required: false)
126has_cereal = cpp.has_header_symbol(
127 'cereal/cereal.hpp',
128 'cereal::specialize',
129 dependencies: cereal_dep,
130 required: false)
131if not has_cereal
132 cereal_opts = import('cmake').subproject_options()
133 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
134 cereal_proj = import('cmake').subproject(
135 'cereal',
136 options: cereal_opts,
137 required: false)
138 assert(cereal_proj.found(), 'cereal is required')
139 cereal_dep = cereal_proj.dependency('cereal')
140endif
141
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500142deps = [
Patrick Williams40267022021-08-26 16:48:42 -0500143 dependency(
144 'phosphor-dbus-interfaces',
145 fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep'],
146 ),
147 dependency(
148 'phosphor-logging',
149 fallback: ['phosphor-logging', 'phosphor_logging_dep'],
150 ),
151 sdbusplus_dep,
152 cereal_dep,
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500153]
154
155ssl = dependency('openssl')
156
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500157systemd = dependency('systemd')
Lei YU3d8ab812021-12-24 10:35:47 +0800158systemd_system_unit_dir = systemd.get_variable(pkgconfig : 'systemdsystemunitdir')
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500159
160unit_files = [
Adriana Kobylak436be812020-06-17 09:44:56 -0500161 'obmc-flash-bmc-setenv@.service.in',
162 'reboot-guard-disable.service.in',
163 'reboot-guard-enable.service.in',
164 'force-reboot.service.in',
165 'usr-local.mount.in',
166 'xyz.openbmc_project.Software.BMC.Updater.service.in',
167 'xyz.openbmc_project.Software.Download.service.in',
168 'xyz.openbmc_project.Software.Sync.service.in',
169 'xyz.openbmc_project.Software.Version.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500170]
171
Adriana Kobylak113492e2020-05-05 13:45:45 -0500172subdir('xyz/openbmc_project/Software/Image')
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500173
174image_updater_sources = files(
175 'activation.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500176 'images.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500177 'item_updater.cpp',
178 'item_updater_main.cpp',
179 'serialize.cpp',
180 'version.cpp',
Miguel Gomez21dad042020-06-26 20:54:48 +0000181 'utils.cpp',
182 'msl_verify.cpp'
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500183)
184
185if get_option('bmc-layout').contains('static')
Adriana Kobylak436be812020-06-17 09:44:56 -0500186 image_updater_sources += files(
187 'static/flash.cpp',
188 'static/item_updater_helper.cpp'
189 )
Adriana Kobylak86013f32020-05-13 12:12:38 -0500190elif get_option('bmc-layout').contains('ubi')
Adriana Kobylak436be812020-06-17 09:44:56 -0500191 image_updater_sources += files(
192 'ubi/flash.cpp',
193 'ubi/item_updater_helper.cpp'
194 )
195
196 unit_files += [
197 'ubi/obmc-flash-bmc-cleanup.service.in',
198 'ubi/obmc-flash-bmc-mirroruboot.service.in',
199 'ubi/obmc-flash-bmc-ubiremount.service.in',
200 'ubi/obmc-flash-bmc-ubiro@.service.in',
201 'ubi/obmc-flash-bmc-ubiro-remove@.service.in',
202 'ubi/obmc-flash-bmc-ubirw.service.in',
203 'ubi/obmc-flash-bmc-ubirw-remove.service.in',
204 'ubi/obmc-flash-bmc-updateubootvars@.service.in'
205 ]
Adriana Kobylak86013f32020-05-13 12:12:38 -0500206elif get_option('bmc-layout').contains('mmc')
Adriana Kobylak436be812020-06-17 09:44:56 -0500207 image_updater_sources += files(
208 'mmc/flash.cpp',
209 'mmc/item_updater_helper.cpp'
210 )
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500211
212 unit_files += [
213 'mmc/obmc-flash-mmc@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500214 'mmc/obmc-flash-mmc-mount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500215 'mmc/obmc-flash-mmc-remove@.service.in',
Adriana Kobylak34124352020-05-22 09:40:40 -0500216 'mmc/obmc-flash-mmc-setprimary@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500217 'mmc/obmc-flash-mmc-umount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500218 ]
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500219endif
220
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500221if get_option('host-bios-upgrade').enabled()
Adriana Kobylak436be812020-06-17 09:44:56 -0500222 unit_files += 'obmc-flash-host-bios@.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500223endif
224
Lei YU63769642021-12-10 16:15:04 +0800225if get_option('bmc-static-dual-image').enabled()
226 unit_files += 'static/obmc-flash-bmc-static-mount-alt.service.in'
227endif
228
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500229if get_option('sync-bmc-files').enabled()
230 executable(
231 'phosphor-sync-software-manager',
232 'sync_manager.cpp',
233 'sync_manager_main.cpp',
234 'sync_watch.cpp',
235 dependencies: deps,
236 install: true
237 )
Adriana Kobylak817209f2020-05-07 09:52:03 -0500238
239 install_data('synclist',
240 install_dir: get_option('sysconfdir')
241 )
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500242endif
243
Adriana Kobylak42bd9932021-01-28 09:45:24 -0600244if (get_option('verify-signature').enabled() or \
245 get_option('verify-full-signature').enabled())
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500246 image_updater_sources += files(
George Liu0a06e972020-12-17 09:17:04 +0800247 'utils.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500248 'image_verify.cpp',
249 'openssl_alloc.cpp'
250 )
251endif
252
253executable(
254 'phosphor-download-manager',
255 'download_manager.cpp',
256 'download_manager_main.cpp',
257 dependencies: deps,
258 install: true
259)
260
261executable(
262 'phosphor-image-updater',
263 image_error_cpp,
264 image_error_hpp,
265 image_updater_sources,
266 dependencies: [deps, ssl],
267 install: true
268)
269
270executable(
271 'phosphor-version-software-manager',
272 image_error_cpp,
273 image_error_hpp,
274 'image_manager.cpp',
275 'image_manager_main.cpp',
276 'version.cpp',
277 'watch.cpp',
278 dependencies: [deps, ssl],
279 install: true
280)
Adriana Kobylak817209f2020-05-07 09:52:03 -0500281
282install_data('obmc-flash-bmc',
283 install_mode: 'rwxr-xr-x',
284 install_dir: get_option('bindir')
285)
286
Lei YU531fbc22021-12-10 20:03:18 +0800287install_data('detect-slot-aspeed',
288 install_mode: 'rwxr-xr-x',
289 install_dir: get_option('bindir')
290)
291
Adriana Kobylak817209f2020-05-07 09:52:03 -0500292install_data('software.conf',
293 install_dir: '/usr/lib/tmpfiles.d/'
294)
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500295
296foreach u : unit_files
297 configure_file(
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500298 input: u,
Adriana Kobylak436be812020-06-17 09:44:56 -0500299 output: '@BASENAME@',
300 configuration: conf,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500301 install: true,
302 install_dir: systemd_system_unit_dir,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500303 )
304endforeach
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500305
306# If test coverage of source files within the root directory are wanted,
307# need to define and build the tests from here
308build_tests = get_option('tests')
309if not build_tests.disabled()
310 oe_sdk = get_option('oe-sdk')
311 if oe_sdk.enabled()
312 # Setup OE SYSROOT
313 OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
314 if OECORE_TARGET_SYSROOT == ''
315 error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
316 endif
317 message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
318 rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
319 ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
320 dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
321 else
322 dynamic_linker = []
323 endif
324
325 gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
326 include_srcs = declare_dependency(sources: [
George Liu0a06e972020-12-17 09:17:04 +0800327 'utils.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500328 'image_verify.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500329 'images.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500330 'version.cpp']
331 )
332
333 test('utest',
334 executable(
335 'utest',
336 './test/utest.cpp',
337 link_args: dynamic_linker,
338 build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
339 dependencies: [deps, gtest, include_srcs, ssl]
340 )
341)
342endif
George Liucc742332021-10-20 16:25:55 +0800343
344if get_option('usb-code-update').enabled()
345 subdir('usb')
346endif