blob: a6ebcc43c0ece795099ee3dc8eb63ff619497c1f [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')
Chanh Nguyen1fd6ddd2021-01-06 11:09:09 +070028conf.set_quoted('EXTENDED_VERSION_IFACE', 'xyz.openbmc_project.Software.ExtendedVersion')
Adriana Kobylak0af80a42020-05-05 13:32:10 -050029
30# Names of the forward and reverse associations
31conf.set_quoted('ACTIVATION_FWD_ASSOCIATION', 'inventory')
32conf.set_quoted('ACTIVATION_REV_ASSOCIATION', 'activation')
33conf.set_quoted('ACTIVE_FWD_ASSOCIATION', 'active')
34conf.set_quoted('ACTIVE_REV_ASSOCIATION', 'software_version')
35conf.set_quoted('FUNCTIONAL_FWD_ASSOCIATION', 'functional')
36conf.set_quoted('FUNCTIONAL_REV_ASSOCIATION', 'software_version')
37conf.set_quoted('UPDATEABLE_FWD_ASSOCIATION', 'updateable')
38conf.set_quoted('UPDATEABLE_REV_ASSOCIATION', 'software_version')
39
40# Filesystem files and directories
41# The path of the alt rwfs overlay
42conf.set_quoted('ALT_RWFS', '/media/alt/var/persist')
43# The prefix path for the versioned read-only bmc partitions
44conf.set_quoted('BMC_ROFS_PREFIX', get_option('media-dir') + '/rofs-')
45# The name of the BMC table of contents file
46conf.set_quoted('OS_RELEASE_FILE', '/etc/os-release')
47# The dir where activation data is stored in files
48conf.set_quoted('PERSIST_DIR', '/var/lib/phosphor-bmc-code-mgmt/')
49
50# Supported BMC layout types
51conf.set('STATIC_LAYOUT', get_option('bmc-layout').contains('static'))
52conf.set('UBIFS_LAYOUT', get_option('bmc-layout').contains('ubi'))
Adriana Kobylak70f5bc02020-05-13 14:08:14 -050053conf.set('MMC_LAYOUT', get_option('bmc-layout').contains('mmc'))
Adriana Kobylak0af80a42020-05-05 13:32:10 -050054
55# Configurable features
56conf.set('HOST_BIOS_UPGRADE', get_option('host-bios-upgrade').enabled())
Adriana Kobylak42bd9932021-01-28 09:45:24 -060057conf.set('WANT_SIGNATURE_VERIFY', \
58 get_option('verify-signature').enabled() or \
59 get_option('verify-full-signature').enabled())
George Liu0a06e972020-12-17 09:17:04 +080060conf.set('WANT_SIGNATURE_FULL_VERIFY', get_option('verify-full-signature').enabled())
Adriana Kobylak0af80a42020-05-05 13:32:10 -050061
62# Configurable variables
63conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed'))
64conf.set_quoted('HASH_FILE_NAME', get_option('hash-file-name'))
65conf.set_quoted('IMG_UPLOAD_DIR', get_option('img-upload-dir'))
66conf.set_quoted('MANIFEST_FILE_NAME', get_option('manifest-file-name'))
67conf.set_quoted('MEDIA_DIR', get_option('media-dir'))
Adriana Kobylak73609bb2020-06-18 15:05:40 -050068optional_array = get_option('optional-images')
69optional_images = ''
70foreach optiona_image : optional_array
71 optional_images = ' '.join([optional_images, optiona_image])
72endforeach
73conf.set_quoted('OPTIONAL_IMAGES', optional_images)
Adriana Kobylak0af80a42020-05-05 13:32:10 -050074conf.set_quoted('PUBLICKEY_FILE_NAME', get_option('publickey-file-name'))
75conf.set_quoted('SIGNATURE_FILE_EXT', get_option('signature-file-ext'))
76conf.set_quoted('SIGNED_IMAGE_CONF_PATH', get_option('signed-image-conf-path'))
77conf.set_quoted('SYNC_LIST_DIR_PATH', get_option('sync-list-dir-path'))
78conf.set_quoted('SYNC_LIST_FILE_NAME', get_option('sync-list-file-name'))
Miguel Gomez21dad042020-06-26 20:54:48 +000079conf.set_quoted('BMC_MSL', get_option('bmc-msl'))
80conf.set_quoted('REGEX_BMC_MSL', get_option('regex-bmc-msl'))
81
Lei YU6e9fb1d2021-02-19 18:01:40 +080082if get_option('host-bios-upgrade').enabled()
83 conf.set_quoted('BIOS_OBJPATH', get_option('bios-object-path'))
84endif
Adriana Kobylak0af80a42020-05-05 13:32:10 -050085
86configure_file(output: 'config.h', configuration: conf)
Adriana Kobylak113492e2020-05-05 13:45:45 -050087
Adriana Kobylake0aa7802020-05-05 13:54:49 -050088deps = [
89 dependency('phosphor-dbus-interfaces'),
90 dependency('phosphor-logging'),
91 dependency('sdbusplus')
92]
93
94ssl = dependency('openssl')
95
Adriana Kobylak29a0d902020-05-05 13:59:49 -050096systemd = dependency('systemd')
97systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
98
99unit_files = [
Adriana Kobylak436be812020-06-17 09:44:56 -0500100 'obmc-flash-bmc-setenv@.service.in',
101 'reboot-guard-disable.service.in',
102 'reboot-guard-enable.service.in',
103 'force-reboot.service.in',
104 'usr-local.mount.in',
105 'xyz.openbmc_project.Software.BMC.Updater.service.in',
106 'xyz.openbmc_project.Software.Download.service.in',
107 'xyz.openbmc_project.Software.Sync.service.in',
108 'xyz.openbmc_project.Software.Version.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500109]
110
Adriana Kobylak113492e2020-05-05 13:45:45 -0500111sdbuspp = find_program('sdbus++')
112subdir('xyz/openbmc_project/Software/Image')
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500113
114image_updater_sources = files(
115 'activation.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500116 'images.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500117 'item_updater.cpp',
118 'item_updater_main.cpp',
119 'serialize.cpp',
120 'version.cpp',
Miguel Gomez21dad042020-06-26 20:54:48 +0000121 'utils.cpp',
122 'msl_verify.cpp'
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500123)
124
125if get_option('bmc-layout').contains('static')
Adriana Kobylak436be812020-06-17 09:44:56 -0500126 image_updater_sources += files(
127 'static/flash.cpp',
128 'static/item_updater_helper.cpp'
129 )
Adriana Kobylak86013f32020-05-13 12:12:38 -0500130elif get_option('bmc-layout').contains('ubi')
Adriana Kobylak436be812020-06-17 09:44:56 -0500131 image_updater_sources += files(
132 'ubi/flash.cpp',
133 'ubi/item_updater_helper.cpp'
134 )
135
136 unit_files += [
137 'ubi/obmc-flash-bmc-cleanup.service.in',
138 'ubi/obmc-flash-bmc-mirroruboot.service.in',
139 'ubi/obmc-flash-bmc-ubiremount.service.in',
140 'ubi/obmc-flash-bmc-ubiro@.service.in',
141 'ubi/obmc-flash-bmc-ubiro-remove@.service.in',
142 'ubi/obmc-flash-bmc-ubirw.service.in',
143 'ubi/obmc-flash-bmc-ubirw-remove.service.in',
144 'ubi/obmc-flash-bmc-updateubootvars@.service.in'
145 ]
Adriana Kobylak86013f32020-05-13 12:12:38 -0500146elif get_option('bmc-layout').contains('mmc')
Adriana Kobylak436be812020-06-17 09:44:56 -0500147 image_updater_sources += files(
148 'mmc/flash.cpp',
149 'mmc/item_updater_helper.cpp'
150 )
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500151
152 unit_files += [
153 'mmc/obmc-flash-mmc@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500154 'mmc/obmc-flash-mmc-mount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500155 'mmc/obmc-flash-mmc-remove@.service.in',
Adriana Kobylak34124352020-05-22 09:40:40 -0500156 'mmc/obmc-flash-mmc-setprimary@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500157 'mmc/obmc-flash-mmc-umount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500158 ]
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500159endif
160
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500161if get_option('host-bios-upgrade').enabled()
Adriana Kobylak436be812020-06-17 09:44:56 -0500162 unit_files += 'obmc-flash-host-bios@.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500163endif
164
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500165if get_option('sync-bmc-files').enabled()
166 executable(
167 'phosphor-sync-software-manager',
168 'sync_manager.cpp',
169 'sync_manager_main.cpp',
170 'sync_watch.cpp',
171 dependencies: deps,
172 install: true
173 )
Adriana Kobylak817209f2020-05-07 09:52:03 -0500174
175 install_data('synclist',
176 install_dir: get_option('sysconfdir')
177 )
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500178endif
179
Adriana Kobylak42bd9932021-01-28 09:45:24 -0600180if (get_option('verify-signature').enabled() or \
181 get_option('verify-full-signature').enabled())
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500182 image_updater_sources += files(
George Liu0a06e972020-12-17 09:17:04 +0800183 'utils.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500184 'image_verify.cpp',
185 'openssl_alloc.cpp'
186 )
187endif
188
189executable(
190 'phosphor-download-manager',
191 'download_manager.cpp',
192 'download_manager_main.cpp',
193 dependencies: deps,
194 install: true
195)
196
197executable(
198 'phosphor-image-updater',
199 image_error_cpp,
200 image_error_hpp,
201 image_updater_sources,
202 dependencies: [deps, ssl],
203 install: true
204)
205
206executable(
207 'phosphor-version-software-manager',
208 image_error_cpp,
209 image_error_hpp,
210 'image_manager.cpp',
211 'image_manager_main.cpp',
212 'version.cpp',
213 'watch.cpp',
214 dependencies: [deps, ssl],
215 install: true
216)
Adriana Kobylak817209f2020-05-07 09:52:03 -0500217
218install_data('obmc-flash-bmc',
219 install_mode: 'rwxr-xr-x',
220 install_dir: get_option('bindir')
221)
222
223install_data('software.conf',
224 install_dir: '/usr/lib/tmpfiles.d/'
225)
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500226
227foreach u : unit_files
228 configure_file(
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500229 input: u,
Adriana Kobylak436be812020-06-17 09:44:56 -0500230 output: '@BASENAME@',
231 configuration: conf,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500232 install: true,
233 install_dir: systemd_system_unit_dir,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500234 )
235endforeach
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500236
237# If test coverage of source files within the root directory are wanted,
238# need to define and build the tests from here
239build_tests = get_option('tests')
240if not build_tests.disabled()
241 oe_sdk = get_option('oe-sdk')
242 if oe_sdk.enabled()
243 # Setup OE SYSROOT
244 OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
245 if OECORE_TARGET_SYSROOT == ''
246 error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
247 endif
248 message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
249 rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
250 ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
251 dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
252 else
253 dynamic_linker = []
254 endif
255
256 gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
257 include_srcs = declare_dependency(sources: [
George Liu0a06e972020-12-17 09:17:04 +0800258 'utils.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500259 'image_verify.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500260 'images.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500261 'version.cpp']
262 )
263
264 test('utest',
265 executable(
266 'utest',
267 './test/utest.cpp',
268 link_args: dynamic_linker,
269 build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
270 dependencies: [deps, gtest, include_srcs, ssl]
271 )
272)
273endif