blob: 938c10b6272128775c240bfbbdf682ed5db516c7 [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'))
64conf.set_quoted('PUBLICKEY_FILE_NAME', get_option('publickey-file-name'))
65conf.set_quoted('SIGNATURE_FILE_EXT', get_option('signature-file-ext'))
66conf.set_quoted('SIGNED_IMAGE_CONF_PATH', get_option('signed-image-conf-path'))
67conf.set_quoted('SYNC_LIST_DIR_PATH', get_option('sync-list-dir-path'))
68conf.set_quoted('SYNC_LIST_FILE_NAME', get_option('sync-list-file-name'))
69
70configure_file(output: 'config.h', configuration: conf)
Adriana Kobylak113492e2020-05-05 13:45:45 -050071
Adriana Kobylake0aa7802020-05-05 13:54:49 -050072deps = [
73 dependency('phosphor-dbus-interfaces'),
74 dependency('phosphor-logging'),
75 dependency('sdbusplus')
76]
77
78ssl = dependency('openssl')
79
Adriana Kobylak29a0d902020-05-05 13:59:49 -050080systemd = dependency('systemd')
81systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
82
83unit_files = [
Adriana Kobylak436be812020-06-17 09:44:56 -050084 'obmc-flash-bmc-setenv@.service.in',
85 'reboot-guard-disable.service.in',
86 'reboot-guard-enable.service.in',
87 'force-reboot.service.in',
88 'usr-local.mount.in',
89 'xyz.openbmc_project.Software.BMC.Updater.service.in',
90 'xyz.openbmc_project.Software.Download.service.in',
91 'xyz.openbmc_project.Software.Sync.service.in',
92 'xyz.openbmc_project.Software.Version.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -050093]
94
Adriana Kobylak113492e2020-05-05 13:45:45 -050095sdbuspp = find_program('sdbus++')
96subdir('xyz/openbmc_project/Software/Image')
Adriana Kobylake0aa7802020-05-05 13:54:49 -050097
98image_updater_sources = files(
99 'activation.cpp',
100 'item_updater.cpp',
101 'item_updater_main.cpp',
102 'serialize.cpp',
103 'version.cpp',
104 'utils.cpp'
105)
106
107if get_option('bmc-layout').contains('static')
Adriana Kobylak436be812020-06-17 09:44:56 -0500108 image_updater_sources += files(
109 'static/flash.cpp',
110 'static/item_updater_helper.cpp'
111 )
Adriana Kobylak86013f32020-05-13 12:12:38 -0500112elif get_option('bmc-layout').contains('ubi')
Adriana Kobylak436be812020-06-17 09:44:56 -0500113 image_updater_sources += files(
114 'ubi/flash.cpp',
115 'ubi/item_updater_helper.cpp'
116 )
117
118 unit_files += [
119 'ubi/obmc-flash-bmc-cleanup.service.in',
120 'ubi/obmc-flash-bmc-mirroruboot.service.in',
121 'ubi/obmc-flash-bmc-ubiremount.service.in',
122 'ubi/obmc-flash-bmc-ubiro@.service.in',
123 'ubi/obmc-flash-bmc-ubiro-remove@.service.in',
124 'ubi/obmc-flash-bmc-ubirw.service.in',
125 'ubi/obmc-flash-bmc-ubirw-remove.service.in',
126 'ubi/obmc-flash-bmc-updateubootvars@.service.in'
127 ]
Adriana Kobylak86013f32020-05-13 12:12:38 -0500128elif get_option('bmc-layout').contains('mmc')
Adriana Kobylak436be812020-06-17 09:44:56 -0500129 image_updater_sources += files(
130 'mmc/flash.cpp',
131 'mmc/item_updater_helper.cpp'
132 )
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500133
134 unit_files += [
135 'mmc/obmc-flash-mmc@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500136 'mmc/obmc-flash-mmc-mount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500137 'mmc/obmc-flash-mmc-remove@.service.in',
Adriana Kobylak34124352020-05-22 09:40:40 -0500138 'mmc/obmc-flash-mmc-setprimary@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500139 'mmc/obmc-flash-mmc-umount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500140 ]
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500141endif
142
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500143if get_option('host-bios-upgrade').enabled()
Adriana Kobylak436be812020-06-17 09:44:56 -0500144 unit_files += 'obmc-flash-host-bios@.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500145endif
146
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500147if get_option('sync-bmc-files').enabled()
148 executable(
149 'phosphor-sync-software-manager',
150 'sync_manager.cpp',
151 'sync_manager_main.cpp',
152 'sync_watch.cpp',
153 dependencies: deps,
154 install: true
155 )
Adriana Kobylak817209f2020-05-07 09:52:03 -0500156
157 install_data('synclist',
158 install_dir: get_option('sysconfdir')
159 )
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500160endif
161
162if get_option('verify-signature').enabled()
163 image_updater_sources += files(
164 'image_verify.cpp',
165 'openssl_alloc.cpp'
166 )
167endif
168
169executable(
170 'phosphor-download-manager',
171 'download_manager.cpp',
172 'download_manager_main.cpp',
173 dependencies: deps,
174 install: true
175)
176
177executable(
178 'phosphor-image-updater',
179 image_error_cpp,
180 image_error_hpp,
181 image_updater_sources,
182 dependencies: [deps, ssl],
183 install: true
184)
185
186executable(
187 'phosphor-version-software-manager',
188 image_error_cpp,
189 image_error_hpp,
190 'image_manager.cpp',
191 'image_manager_main.cpp',
192 'version.cpp',
193 'watch.cpp',
194 dependencies: [deps, ssl],
195 install: true
196)
Adriana Kobylak817209f2020-05-07 09:52:03 -0500197
198install_data('obmc-flash-bmc',
199 install_mode: 'rwxr-xr-x',
200 install_dir: get_option('bindir')
201)
202
203install_data('software.conf',
204 install_dir: '/usr/lib/tmpfiles.d/'
205)
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500206
207foreach u : unit_files
208 configure_file(
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500209 input: u,
Adriana Kobylak436be812020-06-17 09:44:56 -0500210 output: '@BASENAME@',
211 configuration: conf,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500212 install: true,
213 install_dir: systemd_system_unit_dir,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500214 )
215endforeach
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500216
217# If test coverage of source files within the root directory are wanted,
218# need to define and build the tests from here
219build_tests = get_option('tests')
220if not build_tests.disabled()
221 oe_sdk = get_option('oe-sdk')
222 if oe_sdk.enabled()
223 # Setup OE SYSROOT
224 OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
225 if OECORE_TARGET_SYSROOT == ''
226 error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
227 endif
228 message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
229 rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
230 ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
231 dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
232 else
233 dynamic_linker = []
234 endif
235
236 gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
237 include_srcs = declare_dependency(sources: [
238 'image_verify.cpp',
239 'version.cpp']
240 )
241
242 test('utest',
243 executable(
244 'utest',
245 './test/utest.cpp',
246 link_args: dynamic_linker,
247 build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
248 dependencies: [deps, gtest, include_srcs, ssl]
249 )
250)
251endif