blob: 0a7a6a6c0941f279aa0a7871d50da2a1d9afd03a [file] [log] [blame]
Adriana Kobylak0af80a42020-05-05 13:32:10 -05001project('phosphor-bmc-code-mgmt', 'cpp',
2 default_options: [
Gunnar Millsf7a69e12020-06-15 12:16:51 -05003 'buildtype=debugoptimized',
4 'cpp_std=c++17',
Adriana Kobylak0af80a42020-05-05 13:32:10 -05005 'warning_level=3',
Gunnar Millsf7a69e12020-06-15 12:16:51 -05006 'werror=true'
Adriana Kobylak0af80a42020-05-05 13:32:10 -05007 ],
8 license: 'Apache-2.0',
9 version: '1.0')
10
11conf = configuration_data()
12
13# DBus information
14conf.set_quoted('BMC_INVENTORY_INTERFACE', 'xyz.openbmc_project.Inventory.Item.Bmc')
15conf.set_quoted('BUSNAME_UPDATER', 'xyz.openbmc_project.Software.BMC.Updater')
16conf.set_quoted('DOWNLOAD_BUSNAME', 'xyz.openbmc_project.Software.Download')
17conf.set_quoted('FILEPATH_IFACE', 'xyz.openbmc_project.Common.FilePath')
18conf.set_quoted('INVENTORY_PATH', '/xyz/openbmc_project/inventory/')
19conf.set_quoted('MAPPER_BUSNAME', 'xyz.openbmc_project.ObjectMapper')
20conf.set_quoted('MAPPER_INTERFACE', 'xyz.openbmc_project.ObjectMapper')
21conf.set_quoted('MAPPER_PATH', '/xyz/openbmc_project/object_mapper')
22conf.set_quoted('SOFTWARE_OBJPATH', '/xyz/openbmc_project/software')
23conf.set_quoted('SYSTEMD_BUSNAME', 'org.freedesktop.systemd1')
24conf.set_quoted('SYSTEMD_PATH', '/org/freedesktop/systemd1')
25conf.set_quoted('SYSTEMD_INTERFACE', 'org.freedesktop.systemd1.Manager')
26conf.set_quoted('VERSION_BUSNAME', 'xyz.openbmc_project.Software.Version')
27conf.set_quoted('VERSION_IFACE', 'xyz.openbmc_project.Software.Version')
28
29# Names of the forward and reverse associations
30conf.set_quoted('ACTIVATION_FWD_ASSOCIATION', 'inventory')
31conf.set_quoted('ACTIVATION_REV_ASSOCIATION', 'activation')
32conf.set_quoted('ACTIVE_FWD_ASSOCIATION', 'active')
33conf.set_quoted('ACTIVE_REV_ASSOCIATION', 'software_version')
34conf.set_quoted('FUNCTIONAL_FWD_ASSOCIATION', 'functional')
35conf.set_quoted('FUNCTIONAL_REV_ASSOCIATION', 'software_version')
36conf.set_quoted('UPDATEABLE_FWD_ASSOCIATION', 'updateable')
37conf.set_quoted('UPDATEABLE_REV_ASSOCIATION', 'software_version')
38
39# Filesystem files and directories
40# The path of the alt rwfs overlay
41conf.set_quoted('ALT_RWFS', '/media/alt/var/persist')
42# The prefix path for the versioned read-only bmc partitions
43conf.set_quoted('BMC_ROFS_PREFIX', get_option('media-dir') + '/rofs-')
44# The name of the BMC table of contents file
45conf.set_quoted('OS_RELEASE_FILE', '/etc/os-release')
46# The dir where activation data is stored in files
47conf.set_quoted('PERSIST_DIR', '/var/lib/phosphor-bmc-code-mgmt/')
48
49# Supported BMC layout types
50conf.set('STATIC_LAYOUT', get_option('bmc-layout').contains('static'))
51conf.set('UBIFS_LAYOUT', get_option('bmc-layout').contains('ubi'))
Adriana Kobylak70f5bc02020-05-13 14:08:14 -050052conf.set('MMC_LAYOUT', get_option('bmc-layout').contains('mmc'))
Adriana Kobylak0af80a42020-05-05 13:32:10 -050053
54# Configurable features
55conf.set('HOST_BIOS_UPGRADE', get_option('host-bios-upgrade').enabled())
Adriana Kobylak42bd9932021-01-28 09:45:24 -060056conf.set('WANT_SIGNATURE_VERIFY', \
57 get_option('verify-signature').enabled() or \
58 get_option('verify-full-signature').enabled())
George Liu0a06e972020-12-17 09:17:04 +080059conf.set('WANT_SIGNATURE_FULL_VERIFY', get_option('verify-full-signature').enabled())
Adriana Kobylak0af80a42020-05-05 13:32:10 -050060
61# Configurable variables
62conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed'))
63conf.set_quoted('HASH_FILE_NAME', get_option('hash-file-name'))
64conf.set_quoted('IMG_UPLOAD_DIR', get_option('img-upload-dir'))
65conf.set_quoted('MANIFEST_FILE_NAME', get_option('manifest-file-name'))
66conf.set_quoted('MEDIA_DIR', get_option('media-dir'))
Adriana Kobylak73609bb2020-06-18 15:05:40 -050067optional_array = get_option('optional-images')
68optional_images = ''
69foreach optiona_image : optional_array
70 optional_images = ' '.join([optional_images, optiona_image])
71endforeach
72conf.set_quoted('OPTIONAL_IMAGES', optional_images)
Adriana Kobylak0af80a42020-05-05 13:32:10 -050073conf.set_quoted('PUBLICKEY_FILE_NAME', get_option('publickey-file-name'))
74conf.set_quoted('SIGNATURE_FILE_EXT', get_option('signature-file-ext'))
75conf.set_quoted('SIGNED_IMAGE_CONF_PATH', get_option('signed-image-conf-path'))
76conf.set_quoted('SYNC_LIST_DIR_PATH', get_option('sync-list-dir-path'))
77conf.set_quoted('SYNC_LIST_FILE_NAME', get_option('sync-list-file-name'))
Miguel Gomez21dad042020-06-26 20:54:48 +000078conf.set_quoted('BMC_MSL', get_option('bmc-msl'))
79conf.set_quoted('REGEX_BMC_MSL', get_option('regex-bmc-msl'))
80
Adriana Kobylak0af80a42020-05-05 13:32:10 -050081
82configure_file(output: 'config.h', configuration: conf)
Adriana Kobylak113492e2020-05-05 13:45:45 -050083
Adriana Kobylake0aa7802020-05-05 13:54:49 -050084deps = [
85 dependency('phosphor-dbus-interfaces'),
86 dependency('phosphor-logging'),
87 dependency('sdbusplus')
88]
89
90ssl = dependency('openssl')
91
Adriana Kobylak29a0d902020-05-05 13:59:49 -050092systemd = dependency('systemd')
93systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
94
95unit_files = [
Adriana Kobylak436be812020-06-17 09:44:56 -050096 'obmc-flash-bmc-setenv@.service.in',
97 'reboot-guard-disable.service.in',
98 'reboot-guard-enable.service.in',
99 'force-reboot.service.in',
100 'usr-local.mount.in',
101 'xyz.openbmc_project.Software.BMC.Updater.service.in',
102 'xyz.openbmc_project.Software.Download.service.in',
103 'xyz.openbmc_project.Software.Sync.service.in',
104 'xyz.openbmc_project.Software.Version.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500105]
106
Adriana Kobylak113492e2020-05-05 13:45:45 -0500107sdbuspp = find_program('sdbus++')
108subdir('xyz/openbmc_project/Software/Image')
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500109
110image_updater_sources = files(
111 'activation.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500112 'images.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500113 'item_updater.cpp',
114 'item_updater_main.cpp',
115 'serialize.cpp',
116 'version.cpp',
Miguel Gomez21dad042020-06-26 20:54:48 +0000117 'utils.cpp',
118 'msl_verify.cpp'
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500119)
120
121if get_option('bmc-layout').contains('static')
Adriana Kobylak436be812020-06-17 09:44:56 -0500122 image_updater_sources += files(
123 'static/flash.cpp',
124 'static/item_updater_helper.cpp'
125 )
Adriana Kobylak86013f32020-05-13 12:12:38 -0500126elif get_option('bmc-layout').contains('ubi')
Adriana Kobylak436be812020-06-17 09:44:56 -0500127 image_updater_sources += files(
128 'ubi/flash.cpp',
129 'ubi/item_updater_helper.cpp'
130 )
131
132 unit_files += [
133 'ubi/obmc-flash-bmc-cleanup.service.in',
134 'ubi/obmc-flash-bmc-mirroruboot.service.in',
135 'ubi/obmc-flash-bmc-ubiremount.service.in',
136 'ubi/obmc-flash-bmc-ubiro@.service.in',
137 'ubi/obmc-flash-bmc-ubiro-remove@.service.in',
138 'ubi/obmc-flash-bmc-ubirw.service.in',
139 'ubi/obmc-flash-bmc-ubirw-remove.service.in',
140 'ubi/obmc-flash-bmc-updateubootvars@.service.in'
141 ]
Adriana Kobylak86013f32020-05-13 12:12:38 -0500142elif get_option('bmc-layout').contains('mmc')
Adriana Kobylak436be812020-06-17 09:44:56 -0500143 image_updater_sources += files(
144 'mmc/flash.cpp',
145 'mmc/item_updater_helper.cpp'
146 )
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500147
148 unit_files += [
149 'mmc/obmc-flash-mmc@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500150 'mmc/obmc-flash-mmc-mount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500151 'mmc/obmc-flash-mmc-remove@.service.in',
Adriana Kobylak34124352020-05-22 09:40:40 -0500152 'mmc/obmc-flash-mmc-setprimary@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500153 'mmc/obmc-flash-mmc-umount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500154 ]
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500155endif
156
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500157if get_option('host-bios-upgrade').enabled()
Adriana Kobylak436be812020-06-17 09:44:56 -0500158 unit_files += 'obmc-flash-host-bios@.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500159endif
160
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500161if get_option('sync-bmc-files').enabled()
162 executable(
163 'phosphor-sync-software-manager',
164 'sync_manager.cpp',
165 'sync_manager_main.cpp',
166 'sync_watch.cpp',
167 dependencies: deps,
168 install: true
169 )
Adriana Kobylak817209f2020-05-07 09:52:03 -0500170
171 install_data('synclist',
172 install_dir: get_option('sysconfdir')
173 )
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500174endif
175
Adriana Kobylak42bd9932021-01-28 09:45:24 -0600176if (get_option('verify-signature').enabled() or \
177 get_option('verify-full-signature').enabled())
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500178 image_updater_sources += files(
George Liu0a06e972020-12-17 09:17:04 +0800179 'utils.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500180 'image_verify.cpp',
181 'openssl_alloc.cpp'
182 )
183endif
184
185executable(
186 'phosphor-download-manager',
187 'download_manager.cpp',
188 'download_manager_main.cpp',
189 dependencies: deps,
190 install: true
191)
192
193executable(
194 'phosphor-image-updater',
195 image_error_cpp,
196 image_error_hpp,
197 image_updater_sources,
198 dependencies: [deps, ssl],
199 install: true
200)
201
202executable(
203 'phosphor-version-software-manager',
204 image_error_cpp,
205 image_error_hpp,
206 'image_manager.cpp',
207 'image_manager_main.cpp',
208 'version.cpp',
209 'watch.cpp',
210 dependencies: [deps, ssl],
211 install: true
212)
Adriana Kobylak817209f2020-05-07 09:52:03 -0500213
214install_data('obmc-flash-bmc',
215 install_mode: 'rwxr-xr-x',
216 install_dir: get_option('bindir')
217)
218
219install_data('software.conf',
220 install_dir: '/usr/lib/tmpfiles.d/'
221)
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500222
223foreach u : unit_files
224 configure_file(
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500225 input: u,
Adriana Kobylak436be812020-06-17 09:44:56 -0500226 output: '@BASENAME@',
227 configuration: conf,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500228 install: true,
229 install_dir: systemd_system_unit_dir,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500230 )
231endforeach
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500232
233# If test coverage of source files within the root directory are wanted,
234# need to define and build the tests from here
235build_tests = get_option('tests')
236if not build_tests.disabled()
237 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
252 gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
253 include_srcs = declare_dependency(sources: [
George Liu0a06e972020-12-17 09:17:04 +0800254 'utils.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500255 'image_verify.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500256 'images.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500257 'version.cpp']
258 )
259
260 test('utest',
261 executable(
262 'utest',
263 './test/utest.cpp',
264 link_args: dynamic_linker,
265 build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
266 dependencies: [deps, gtest, include_srcs, ssl]
267 )
268)
269endif