blob: 12ff150d77cac4dfd93baf263b24d895e3462ed8 [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',
7 'cpp_std=c++17',
8 'buildtype=debugoptimized',
9 'b_ndebug=if-release',
10 'b_lto=true',
11 ],
12 license: 'Apache-2.0',
13 version: '1.0',
14)
15
16if get_option('cpp_std') != 'c++17'
17 error('This project requires c++17')
18endif
19
20if(get_option('buildtype') == 'minsize')
21 add_project_arguments('-DNDEBUG', language : 'cpp')
22endif
23
24# Disable lto when compiling with no optimization
25if(get_option('optimization') == '0')
26 add_project_arguments('-fno-lto', language: 'cpp')
27 message('Disabling lto because optimization is disabled')
28endif
29
Brad Bishop099543e2020-11-09 15:37:58 -050030cxx = meson.get_compiler('cpp')
31
Brad Bishopa0fa15b2020-11-06 14:42:24 -050032extra_sources = []
33extra_unit_files = []
34extra_scripts = []
35
36build_vpnor = get_option('vpnor').enabled()
37build_verify_signature = get_option('verify-signature').enabled()
38
Brad Bishop099543e2020-11-09 15:37:58 -050039if not cxx.has_header('CLI/CLI.hpp')
40 error('Could not find CLI.hpp')
41endif
42
Brad Bishopa0fa15b2020-11-06 14:42:24 -050043summary('building for device type', '@0@'.format(get_option('device-type')))
44summary('building vpnor', build_vpnor)
45summary('building signature verify', build_verify_signature)
46
47subs = configuration_data()
48subs.set_quoted('ACTIVATION_FWD_ASSOCIATION', 'inventory')
49subs.set_quoted('ACTIVATION_REV_ASSOCIATION', 'activation')
50subs.set_quoted('ACTIVE_FWD_ASSOCIATION', 'active')
51subs.set('ACTIVE_PNOR_MAX_ALLOWED', 2)
52subs.set_quoted('ACTIVE_REV_ASSOCIATION', 'software_version')
53subs.set_quoted('ASSOCIATIONS_INTERFACE', 'xyz.openbmc_project.Association.Definitions')
Brad Bishop7c053c32020-11-16 12:58:11 -050054subs.set_quoted('BUSNAME_UPDATER', 'org.open_power.Software.Host.Updater')
Brad Bishopa0fa15b2020-11-06 14:42:24 -050055subs.set_quoted('CHASSIS_STATE_OBJ', 'xyz.openbmc_project.State.Chassis')
56subs.set_quoted('CHASSIS_STATE_OFF', 'xyz.openbmc_project.State.Chassis.PowerState.Off')
57subs.set_quoted('CHASSIS_STATE_PATH', '/xyz/openbmc_project/state/chassis0')
58subs.set_quoted('FILEPATH_IFACE', 'xyz.openbmc_project.Common.FilePath')
59subs.set_quoted('FUNCTIONAL_FWD_ASSOCIATION', 'functional')
60subs.set_quoted('FUNCTIONAL_REV_ASSOCIATION', 'software_version')
61subs.set_quoted('HASH_FILE_NAME', 'hashfunc')
62subs.set_quoted('HOST_INVENTORY_PATH', '/xyz/openbmc_project/inventory/system/chassis')
63subs.set_quoted('IMG_DIR', '/tmp/images')
64subs.set_quoted('MANIFEST_FILE', 'MANIFEST')
65subs.set_quoted('MAPPER_BUSNAME', 'xyz.openbmc_project.ObjectMapper')
66subs.set_quoted('MAPPER_INTERFACE', 'xyz.openbmc_project.ObjectMapper')
67subs.set_quoted('MAPPER_PATH', '/xyz/openbmc_project/object_mapper')
68subs.set_quoted('MEDIA_DIR', '/media/')
69subs.set('MMC_LAYOUT', get_option('device-type') == 'mmc')
70subs.set_quoted('PERSIST_DIR', '/var/lib/obmc/openpower-pnor-code-mgmt/')
71subs.set_quoted('PNOR_ACTIVE_PATH', '/var/lib/phosphor-software-manager/pnor/')
72subs.set_quoted('PNOR_MSL', get_option('msl'))
73subs.set_quoted('PNOR_PRSV', '/media/pnor-prsv')
74subs.set_quoted('PNOR_PRSV_ACTIVE_PATH', '/var/lib/phosphor-software-manager/pnor/prsv')
75subs.set_quoted('PNOR_RO_ACTIVE_PATH', '/var/lib/phosphor-software-manager/pnor/ro')
76subs.set_quoted('PNOR_RO_PREFIX', '/media/pnor-ro-')
77subs.set_quoted('PNOR_RW_ACTIVE_PATH', '/var/lib/phosphor-software-manager/pnor/rw')
78subs.set_quoted('PNOR_RW_PREFIX', '/media/pnor-rw-')
79subs.set_quoted('PNOR_SIGNED_IMAGE_CONF_PATH', '/etc/activationdata/')
80subs.set_quoted('PNOR_TOC_FILE', 'pnor.toc')
81subs.set_quoted('PNOR_VERSION_PARTITION', 'VERSION')
82subs.set_quoted('PUBLICKEY_FILE_NAME', 'publickey')
83subs.set_quoted('SIGNATURE_FILE_EXT', '.sig')
84subs.set_quoted('SOFTWARE_OBJPATH', '/xyz/openbmc_project/software')
85subs.set_quoted('SYSTEMD_BUSNAME', 'org.freedesktop.systemd1')
86subs.set_quoted('SYSTEMD_INTERFACE', 'org.freedesktop.systemd1.Manager')
87subs.set_quoted('SYSTEMD_PATH', '/org/freedesktop/systemd1')
88subs.set_quoted('SYSTEMD_PROPERTY_INTERFACE', 'org.freedesktop.DBus.Properties')
89subs.set('UBIFS_LAYOUT', get_option('device-type') == 'ubi')
90subs.set_quoted('UPDATEABLE_FWD_ASSOCIATION', 'updateable')
91subs.set_quoted('UPDATEABLE_REV_ASSOCIATION', 'software_version')
92subs.set_quoted('VERSION_IFACE', 'xyz.openbmc_project.Software.Version')
93subs.set('WANT_SIGNATURE_VERIFY', build_verify_signature)
94configure_file(
95 output: 'config.h',
96 configuration: subs)
97
98if get_option('device-type') == 'ubi'
99 extra_sources += [
100 'ubi/activation_ubi.cpp',
101 'ubi/item_updater_ubi.cpp',
102 'ubi/serialize.cpp',
103 'ubi/watch.cpp',
104 ]
105 extra_scripts += [
106 'ubi/obmc-flash-bios',
107 ]
108 extra_unit_files += [
109 'ubi/obmc-flash-bios-cleanup.service',
110 'ubi/obmc-flash-bios-ubiattach.service',
111 'ubi/obmc-flash-bios-ubimount@.service',
112 'ubi/obmc-flash-bios-ubipatch.service',
113 'ubi/obmc-flash-bios-ubiremount.service',
114 'ubi/obmc-flash-bios-ubiumount-ro@.service',
115 'ubi/obmc-flash-bios-ubiumount-rw@.service',
116 ]
117endif
118
119if get_option('device-type') == 'mmc'
120 extra_sources += [
121 'mmc/activation_mmc.cpp',
122 'mmc/item_updater_mmc.cpp',
123 ]
124 extra_scripts += [
125 'mmc/obmc-flash-bios',
126 ]
127 extra_unit_files += [
128 'mmc/obmc-flash-bios-init.service',
129 'mmc/obmc-flash-bios-patch.service',
130 ]
131endif
132
133if get_option('device-type') == 'static'
134 extra_sources += [
135 'static/item_updater_static.cpp',
136 'static/activation_static.cpp',
137 ]
138 extra_unit_files += [
139 'openpower-pnor-update@.service',
140 ]
141endif
142
143if build_verify_signature
144 extra_sources += [
145 'image_verify.cpp'
146 ]
147endif
148
149if build_vpnor
150 extra_scripts += [
151 'vpnor/obmc-vpnor-util',
152 ]
153 extra_unit_files += [
154 'vpnor/obmc-vpnor-check-clearvolatile@.service',
155 'vpnor/obmc-vpnor-enable-clearvolatile@.service',
156 'vpnor/obmc-vpnor-updatesymlinks.service',
157 ]
158endif
159
160executable(
161 'openpower-update-manager',
162 [
163 'activation.cpp',
Brad Bishop099543e2020-11-09 15:37:58 -0500164 'functions.cpp',
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500165 'version.cpp',
166 'item_updater.cpp',
167 'item_updater_main.cpp',
168 'utils.cpp',
169 ] + extra_sources,
170 dependencies: [
171 dependency('libcrypto'),
172 dependency('libsystemd'),
173 dependency('openssl'),
174 dependency('phosphor-dbus-interfaces'),
175 dependency('phosphor-logging'),
176 dependency('sdbusplus'),
Brad Bishop0283f7c2020-11-09 10:09:26 -0500177 dependency('sdeventplus'),
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500178 ],
179 install: true
180)
181
182executable(
183 'openpower-pnor-msl',
184 [
185 'msl_verify.cpp',
186 'msl_verify_main.cpp',
187 ],
188 dependencies: [
189 dependency('libsystemd'),
190 dependency('phosphor-dbus-interfaces'),
191 dependency('phosphor-logging'),
192 dependency('sdbusplus'),
193 ],
194 install: true
195)
196
197foreach s : extra_scripts
198 configure_file(
199 input: s,
200 copy: true,
201 install: true,
202 install_mode: 'rwxr-xr-x',
203 install_dir: get_option('bindir'),
204 output: '@BASENAME@'
205 )
206endforeach
207
208unit_files = [
209 'op-pnor-msl.service',
210 'org.open_power.Software.Host.Updater.service',
211] + extra_unit_files
212
213systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable(
214 'systemdsystemunitdir',
215 define_variable: ['prefix', get_option('prefix')])
216foreach u : unit_files
217 configure_file(
218 input: u,
219 copy: true,
220 install: true,
221 install_dir: systemd_system_unit_dir,
222 output: '@BASENAME@.service'
223 )
224endforeach
225
226if not get_option('tests').disabled()
227 test(
228 'utest',
229 executable(
230 'utest',
231 'activation.cpp',
232 'version.cpp',
233 'item_updater.cpp',
234 'image_verify.cpp',
235 'utils.cpp',
236 'msl_verify.cpp',
237 'ubi/activation_ubi.cpp',
238 'ubi/item_updater_ubi.cpp',
239 'ubi/serialize.cpp',
240 'ubi/watch.cpp',
241 'static/item_updater_static.cpp',
242 'static/activation_static.cpp',
243 'test/test_signature.cpp',
244 'test/test_version.cpp',
245 'test/test_item_updater_static.cpp',
246 'msl_verify.cpp',
247 dependencies: [
248 dependency('libcrypto'),
249 dependency('gtest', main: true),
250 dependency('openssl'),
251 dependency('phosphor-logging'),
252 dependency('phosphor-dbus-interfaces'),
253 ],
254 implicit_include_directories: false,
255 include_directories: '.',
256 )
257 )
Brad Bishop099543e2020-11-09 15:37:58 -0500258 test(
259 'test_functions',
260 executable(
261 'test_functions',
262 'test/test_functions.cpp',
263 'functions.cpp',
264 dependencies: [
265 dependency('gtest', main: true),
266 dependency('sdbusplus'),
267 dependency('sdeventplus'),
268 ],
269 )
270 )
Brad Bishopa0fa15b2020-11-06 14:42:24 -0500271endif