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