blob: af82637e6615894a724dc182e6ba1b6f483d48fd [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'),
170 ],
171 install: true
172)
173
174executable(
175 'openpower-pnor-msl',
176 [
177 'msl_verify.cpp',
178 'msl_verify_main.cpp',
179 ],
180 dependencies: [
181 dependency('libsystemd'),
182 dependency('phosphor-dbus-interfaces'),
183 dependency('phosphor-logging'),
184 dependency('sdbusplus'),
185 ],
186 install: true
187)
188
189foreach s : extra_scripts
190 configure_file(
191 input: s,
192 copy: true,
193 install: true,
194 install_mode: 'rwxr-xr-x',
195 install_dir: get_option('bindir'),
196 output: '@BASENAME@'
197 )
198endforeach
199
200unit_files = [
201 'op-pnor-msl.service',
202 'org.open_power.Software.Host.Updater.service',
203] + extra_unit_files
204
205systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable(
206 'systemdsystemunitdir',
207 define_variable: ['prefix', get_option('prefix')])
208foreach u : unit_files
209 configure_file(
210 input: u,
211 copy: true,
212 install: true,
213 install_dir: systemd_system_unit_dir,
214 output: '@BASENAME@.service'
215 )
216endforeach
217
218if not get_option('tests').disabled()
219 test(
220 'utest',
221 executable(
222 'utest',
223 'activation.cpp',
224 'version.cpp',
225 'item_updater.cpp',
226 'image_verify.cpp',
227 'utils.cpp',
228 'msl_verify.cpp',
229 'ubi/activation_ubi.cpp',
230 'ubi/item_updater_ubi.cpp',
231 'ubi/serialize.cpp',
232 'ubi/watch.cpp',
233 'static/item_updater_static.cpp',
234 'static/activation_static.cpp',
235 'test/test_signature.cpp',
236 'test/test_version.cpp',
237 'test/test_item_updater_static.cpp',
238 'msl_verify.cpp',
239 dependencies: [
240 dependency('libcrypto'),
241 dependency('gtest', main: true),
242 dependency('openssl'),
243 dependency('phosphor-logging'),
244 dependency('phosphor-dbus-interfaces'),
245 ],
246 implicit_include_directories: false,
247 include_directories: '.',
248 )
249 )
250endif