blob: aa2ce5a6bd57a04d49740f09fcb8c1708ffbdfab [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',
Adriana Kobylak067876a2021-04-26 19:36:39 +00007 'cpp_std=c++20',
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',
Adriana Kobylak067876a2021-04-26 19:36:39 +000014 meson_version: '>=0.57.0',
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
33build_vpnor = get_option('vpnor').enabled()
34build_verify_signature = get_option('verify-signature').enabled()
35
Brad Bishop099543e2020-11-09 15:37:58 -050036if not cxx.has_header('CLI/CLI.hpp')
37 error('Could not find CLI.hpp')
38endif
39
Brad Bishopa0fa15b2020-11-06 14:42:24 -050040summary('building for device type', '@0@'.format(get_option('device-type')))
41summary('building vpnor', build_vpnor)
42summary('building signature verify', build_verify_signature)
43
44subs = configuration_data()
45subs.set_quoted('ACTIVATION_FWD_ASSOCIATION', 'inventory')
46subs.set_quoted('ACTIVATION_REV_ASSOCIATION', 'activation')
47subs.set_quoted('ACTIVE_FWD_ASSOCIATION', 'active')
48subs.set('ACTIVE_PNOR_MAX_ALLOWED', 2)
49subs.set_quoted('ACTIVE_REV_ASSOCIATION', 'software_version')
50subs.set_quoted('ASSOCIATIONS_INTERFACE', 'xyz.openbmc_project.Association.Definitions')
Brad Bishop7c053c32020-11-16 12:58:11 -050051subs.set_quoted('BUSNAME_UPDATER', 'org.open_power.Software.Host.Updater')
Brad Bishopa0fa15b2020-11-06 14:42:24 -050052subs.set_quoted('CHASSIS_STATE_OBJ', 'xyz.openbmc_project.State.Chassis')
53subs.set_quoted('CHASSIS_STATE_OFF', 'xyz.openbmc_project.State.Chassis.PowerState.Off')
54subs.set_quoted('CHASSIS_STATE_PATH', '/xyz/openbmc_project/state/chassis0')
55subs.set_quoted('FILEPATH_IFACE', 'xyz.openbmc_project.Common.FilePath')
56subs.set_quoted('FUNCTIONAL_FWD_ASSOCIATION', 'functional')
57subs.set_quoted('FUNCTIONAL_REV_ASSOCIATION', 'software_version')
58subs.set_quoted('HASH_FILE_NAME', 'hashfunc')
59subs.set_quoted('HOST_INVENTORY_PATH', '/xyz/openbmc_project/inventory/system/chassis')
60subs.set_quoted('IMG_DIR', '/tmp/images')
61subs.set_quoted('MANIFEST_FILE', 'MANIFEST')
62subs.set_quoted('MAPPER_BUSNAME', 'xyz.openbmc_project.ObjectMapper')
63subs.set_quoted('MAPPER_INTERFACE', 'xyz.openbmc_project.ObjectMapper')
64subs.set_quoted('MAPPER_PATH', '/xyz/openbmc_project/object_mapper')
65subs.set_quoted('MEDIA_DIR', '/media/')
66subs.set('MMC_LAYOUT', get_option('device-type') == 'mmc')
67subs.set_quoted('PERSIST_DIR', '/var/lib/obmc/openpower-pnor-code-mgmt/')
68subs.set_quoted('PNOR_ACTIVE_PATH', '/var/lib/phosphor-software-manager/pnor/')
69subs.set_quoted('PNOR_MSL', get_option('msl'))
70subs.set_quoted('PNOR_PRSV', '/media/pnor-prsv')
71subs.set_quoted('PNOR_PRSV_ACTIVE_PATH', '/var/lib/phosphor-software-manager/pnor/prsv')
72subs.set_quoted('PNOR_RO_ACTIVE_PATH', '/var/lib/phosphor-software-manager/pnor/ro')
73subs.set_quoted('PNOR_RO_PREFIX', '/media/pnor-ro-')
74subs.set_quoted('PNOR_RW_ACTIVE_PATH', '/var/lib/phosphor-software-manager/pnor/rw')
75subs.set_quoted('PNOR_RW_PREFIX', '/media/pnor-rw-')
76subs.set_quoted('PNOR_SIGNED_IMAGE_CONF_PATH', '/etc/activationdata/')
77subs.set_quoted('PNOR_TOC_FILE', 'pnor.toc')
78subs.set_quoted('PNOR_VERSION_PARTITION', 'VERSION')
79subs.set_quoted('PUBLICKEY_FILE_NAME', 'publickey')
80subs.set_quoted('SIGNATURE_FILE_EXT', '.sig')
81subs.set_quoted('SOFTWARE_OBJPATH', '/xyz/openbmc_project/software')
82subs.set_quoted('SYSTEMD_BUSNAME', 'org.freedesktop.systemd1')
83subs.set_quoted('SYSTEMD_INTERFACE', 'org.freedesktop.systemd1.Manager')
84subs.set_quoted('SYSTEMD_PATH', '/org/freedesktop/systemd1')
85subs.set_quoted('SYSTEMD_PROPERTY_INTERFACE', 'org.freedesktop.DBus.Properties')
86subs.set('UBIFS_LAYOUT', get_option('device-type') == 'ubi')
87subs.set_quoted('UPDATEABLE_FWD_ASSOCIATION', 'updateable')
88subs.set_quoted('UPDATEABLE_REV_ASSOCIATION', 'software_version')
89subs.set_quoted('VERSION_IFACE', 'xyz.openbmc_project.Software.Version')
90subs.set('WANT_SIGNATURE_VERIFY', build_verify_signature)
91configure_file(
92 output: 'config.h',
93 configuration: subs)
94
95if get_option('device-type') == 'ubi'
96 extra_sources += [
97 'ubi/activation_ubi.cpp',
98 'ubi/item_updater_ubi.cpp',
99 'ubi/serialize.cpp',
100 'ubi/watch.cpp',
101 ]
102 extra_scripts += [
103 'ubi/obmc-flash-bios',
104 ]
105 extra_unit_files += [
106 'ubi/obmc-flash-bios-cleanup.service',
107 'ubi/obmc-flash-bios-ubiattach.service',
108 'ubi/obmc-flash-bios-ubimount@.service',
109 'ubi/obmc-flash-bios-ubipatch.service',
110 'ubi/obmc-flash-bios-ubiremount.service',
111 'ubi/obmc-flash-bios-ubiumount-ro@.service',
112 'ubi/obmc-flash-bios-ubiumount-rw@.service',
113 ]
114endif
115
116if get_option('device-type') == 'mmc'
117 extra_sources += [
118 'mmc/activation_mmc.cpp',
119 'mmc/item_updater_mmc.cpp',
120 ]
121 extra_scripts += [
122 'mmc/obmc-flash-bios',
123 ]
124 extra_unit_files += [
125 'mmc/obmc-flash-bios-init.service',
126 'mmc/obmc-flash-bios-patch.service',
Adriana Kobylakac5aec12021-06-22 16:22:17 +0000127 'mmc/openpower-process-host-firmware.service',
Adriana Kobylak53a27392021-06-14 17:42:40 +0000128 'mmc/openpower-update-bios-attr-table.service',
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500129 ]
130endif
131
132if get_option('device-type') == 'static'
133 extra_sources += [
134 'static/item_updater_static.cpp',
135 'static/activation_static.cpp',
136 ]
137 extra_unit_files += [
138 'openpower-pnor-update@.service',
139 ]
140endif
141
142if build_verify_signature
143 extra_sources += [
144 'image_verify.cpp'
145 ]
146endif
147
148if build_vpnor
149 extra_scripts += [
150 'vpnor/obmc-vpnor-util',
151 ]
152 extra_unit_files += [
153 'vpnor/obmc-vpnor-check-clearvolatile@.service',
154 'vpnor/obmc-vpnor-enable-clearvolatile@.service',
155 'vpnor/obmc-vpnor-updatesymlinks.service',
156 ]
157endif
158
159executable(
160 'openpower-update-manager',
161 [
162 'activation.cpp',
Brad Bishop099543e2020-11-09 15:37:58 -0500163 'functions.cpp',
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500164 'version.cpp',
165 'item_updater.cpp',
166 'item_updater_main.cpp',
167 'utils.cpp',
168 ] + extra_sources,
169 dependencies: [
170 dependency('libcrypto'),
171 dependency('libsystemd'),
172 dependency('openssl'),
173 dependency('phosphor-dbus-interfaces'),
174 dependency('phosphor-logging'),
175 dependency('sdbusplus'),
Brad Bishop0283f7c2020-11-09 10:09:26 -0500176 dependency('sdeventplus'),
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500177 ],
178 install: true
179)
180
181executable(
182 'openpower-pnor-msl',
183 [
184 'msl_verify.cpp',
185 'msl_verify_main.cpp',
186 ],
187 dependencies: [
188 dependency('libsystemd'),
189 dependency('phosphor-dbus-interfaces'),
190 dependency('phosphor-logging'),
191 dependency('sdbusplus'),
192 ],
193 install: true
194)
195
196foreach s : extra_scripts
197 configure_file(
198 input: s,
199 copy: true,
200 install: true,
201 install_mode: 'rwxr-xr-x',
202 install_dir: get_option('bindir'),
203 output: '@BASENAME@'
204 )
205endforeach
206
207unit_files = [
208 'op-pnor-msl.service',
209 'org.open_power.Software.Host.Updater.service',
210] + extra_unit_files
211
Adriana Kobylak067876a2021-04-26 19:36:39 +0000212systemd_system_unit_dir = dependency('systemd').get_variable(
213 pkgconfig: 'systemdsystemunitdir',
214 pkgconfig_define: ['prefix', get_option('prefix')])
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500215foreach u : unit_files
216 configure_file(
217 input: u,
218 copy: true,
219 install: true,
220 install_dir: systemd_system_unit_dir,
221 output: '@BASENAME@.service'
222 )
223endforeach
224
Adriana Kobylak067876a2021-04-26 19:36:39 +0000225dbus_system_bus_services_dir = dependency('dbus-1').get_variable(
226 pkgconfig: 'system_bus_services_dir',
227 pkgconfig_define: ['prefix', get_option('prefix')])
Brad Bishop671a7da2020-11-15 13:31:05 -0500228dbus_policy_dir = run_command(
229 'realpath',
230 join_paths(dbus_system_bus_services_dir, '..', 'system.d')).stdout().strip()
231
232install_data(
233 'dbus/org.open_power.Software.Host.Updater.conf',
234 install_dir: dbus_policy_dir)
235
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500236if not get_option('tests').disabled()
Adriana Kobylak588a9fa2021-06-22 14:28:45 +0000237 oe_sdk = get_option('oe-sdk')
238 if oe_sdk.enabled()
239 # Setup OE SYSROOT
240 OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
241 if OECORE_TARGET_SYSROOT == ''
242 error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
243 endif
244 message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
245 rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
246 ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
247 dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
248 else
249 dynamic_linker = []
250 endif
251
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500252 test(
253 'utest',
254 executable(
255 'utest',
256 'activation.cpp',
257 'version.cpp',
258 'item_updater.cpp',
259 'image_verify.cpp',
260 'utils.cpp',
261 'msl_verify.cpp',
262 'ubi/activation_ubi.cpp',
263 'ubi/item_updater_ubi.cpp',
264 'ubi/serialize.cpp',
265 'ubi/watch.cpp',
266 'static/item_updater_static.cpp',
267 'static/activation_static.cpp',
268 'test/test_signature.cpp',
269 'test/test_version.cpp',
270 'test/test_item_updater_static.cpp',
271 'msl_verify.cpp',
272 dependencies: [
273 dependency('libcrypto'),
274 dependency('gtest', main: true),
275 dependency('openssl'),
276 dependency('phosphor-logging'),
277 dependency('phosphor-dbus-interfaces'),
278 ],
279 implicit_include_directories: false,
280 include_directories: '.',
281 )
282 )
Brad Bishop099543e2020-11-09 15:37:58 -0500283 test(
284 'test_functions',
285 executable(
286 'test_functions',
287 'test/test_functions.cpp',
288 'functions.cpp',
289 dependencies: [
290 dependency('gtest', main: true),
291 dependency('sdbusplus'),
292 dependency('sdeventplus'),
293 ],
294 )
295 )
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500296endif