blob: 17232b1b2a688c8aeea6b49e864d62e53d1213c0 [file] [log] [blame]
Brad Bishopa0fa15b2020-11-06 14:42:24 -05001project(
2 'openpower-pnor-code-mgmt',
3 'cpp',
4 default_options: [
5 'warning_level=3',
6 'werror=true',
Patrick Williams90475e72023-07-12 11:15:12 -05007 'cpp_std=c++23',
Brad Bishopa0fa15b2020-11-06 14:42:24 -05008 'buildtype=debugoptimized',
9 'b_ndebug=if-release',
10 'b_lto=true',
11 ],
12 license: 'Apache-2.0',
13 version: '1.0',
Patrick Williams90475e72023-07-12 11:15:12 -050014 meson_version: '>=1.1.1',
Brad Bishopa0fa15b2020-11-06 14:42:24 -050015)
16
Brad Bishopa0fa15b2020-11-06 14:42:24 -050017if(get_option('buildtype') == 'minsize')
18 add_project_arguments('-DNDEBUG', language : 'cpp')
19endif
20
21# Disable lto when compiling with no optimization
22if(get_option('optimization') == '0')
23 add_project_arguments('-fno-lto', language: 'cpp')
24 message('Disabling lto because optimization is disabled')
25endif
26
Brad Bishop099543e2020-11-09 15:37:58 -050027cxx = meson.get_compiler('cpp')
28
Brad Bishopa0fa15b2020-11-06 14:42:24 -050029extra_sources = []
30extra_unit_files = []
31extra_scripts = []
32
Patrick Williams9c6fa9b2023-11-29 06:43:59 -060033build_vpnor = get_option('vpnor').allowed()
34build_pldm = get_option('pldm').allowed()
35build_verify_signature = get_option('verify-signature').allowed()
Brad Bishopa0fa15b2020-11-06 14:42:24 -050036
Brad Bishop099543e2020-11-09 15:37:58 -050037if not cxx.has_header('CLI/CLI.hpp')
38 error('Could not find CLI.hpp')
39endif
40
Brad Bishopa0fa15b2020-11-06 14:42:24 -050041summary('building for device type', '@0@'.format(get_option('device-type')))
42summary('building vpnor', build_vpnor)
Adriana Kobylak6fc7fcd2021-10-18 18:47:55 +000043summary('building pldm', build_pldm)
Brad Bishopa0fa15b2020-11-06 14:42:24 -050044summary('building signature verify', build_verify_signature)
45
46subs = configuration_data()
47subs.set_quoted('ACTIVATION_FWD_ASSOCIATION', 'inventory')
48subs.set_quoted('ACTIVATION_REV_ASSOCIATION', 'activation')
49subs.set_quoted('ACTIVE_FWD_ASSOCIATION', 'active')
50subs.set('ACTIVE_PNOR_MAX_ALLOWED', 2)
51subs.set_quoted('ACTIVE_REV_ASSOCIATION', 'software_version')
52subs.set_quoted('ASSOCIATIONS_INTERFACE', 'xyz.openbmc_project.Association.Definitions')
Brad Bishop7c053c32020-11-16 12:58:11 -050053subs.set_quoted('BUSNAME_UPDATER', 'org.open_power.Software.Host.Updater')
Brad Bishopa0fa15b2020-11-06 14:42:24 -050054subs.set_quoted('CHASSIS_STATE_OBJ', 'xyz.openbmc_project.State.Chassis')
55subs.set_quoted('CHASSIS_STATE_OFF', 'xyz.openbmc_project.State.Chassis.PowerState.Off')
56subs.set_quoted('CHASSIS_STATE_PATH', '/xyz/openbmc_project/state/chassis0')
57subs.set_quoted('FILEPATH_IFACE', 'xyz.openbmc_project.Common.FilePath')
58subs.set_quoted('FUNCTIONAL_FWD_ASSOCIATION', 'functional')
59subs.set_quoted('FUNCTIONAL_REV_ASSOCIATION', 'software_version')
60subs.set_quoted('HASH_FILE_NAME', 'hashfunc')
61subs.set_quoted('HOST_INVENTORY_PATH', '/xyz/openbmc_project/inventory/system/chassis')
62subs.set_quoted('IMG_DIR', '/tmp/images')
63subs.set_quoted('MANIFEST_FILE', 'MANIFEST')
64subs.set_quoted('MAPPER_BUSNAME', 'xyz.openbmc_project.ObjectMapper')
65subs.set_quoted('MAPPER_INTERFACE', 'xyz.openbmc_project.ObjectMapper')
66subs.set_quoted('MAPPER_PATH', '/xyz/openbmc_project/object_mapper')
67subs.set_quoted('MEDIA_DIR', '/media/')
68subs.set('MMC_LAYOUT', get_option('device-type') == 'mmc')
69subs.set_quoted('PERSIST_DIR', '/var/lib/obmc/openpower-pnor-code-mgmt/')
70subs.set_quoted('PNOR_ACTIVE_PATH', '/var/lib/phosphor-software-manager/pnor/')
71subs.set_quoted('PNOR_MSL', get_option('msl'))
72subs.set_quoted('PNOR_PRSV', '/media/pnor-prsv')
73subs.set_quoted('PNOR_PRSV_ACTIVE_PATH', '/var/lib/phosphor-software-manager/pnor/prsv')
74subs.set_quoted('PNOR_RO_ACTIVE_PATH', '/var/lib/phosphor-software-manager/pnor/ro')
75subs.set_quoted('PNOR_RO_PREFIX', '/media/pnor-ro-')
76subs.set_quoted('PNOR_RW_ACTIVE_PATH', '/var/lib/phosphor-software-manager/pnor/rw')
77subs.set_quoted('PNOR_RW_PREFIX', '/media/pnor-rw-')
78subs.set_quoted('PNOR_SIGNED_IMAGE_CONF_PATH', '/etc/activationdata/')
79subs.set_quoted('PNOR_TOC_FILE', 'pnor.toc')
80subs.set_quoted('PNOR_VERSION_PARTITION', 'VERSION')
81subs.set_quoted('PUBLICKEY_FILE_NAME', 'publickey')
82subs.set_quoted('SIGNATURE_FILE_EXT', '.sig')
83subs.set_quoted('SOFTWARE_OBJPATH', '/xyz/openbmc_project/software')
84subs.set_quoted('SYSTEMD_BUSNAME', 'org.freedesktop.systemd1')
85subs.set_quoted('SYSTEMD_INTERFACE', 'org.freedesktop.systemd1.Manager')
86subs.set_quoted('SYSTEMD_PATH', '/org/freedesktop/systemd1')
87subs.set_quoted('SYSTEMD_PROPERTY_INTERFACE', 'org.freedesktop.DBus.Properties')
88subs.set('UBIFS_LAYOUT', get_option('device-type') == 'ubi')
89subs.set_quoted('UPDATEABLE_FWD_ASSOCIATION', 'updateable')
90subs.set_quoted('UPDATEABLE_REV_ASSOCIATION', 'software_version')
91subs.set_quoted('VERSION_IFACE', 'xyz.openbmc_project.Software.Version')
92subs.set('WANT_SIGNATURE_VERIFY', build_verify_signature)
93configure_file(
94 output: 'config.h',
95 configuration: subs)
96
97if get_option('device-type') == 'ubi'
98 extra_sources += [
99 'ubi/activation_ubi.cpp',
100 'ubi/item_updater_ubi.cpp',
101 'ubi/serialize.cpp',
102 'ubi/watch.cpp',
103 ]
104 extra_scripts += [
105 'ubi/obmc-flash-bios',
106 ]
107 extra_unit_files += [
108 'ubi/obmc-flash-bios-cleanup.service',
109 'ubi/obmc-flash-bios-ubiattach.service',
110 'ubi/obmc-flash-bios-ubimount@.service',
111 'ubi/obmc-flash-bios-ubipatch.service',
112 'ubi/obmc-flash-bios-ubiremount.service',
113 'ubi/obmc-flash-bios-ubiumount-ro@.service',
114 'ubi/obmc-flash-bios-ubiumount-rw@.service',
115 ]
116endif
117
118if get_option('device-type') == 'mmc'
119 extra_sources += [
120 'mmc/activation_mmc.cpp',
121 'mmc/item_updater_mmc.cpp',
122 ]
123 extra_scripts += [
124 'mmc/obmc-flash-bios',
Deepa Karthikeyana96df3e2024-04-16 11:22:29 -0500125 'mmc/recover_pnor_files',
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500126 ]
127 extra_unit_files += [
128 'mmc/obmc-flash-bios-init.service',
129 'mmc/obmc-flash-bios-patch.service',
Isaac Kurth514a0942021-10-19 21:17:44 +0000130 'mmc/openpower-bios-factory-reset.service',
Deepa Karthikeyana96df3e2024-04-16 11:22:29 -0500131 'mmc/obmc-recover-pnor.service',
Adriana Kobylak6fc7fcd2021-10-18 18:47:55 +0000132 ]
133endif
134
135if build_pldm
136 extra_unit_files += [
Adriana Kobylakac5aec12021-06-22 16:22:17 +0000137 'mmc/openpower-process-host-firmware.service',
Adriana Kobylak53a27392021-06-14 17:42:40 +0000138 'mmc/openpower-update-bios-attr-table.service',
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500139 ]
140endif
141
142if get_option('device-type') == 'static'
143 extra_sources += [
144 'static/item_updater_static.cpp',
145 'static/activation_static.cpp',
146 ]
147 extra_unit_files += [
148 'openpower-pnor-update@.service',
149 ]
150endif
151
152if build_verify_signature
153 extra_sources += [
154 'image_verify.cpp'
155 ]
156endif
157
158if build_vpnor
159 extra_scripts += [
160 'vpnor/obmc-vpnor-util',
161 ]
162 extra_unit_files += [
163 'vpnor/obmc-vpnor-check-clearvolatile@.service',
164 'vpnor/obmc-vpnor-enable-clearvolatile@.service',
165 'vpnor/obmc-vpnor-updatesymlinks.service',
166 ]
167endif
168
169executable(
170 'openpower-update-manager',
171 [
172 'activation.cpp',
Brad Bishop099543e2020-11-09 15:37:58 -0500173 'functions.cpp',
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500174 'version.cpp',
175 'item_updater.cpp',
176 'item_updater_main.cpp',
177 'utils.cpp',
178 ] + extra_sources,
179 dependencies: [
180 dependency('libcrypto'),
181 dependency('libsystemd'),
182 dependency('openssl'),
183 dependency('phosphor-dbus-interfaces'),
184 dependency('phosphor-logging'),
185 dependency('sdbusplus'),
Brad Bishop0283f7c2020-11-09 10:09:26 -0500186 dependency('sdeventplus'),
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500187 ],
188 install: true
189)
190
191executable(
192 'openpower-pnor-msl',
193 [
194 'msl_verify.cpp',
195 'msl_verify_main.cpp',
196 ],
197 dependencies: [
198 dependency('libsystemd'),
199 dependency('phosphor-dbus-interfaces'),
200 dependency('phosphor-logging'),
201 dependency('sdbusplus'),
202 ],
203 install: true
204)
205
George Liu24bfa192023-08-16 14:32:24 +0800206fs = import('fs')
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500207foreach s : extra_scripts
George Liu24bfa192023-08-16 14:32:24 +0800208 fs.copyfile(
209 s,
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500210 install: true,
211 install_mode: 'rwxr-xr-x',
George Liu24bfa192023-08-16 14:32:24 +0800212 install_dir: get_option('bindir')
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500213 )
214endforeach
215
216unit_files = [
217 'op-pnor-msl.service',
218 'org.open_power.Software.Host.Updater.service',
219] + extra_unit_files
220
Adriana Kobylak067876a2021-04-26 19:36:39 +0000221systemd_system_unit_dir = dependency('systemd').get_variable(
Patrick Williamsfe34ccd2023-04-12 08:01:04 -0500222 'systemdsystemunitdir',
Adriana Kobylak067876a2021-04-26 19:36:39 +0000223 pkgconfig_define: ['prefix', get_option('prefix')])
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500224foreach u : unit_files
George Liu24bfa192023-08-16 14:32:24 +0800225 fs.copyfile(
226 u,
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500227 install: true,
George Liu24bfa192023-08-16 14:32:24 +0800228 install_dir: systemd_system_unit_dir
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500229 )
230endforeach
231
Adriana Kobylak067876a2021-04-26 19:36:39 +0000232dbus_system_bus_services_dir = dependency('dbus-1').get_variable(
Patrick Williamsfe34ccd2023-04-12 08:01:04 -0500233 'system_bus_services_dir',
Adriana Kobylak067876a2021-04-26 19:36:39 +0000234 pkgconfig_define: ['prefix', get_option('prefix')])
Brad Bishop671a7da2020-11-15 13:31:05 -0500235dbus_policy_dir = run_command(
236 'realpath',
237 join_paths(dbus_system_bus_services_dir, '..', 'system.d')).stdout().strip()
238
239install_data(
240 'dbus/org.open_power.Software.Host.Updater.conf',
241 install_dir: dbus_policy_dir)
242
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500243if not get_option('tests').disabled()
Adriana Kobylak588a9fa2021-06-22 14:28:45 +0000244 oe_sdk = get_option('oe-sdk')
Patrick Williams9c6fa9b2023-11-29 06:43:59 -0600245 if oe_sdk.allowed()
Adriana Kobylak588a9fa2021-06-22 14:28:45 +0000246 # Setup OE SYSROOT
247 OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
248 if OECORE_TARGET_SYSROOT == ''
249 error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
250 endif
251 message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
252 rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
253 ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
254 dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
255 else
256 dynamic_linker = []
257 endif
258
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500259 test(
260 'utest',
261 executable(
262 'utest',
263 'activation.cpp',
264 'version.cpp',
265 'item_updater.cpp',
266 'image_verify.cpp',
267 'utils.cpp',
268 'msl_verify.cpp',
269 'ubi/activation_ubi.cpp',
270 'ubi/item_updater_ubi.cpp',
271 'ubi/serialize.cpp',
272 'ubi/watch.cpp',
273 'static/item_updater_static.cpp',
274 'static/activation_static.cpp',
275 'test/test_signature.cpp',
276 'test/test_version.cpp',
277 'test/test_item_updater_static.cpp',
278 'msl_verify.cpp',
279 dependencies: [
280 dependency('libcrypto'),
281 dependency('gtest', main: true),
282 dependency('openssl'),
283 dependency('phosphor-logging'),
284 dependency('phosphor-dbus-interfaces'),
285 ],
286 implicit_include_directories: false,
287 include_directories: '.',
288 )
289 )
Brad Bishop099543e2020-11-09 15:37:58 -0500290 test(
291 'test_functions',
292 executable(
293 'test_functions',
294 'test/test_functions.cpp',
295 'functions.cpp',
296 dependencies: [
297 dependency('gtest', main: true),
Adriana Kobylak2b78eb02022-04-06 19:38:47 +0000298 dependency('phosphor-dbus-interfaces'),
Brad Bishop099543e2020-11-09 15:37:58 -0500299 dependency('sdbusplus'),
300 dependency('sdeventplus'),
301 ],
302 )
303 )
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500304endif