blob: 0e8a3c01b87222d7401476556b87ed98519f9825 [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
Adriana Kobylak0af80a42020-05-05 13:32:10 -050082
83configure_file(output: 'config.h', configuration: conf)
Adriana Kobylak113492e2020-05-05 13:45:45 -050084
Adriana Kobylake0aa7802020-05-05 13:54:49 -050085deps = [
86 dependency('phosphor-dbus-interfaces'),
87 dependency('phosphor-logging'),
88 dependency('sdbusplus')
89]
90
91ssl = dependency('openssl')
92
Adriana Kobylak29a0d902020-05-05 13:59:49 -050093systemd = dependency('systemd')
94systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
95
96unit_files = [
Adriana Kobylak436be812020-06-17 09:44:56 -050097 'obmc-flash-bmc-setenv@.service.in',
98 'reboot-guard-disable.service.in',
99 'reboot-guard-enable.service.in',
100 'force-reboot.service.in',
101 'usr-local.mount.in',
102 'xyz.openbmc_project.Software.BMC.Updater.service.in',
103 'xyz.openbmc_project.Software.Download.service.in',
104 'xyz.openbmc_project.Software.Sync.service.in',
105 'xyz.openbmc_project.Software.Version.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500106]
107
Adriana Kobylak113492e2020-05-05 13:45:45 -0500108sdbuspp = find_program('sdbus++')
109subdir('xyz/openbmc_project/Software/Image')
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500110
111image_updater_sources = files(
112 'activation.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500113 'images.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500114 'item_updater.cpp',
115 'item_updater_main.cpp',
116 'serialize.cpp',
117 'version.cpp',
Miguel Gomez21dad042020-06-26 20:54:48 +0000118 'utils.cpp',
119 'msl_verify.cpp'
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500120)
121
122if get_option('bmc-layout').contains('static')
Adriana Kobylak436be812020-06-17 09:44:56 -0500123 image_updater_sources += files(
124 'static/flash.cpp',
125 'static/item_updater_helper.cpp'
126 )
Adriana Kobylak86013f32020-05-13 12:12:38 -0500127elif get_option('bmc-layout').contains('ubi')
Adriana Kobylak436be812020-06-17 09:44:56 -0500128 image_updater_sources += files(
129 'ubi/flash.cpp',
130 'ubi/item_updater_helper.cpp'
131 )
132
133 unit_files += [
134 'ubi/obmc-flash-bmc-cleanup.service.in',
135 'ubi/obmc-flash-bmc-mirroruboot.service.in',
136 'ubi/obmc-flash-bmc-ubiremount.service.in',
137 'ubi/obmc-flash-bmc-ubiro@.service.in',
138 'ubi/obmc-flash-bmc-ubiro-remove@.service.in',
139 'ubi/obmc-flash-bmc-ubirw.service.in',
140 'ubi/obmc-flash-bmc-ubirw-remove.service.in',
141 'ubi/obmc-flash-bmc-updateubootvars@.service.in'
142 ]
Adriana Kobylak86013f32020-05-13 12:12:38 -0500143elif get_option('bmc-layout').contains('mmc')
Adriana Kobylak436be812020-06-17 09:44:56 -0500144 image_updater_sources += files(
145 'mmc/flash.cpp',
146 'mmc/item_updater_helper.cpp'
147 )
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500148
149 unit_files += [
150 'mmc/obmc-flash-mmc@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500151 'mmc/obmc-flash-mmc-mount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500152 'mmc/obmc-flash-mmc-remove@.service.in',
Adriana Kobylak34124352020-05-22 09:40:40 -0500153 'mmc/obmc-flash-mmc-setprimary@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500154 'mmc/obmc-flash-mmc-umount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500155 ]
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500156endif
157
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500158if get_option('host-bios-upgrade').enabled()
Adriana Kobylak436be812020-06-17 09:44:56 -0500159 unit_files += 'obmc-flash-host-bios@.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500160endif
161
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500162if get_option('sync-bmc-files').enabled()
163 executable(
164 'phosphor-sync-software-manager',
165 'sync_manager.cpp',
166 'sync_manager_main.cpp',
167 'sync_watch.cpp',
168 dependencies: deps,
169 install: true
170 )
Adriana Kobylak817209f2020-05-07 09:52:03 -0500171
172 install_data('synclist',
173 install_dir: get_option('sysconfdir')
174 )
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500175endif
176
Adriana Kobylak42bd9932021-01-28 09:45:24 -0600177if (get_option('verify-signature').enabled() or \
178 get_option('verify-full-signature').enabled())
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500179 image_updater_sources += files(
George Liu0a06e972020-12-17 09:17:04 +0800180 'utils.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500181 'image_verify.cpp',
182 'openssl_alloc.cpp'
183 )
184endif
185
186executable(
187 'phosphor-download-manager',
188 'download_manager.cpp',
189 'download_manager_main.cpp',
190 dependencies: deps,
191 install: true
192)
193
194executable(
195 'phosphor-image-updater',
196 image_error_cpp,
197 image_error_hpp,
198 image_updater_sources,
199 dependencies: [deps, ssl],
200 install: true
201)
202
203executable(
204 'phosphor-version-software-manager',
205 image_error_cpp,
206 image_error_hpp,
207 'image_manager.cpp',
208 'image_manager_main.cpp',
209 'version.cpp',
210 'watch.cpp',
211 dependencies: [deps, ssl],
212 install: true
213)
Adriana Kobylak817209f2020-05-07 09:52:03 -0500214
215install_data('obmc-flash-bmc',
216 install_mode: 'rwxr-xr-x',
217 install_dir: get_option('bindir')
218)
219
220install_data('software.conf',
221 install_dir: '/usr/lib/tmpfiles.d/'
222)
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500223
224foreach u : unit_files
225 configure_file(
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500226 input: u,
Adriana Kobylak436be812020-06-17 09:44:56 -0500227 output: '@BASENAME@',
228 configuration: conf,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500229 install: true,
230 install_dir: systemd_system_unit_dir,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500231 )
232endforeach
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500233
234# If test coverage of source files within the root directory are wanted,
235# need to define and build the tests from here
236build_tests = get_option('tests')
237if not build_tests.disabled()
238 oe_sdk = get_option('oe-sdk')
239 if oe_sdk.enabled()
240 # Setup OE SYSROOT
241 OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
242 if OECORE_TARGET_SYSROOT == ''
243 error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
244 endif
245 message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
246 rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
247 ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
248 dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
249 else
250 dynamic_linker = []
251 endif
252
253 gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
254 include_srcs = declare_dependency(sources: [
George Liu0a06e972020-12-17 09:17:04 +0800255 'utils.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500256 'image_verify.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500257 'images.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500258 'version.cpp']
259 )
260
261 test('utest',
262 executable(
263 'utest',
264 './test/utest.cpp',
265 link_args: dynamic_linker,
266 build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
267 dependencies: [deps, gtest, include_srcs, ssl]
268 )
269)
270endif