blob: 29939ede27f90e7aa9b86f9a0678c796536ad41b [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
Lei YU25868182021-05-14 14:50:51 +080011add_project_arguments(
12 '-DBOOST_SYSTEM_NO_DEPRECATED',
13 '-DBOOST_ERROR_CODE_HEADER_ONLY',
14 '-DBOOST_NO_RTTI',
15 '-DBOOST_NO_TYPEID',
16 '-DBOOST_ALL_NO_LIB',
17 '-DBOOST_ASIO_DISABLE_THREADS',
18 '-DBOOST_ASIO_NO_DEPRECATED',
19 language: 'cpp',
20)
21
Adriana Kobylak0af80a42020-05-05 13:32:10 -050022conf = configuration_data()
23
24# DBus information
25conf.set_quoted('BMC_INVENTORY_INTERFACE', 'xyz.openbmc_project.Inventory.Item.Bmc')
26conf.set_quoted('BUSNAME_UPDATER', 'xyz.openbmc_project.Software.BMC.Updater')
27conf.set_quoted('DOWNLOAD_BUSNAME', 'xyz.openbmc_project.Software.Download')
28conf.set_quoted('FILEPATH_IFACE', 'xyz.openbmc_project.Common.FilePath')
29conf.set_quoted('INVENTORY_PATH', '/xyz/openbmc_project/inventory/')
30conf.set_quoted('MAPPER_BUSNAME', 'xyz.openbmc_project.ObjectMapper')
31conf.set_quoted('MAPPER_INTERFACE', 'xyz.openbmc_project.ObjectMapper')
32conf.set_quoted('MAPPER_PATH', '/xyz/openbmc_project/object_mapper')
33conf.set_quoted('SOFTWARE_OBJPATH', '/xyz/openbmc_project/software')
34conf.set_quoted('SYSTEMD_BUSNAME', 'org.freedesktop.systemd1')
35conf.set_quoted('SYSTEMD_PATH', '/org/freedesktop/systemd1')
36conf.set_quoted('SYSTEMD_INTERFACE', 'org.freedesktop.systemd1.Manager')
37conf.set_quoted('VERSION_BUSNAME', 'xyz.openbmc_project.Software.Version')
38conf.set_quoted('VERSION_IFACE', 'xyz.openbmc_project.Software.Version')
Chanh Nguyen1fd6ddd2021-01-06 11:09:09 +070039conf.set_quoted('EXTENDED_VERSION_IFACE', 'xyz.openbmc_project.Software.ExtendedVersion')
Adriana Kobylak0af80a42020-05-05 13:32:10 -050040
41# Names of the forward and reverse associations
42conf.set_quoted('ACTIVATION_FWD_ASSOCIATION', 'inventory')
43conf.set_quoted('ACTIVATION_REV_ASSOCIATION', 'activation')
44conf.set_quoted('ACTIVE_FWD_ASSOCIATION', 'active')
45conf.set_quoted('ACTIVE_REV_ASSOCIATION', 'software_version')
46conf.set_quoted('FUNCTIONAL_FWD_ASSOCIATION', 'functional')
47conf.set_quoted('FUNCTIONAL_REV_ASSOCIATION', 'software_version')
48conf.set_quoted('UPDATEABLE_FWD_ASSOCIATION', 'updateable')
49conf.set_quoted('UPDATEABLE_REV_ASSOCIATION', 'software_version')
50
51# Filesystem files and directories
52# The path of the alt rwfs overlay
53conf.set_quoted('ALT_RWFS', '/media/alt/var/persist')
54# The prefix path for the versioned read-only bmc partitions
55conf.set_quoted('BMC_ROFS_PREFIX', get_option('media-dir') + '/rofs-')
56# The name of the BMC table of contents file
57conf.set_quoted('OS_RELEASE_FILE', '/etc/os-release')
58# The dir where activation data is stored in files
59conf.set_quoted('PERSIST_DIR', '/var/lib/phosphor-bmc-code-mgmt/')
60
61# Supported BMC layout types
62conf.set('STATIC_LAYOUT', get_option('bmc-layout').contains('static'))
63conf.set('UBIFS_LAYOUT', get_option('bmc-layout').contains('ubi'))
Adriana Kobylak70f5bc02020-05-13 14:08:14 -050064conf.set('MMC_LAYOUT', get_option('bmc-layout').contains('mmc'))
Adriana Kobylak0af80a42020-05-05 13:32:10 -050065
66# Configurable features
67conf.set('HOST_BIOS_UPGRADE', get_option('host-bios-upgrade').enabled())
Adriana Kobylak42bd9932021-01-28 09:45:24 -060068conf.set('WANT_SIGNATURE_VERIFY', \
69 get_option('verify-signature').enabled() or \
70 get_option('verify-full-signature').enabled())
George Liu0a06e972020-12-17 09:17:04 +080071conf.set('WANT_SIGNATURE_FULL_VERIFY', get_option('verify-full-signature').enabled())
Adriana Kobylak0af80a42020-05-05 13:32:10 -050072
73# Configurable variables
74conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed'))
75conf.set_quoted('HASH_FILE_NAME', get_option('hash-file-name'))
76conf.set_quoted('IMG_UPLOAD_DIR', get_option('img-upload-dir'))
77conf.set_quoted('MANIFEST_FILE_NAME', get_option('manifest-file-name'))
78conf.set_quoted('MEDIA_DIR', get_option('media-dir'))
Adriana Kobylak73609bb2020-06-18 15:05:40 -050079optional_array = get_option('optional-images')
80optional_images = ''
81foreach optiona_image : optional_array
82 optional_images = ' '.join([optional_images, optiona_image])
83endforeach
84conf.set_quoted('OPTIONAL_IMAGES', optional_images)
Adriana Kobylak0af80a42020-05-05 13:32:10 -050085conf.set_quoted('PUBLICKEY_FILE_NAME', get_option('publickey-file-name'))
86conf.set_quoted('SIGNATURE_FILE_EXT', get_option('signature-file-ext'))
87conf.set_quoted('SIGNED_IMAGE_CONF_PATH', get_option('signed-image-conf-path'))
88conf.set_quoted('SYNC_LIST_DIR_PATH', get_option('sync-list-dir-path'))
89conf.set_quoted('SYNC_LIST_FILE_NAME', get_option('sync-list-file-name'))
Miguel Gomez21dad042020-06-26 20:54:48 +000090conf.set_quoted('BMC_MSL', get_option('bmc-msl'))
91conf.set_quoted('REGEX_BMC_MSL', get_option('regex-bmc-msl'))
92
Lei YU6e9fb1d2021-02-19 18:01:40 +080093if get_option('host-bios-upgrade').enabled()
94 conf.set_quoted('BIOS_OBJPATH', get_option('bios-object-path'))
95endif
Adriana Kobylak0af80a42020-05-05 13:32:10 -050096
97configure_file(output: 'config.h', configuration: conf)
Adriana Kobylak113492e2020-05-05 13:45:45 -050098
Adriana Kobylake0aa7802020-05-05 13:54:49 -050099deps = [
100 dependency('phosphor-dbus-interfaces'),
101 dependency('phosphor-logging'),
102 dependency('sdbusplus')
103]
104
105ssl = dependency('openssl')
106
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500107systemd = dependency('systemd')
108systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
109
110unit_files = [
Adriana Kobylak436be812020-06-17 09:44:56 -0500111 'obmc-flash-bmc-setenv@.service.in',
112 'reboot-guard-disable.service.in',
113 'reboot-guard-enable.service.in',
114 'force-reboot.service.in',
115 'usr-local.mount.in',
116 'xyz.openbmc_project.Software.BMC.Updater.service.in',
117 'xyz.openbmc_project.Software.Download.service.in',
118 'xyz.openbmc_project.Software.Sync.service.in',
119 'xyz.openbmc_project.Software.Version.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500120]
121
Adriana Kobylak113492e2020-05-05 13:45:45 -0500122sdbuspp = find_program('sdbus++')
123subdir('xyz/openbmc_project/Software/Image')
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500124
125image_updater_sources = files(
126 'activation.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500127 'images.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500128 'item_updater.cpp',
129 'item_updater_main.cpp',
130 'serialize.cpp',
131 'version.cpp',
Miguel Gomez21dad042020-06-26 20:54:48 +0000132 'utils.cpp',
133 'msl_verify.cpp'
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500134)
135
136if get_option('bmc-layout').contains('static')
Adriana Kobylak436be812020-06-17 09:44:56 -0500137 image_updater_sources += files(
138 'static/flash.cpp',
139 'static/item_updater_helper.cpp'
140 )
Adriana Kobylak86013f32020-05-13 12:12:38 -0500141elif get_option('bmc-layout').contains('ubi')
Adriana Kobylak436be812020-06-17 09:44:56 -0500142 image_updater_sources += files(
143 'ubi/flash.cpp',
144 'ubi/item_updater_helper.cpp'
145 )
146
147 unit_files += [
148 'ubi/obmc-flash-bmc-cleanup.service.in',
149 'ubi/obmc-flash-bmc-mirroruboot.service.in',
150 'ubi/obmc-flash-bmc-ubiremount.service.in',
151 'ubi/obmc-flash-bmc-ubiro@.service.in',
152 'ubi/obmc-flash-bmc-ubiro-remove@.service.in',
153 'ubi/obmc-flash-bmc-ubirw.service.in',
154 'ubi/obmc-flash-bmc-ubirw-remove.service.in',
155 'ubi/obmc-flash-bmc-updateubootvars@.service.in'
156 ]
Adriana Kobylak86013f32020-05-13 12:12:38 -0500157elif get_option('bmc-layout').contains('mmc')
Adriana Kobylak436be812020-06-17 09:44:56 -0500158 image_updater_sources += files(
159 'mmc/flash.cpp',
160 'mmc/item_updater_helper.cpp'
161 )
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500162
163 unit_files += [
164 'mmc/obmc-flash-mmc@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500165 'mmc/obmc-flash-mmc-mount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500166 'mmc/obmc-flash-mmc-remove@.service.in',
Adriana Kobylak34124352020-05-22 09:40:40 -0500167 'mmc/obmc-flash-mmc-setprimary@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500168 'mmc/obmc-flash-mmc-umount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500169 ]
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500170endif
171
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500172if get_option('host-bios-upgrade').enabled()
Adriana Kobylak436be812020-06-17 09:44:56 -0500173 unit_files += 'obmc-flash-host-bios@.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500174endif
175
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500176if get_option('sync-bmc-files').enabled()
177 executable(
178 'phosphor-sync-software-manager',
179 'sync_manager.cpp',
180 'sync_manager_main.cpp',
181 'sync_watch.cpp',
182 dependencies: deps,
183 install: true
184 )
Adriana Kobylak817209f2020-05-07 09:52:03 -0500185
186 install_data('synclist',
187 install_dir: get_option('sysconfdir')
188 )
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500189endif
190
Adriana Kobylak42bd9932021-01-28 09:45:24 -0600191if (get_option('verify-signature').enabled() or \
192 get_option('verify-full-signature').enabled())
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500193 image_updater_sources += files(
George Liu0a06e972020-12-17 09:17:04 +0800194 'utils.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500195 'image_verify.cpp',
196 'openssl_alloc.cpp'
197 )
198endif
199
200executable(
201 'phosphor-download-manager',
202 'download_manager.cpp',
203 'download_manager_main.cpp',
204 dependencies: deps,
205 install: true
206)
207
208executable(
209 'phosphor-image-updater',
210 image_error_cpp,
211 image_error_hpp,
212 image_updater_sources,
213 dependencies: [deps, ssl],
214 install: true
215)
216
217executable(
218 'phosphor-version-software-manager',
219 image_error_cpp,
220 image_error_hpp,
221 'image_manager.cpp',
222 'image_manager_main.cpp',
223 'version.cpp',
224 'watch.cpp',
225 dependencies: [deps, ssl],
226 install: true
227)
Adriana Kobylak817209f2020-05-07 09:52:03 -0500228
229install_data('obmc-flash-bmc',
230 install_mode: 'rwxr-xr-x',
231 install_dir: get_option('bindir')
232)
233
234install_data('software.conf',
235 install_dir: '/usr/lib/tmpfiles.d/'
236)
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500237
238foreach u : unit_files
239 configure_file(
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500240 input: u,
Adriana Kobylak436be812020-06-17 09:44:56 -0500241 output: '@BASENAME@',
242 configuration: conf,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500243 install: true,
244 install_dir: systemd_system_unit_dir,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500245 )
246endforeach
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500247
248# If test coverage of source files within the root directory are wanted,
249# need to define and build the tests from here
250build_tests = get_option('tests')
251if not build_tests.disabled()
252 oe_sdk = get_option('oe-sdk')
253 if oe_sdk.enabled()
254 # Setup OE SYSROOT
255 OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
256 if OECORE_TARGET_SYSROOT == ''
257 error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
258 endif
259 message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
260 rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
261 ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
262 dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
263 else
264 dynamic_linker = []
265 endif
266
267 gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
268 include_srcs = declare_dependency(sources: [
George Liu0a06e972020-12-17 09:17:04 +0800269 'utils.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500270 'image_verify.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500271 'images.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500272 'version.cpp']
273 )
274
275 test('utest',
276 executable(
277 'utest',
278 './test/utest.cpp',
279 link_args: dynamic_linker,
280 build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
281 dependencies: [deps, gtest, include_srcs, ssl]
282 )
283)
284endif