blob: c74a927de6a0354b015f12bb5ade79ea376316db [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())
56conf.set('WANT_SIGNATURE_VERIFY', get_option('verify-signature').enabled())
57
58# Configurable variables
59conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed'))
60conf.set_quoted('HASH_FILE_NAME', get_option('hash-file-name'))
61conf.set_quoted('IMG_UPLOAD_DIR', get_option('img-upload-dir'))
62conf.set_quoted('MANIFEST_FILE_NAME', get_option('manifest-file-name'))
63conf.set_quoted('MEDIA_DIR', get_option('media-dir'))
Adriana Kobylak73609bb2020-06-18 15:05:40 -050064optional_array = get_option('optional-images')
65optional_images = ''
66foreach optiona_image : optional_array
67 optional_images = ' '.join([optional_images, optiona_image])
68endforeach
69conf.set_quoted('OPTIONAL_IMAGES', optional_images)
Adriana Kobylak0af80a42020-05-05 13:32:10 -050070conf.set_quoted('PUBLICKEY_FILE_NAME', get_option('publickey-file-name'))
71conf.set_quoted('SIGNATURE_FILE_EXT', get_option('signature-file-ext'))
72conf.set_quoted('SIGNED_IMAGE_CONF_PATH', get_option('signed-image-conf-path'))
73conf.set_quoted('SYNC_LIST_DIR_PATH', get_option('sync-list-dir-path'))
74conf.set_quoted('SYNC_LIST_FILE_NAME', get_option('sync-list-file-name'))
Miguel Gomez21dad042020-06-26 20:54:48 +000075conf.set_quoted('BMC_MSL', get_option('bmc-msl'))
76conf.set_quoted('REGEX_BMC_MSL', get_option('regex-bmc-msl'))
77
Adriana Kobylak0af80a42020-05-05 13:32:10 -050078
79configure_file(output: 'config.h', configuration: conf)
Adriana Kobylak113492e2020-05-05 13:45:45 -050080
Adriana Kobylake0aa7802020-05-05 13:54:49 -050081deps = [
82 dependency('phosphor-dbus-interfaces'),
83 dependency('phosphor-logging'),
84 dependency('sdbusplus')
85]
86
87ssl = dependency('openssl')
88
Adriana Kobylak29a0d902020-05-05 13:59:49 -050089systemd = dependency('systemd')
90systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
91
92unit_files = [
Adriana Kobylak436be812020-06-17 09:44:56 -050093 'obmc-flash-bmc-setenv@.service.in',
94 'reboot-guard-disable.service.in',
95 'reboot-guard-enable.service.in',
96 'force-reboot.service.in',
97 'usr-local.mount.in',
98 'xyz.openbmc_project.Software.BMC.Updater.service.in',
99 'xyz.openbmc_project.Software.Download.service.in',
100 'xyz.openbmc_project.Software.Sync.service.in',
101 'xyz.openbmc_project.Software.Version.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500102]
103
Adriana Kobylak113492e2020-05-05 13:45:45 -0500104sdbuspp = find_program('sdbus++')
105subdir('xyz/openbmc_project/Software/Image')
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500106
107image_updater_sources = files(
108 'activation.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500109 'images.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500110 'item_updater.cpp',
111 'item_updater_main.cpp',
112 'serialize.cpp',
113 'version.cpp',
Miguel Gomez21dad042020-06-26 20:54:48 +0000114 'utils.cpp',
115 'msl_verify.cpp'
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500116)
117
118if get_option('bmc-layout').contains('static')
Adriana Kobylak436be812020-06-17 09:44:56 -0500119 image_updater_sources += files(
120 'static/flash.cpp',
121 'static/item_updater_helper.cpp'
122 )
Adriana Kobylak86013f32020-05-13 12:12:38 -0500123elif get_option('bmc-layout').contains('ubi')
Adriana Kobylak436be812020-06-17 09:44:56 -0500124 image_updater_sources += files(
125 'ubi/flash.cpp',
126 'ubi/item_updater_helper.cpp'
127 )
128
129 unit_files += [
130 'ubi/obmc-flash-bmc-cleanup.service.in',
131 'ubi/obmc-flash-bmc-mirroruboot.service.in',
132 'ubi/obmc-flash-bmc-ubiremount.service.in',
133 'ubi/obmc-flash-bmc-ubiro@.service.in',
134 'ubi/obmc-flash-bmc-ubiro-remove@.service.in',
135 'ubi/obmc-flash-bmc-ubirw.service.in',
136 'ubi/obmc-flash-bmc-ubirw-remove.service.in',
137 'ubi/obmc-flash-bmc-updateubootvars@.service.in'
138 ]
Adriana Kobylak86013f32020-05-13 12:12:38 -0500139elif get_option('bmc-layout').contains('mmc')
Adriana Kobylak436be812020-06-17 09:44:56 -0500140 image_updater_sources += files(
141 'mmc/flash.cpp',
142 'mmc/item_updater_helper.cpp'
143 )
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500144
145 unit_files += [
146 'mmc/obmc-flash-mmc@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500147 'mmc/obmc-flash-mmc-mount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500148 'mmc/obmc-flash-mmc-remove@.service.in',
Adriana Kobylak34124352020-05-22 09:40:40 -0500149 'mmc/obmc-flash-mmc-setprimary@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500150 'mmc/obmc-flash-mmc-umount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500151 ]
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500152endif
153
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500154if get_option('host-bios-upgrade').enabled()
Adriana Kobylak436be812020-06-17 09:44:56 -0500155 unit_files += 'obmc-flash-host-bios@.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500156endif
157
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500158if get_option('sync-bmc-files').enabled()
159 executable(
160 'phosphor-sync-software-manager',
161 'sync_manager.cpp',
162 'sync_manager_main.cpp',
163 'sync_watch.cpp',
164 dependencies: deps,
165 install: true
166 )
Adriana Kobylak817209f2020-05-07 09:52:03 -0500167
168 install_data('synclist',
169 install_dir: get_option('sysconfdir')
170 )
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500171endif
172
173if get_option('verify-signature').enabled()
174 image_updater_sources += files(
175 'image_verify.cpp',
176 'openssl_alloc.cpp'
177 )
178endif
179
180executable(
181 'phosphor-download-manager',
182 'download_manager.cpp',
183 'download_manager_main.cpp',
184 dependencies: deps,
185 install: true
186)
187
188executable(
189 'phosphor-image-updater',
190 image_error_cpp,
191 image_error_hpp,
192 image_updater_sources,
193 dependencies: [deps, ssl],
194 install: true
195)
196
197executable(
198 'phosphor-version-software-manager',
199 image_error_cpp,
200 image_error_hpp,
201 'image_manager.cpp',
202 'image_manager_main.cpp',
203 'version.cpp',
204 'watch.cpp',
205 dependencies: [deps, ssl],
206 install: true
207)
Adriana Kobylak817209f2020-05-07 09:52:03 -0500208
209install_data('obmc-flash-bmc',
210 install_mode: 'rwxr-xr-x',
211 install_dir: get_option('bindir')
212)
213
214install_data('software.conf',
215 install_dir: '/usr/lib/tmpfiles.d/'
216)
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500217
218foreach u : unit_files
219 configure_file(
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500220 input: u,
Adriana Kobylak436be812020-06-17 09:44:56 -0500221 output: '@BASENAME@',
222 configuration: conf,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500223 install: true,
224 install_dir: systemd_system_unit_dir,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500225 )
226endforeach
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500227
228# If test coverage of source files within the root directory are wanted,
229# need to define and build the tests from here
230build_tests = get_option('tests')
231if not build_tests.disabled()
232 oe_sdk = get_option('oe-sdk')
233 if oe_sdk.enabled()
234 # Setup OE SYSROOT
235 OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
236 if OECORE_TARGET_SYSROOT == ''
237 error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
238 endif
239 message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
240 rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
241 ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
242 dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
243 else
244 dynamic_linker = []
245 endif
246
247 gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
248 include_srcs = declare_dependency(sources: [
249 'image_verify.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500250 'images.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500251 'version.cpp']
252 )
253
254 test('utest',
255 executable(
256 'utest',
257 './test/utest.cpp',
258 link_args: dynamic_linker,
259 build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
260 dependencies: [deps, gtest, include_srcs, ssl]
261 )
262)
263endif