blob: f06090e78eeac36f59521acbba45cfd94b809716 [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())
George Liu0a06e972020-12-17 09:17:04 +080057conf.set('WANT_SIGNATURE_FULL_VERIFY', get_option('verify-full-signature').enabled())
Adriana Kobylak0af80a42020-05-05 13:32:10 -050058
59# Configurable variables
60conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed'))
61conf.set_quoted('HASH_FILE_NAME', get_option('hash-file-name'))
62conf.set_quoted('IMG_UPLOAD_DIR', get_option('img-upload-dir'))
63conf.set_quoted('MANIFEST_FILE_NAME', get_option('manifest-file-name'))
64conf.set_quoted('MEDIA_DIR', get_option('media-dir'))
Adriana Kobylak73609bb2020-06-18 15:05:40 -050065optional_array = get_option('optional-images')
66optional_images = ''
67foreach optiona_image : optional_array
68 optional_images = ' '.join([optional_images, optiona_image])
69endforeach
70conf.set_quoted('OPTIONAL_IMAGES', optional_images)
Adriana Kobylak0af80a42020-05-05 13:32:10 -050071conf.set_quoted('PUBLICKEY_FILE_NAME', get_option('publickey-file-name'))
72conf.set_quoted('SIGNATURE_FILE_EXT', get_option('signature-file-ext'))
73conf.set_quoted('SIGNED_IMAGE_CONF_PATH', get_option('signed-image-conf-path'))
74conf.set_quoted('SYNC_LIST_DIR_PATH', get_option('sync-list-dir-path'))
75conf.set_quoted('SYNC_LIST_FILE_NAME', get_option('sync-list-file-name'))
Miguel Gomez21dad042020-06-26 20:54:48 +000076conf.set_quoted('BMC_MSL', get_option('bmc-msl'))
77conf.set_quoted('REGEX_BMC_MSL', get_option('regex-bmc-msl'))
78
Adriana Kobylak0af80a42020-05-05 13:32:10 -050079
80configure_file(output: 'config.h', configuration: conf)
Adriana Kobylak113492e2020-05-05 13:45:45 -050081
Adriana Kobylake0aa7802020-05-05 13:54:49 -050082deps = [
83 dependency('phosphor-dbus-interfaces'),
84 dependency('phosphor-logging'),
85 dependency('sdbusplus')
86]
87
88ssl = dependency('openssl')
89
Adriana Kobylak29a0d902020-05-05 13:59:49 -050090systemd = dependency('systemd')
91systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
92
93unit_files = [
Adriana Kobylak436be812020-06-17 09:44:56 -050094 'obmc-flash-bmc-setenv@.service.in',
95 'reboot-guard-disable.service.in',
96 'reboot-guard-enable.service.in',
97 'force-reboot.service.in',
98 'usr-local.mount.in',
99 'xyz.openbmc_project.Software.BMC.Updater.service.in',
100 'xyz.openbmc_project.Software.Download.service.in',
101 'xyz.openbmc_project.Software.Sync.service.in',
102 'xyz.openbmc_project.Software.Version.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500103]
104
Adriana Kobylak113492e2020-05-05 13:45:45 -0500105sdbuspp = find_program('sdbus++')
106subdir('xyz/openbmc_project/Software/Image')
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500107
108image_updater_sources = files(
109 'activation.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500110 'images.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500111 'item_updater.cpp',
112 'item_updater_main.cpp',
113 'serialize.cpp',
114 'version.cpp',
Miguel Gomez21dad042020-06-26 20:54:48 +0000115 'utils.cpp',
116 'msl_verify.cpp'
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500117)
118
119if get_option('bmc-layout').contains('static')
Adriana Kobylak436be812020-06-17 09:44:56 -0500120 image_updater_sources += files(
121 'static/flash.cpp',
122 'static/item_updater_helper.cpp'
123 )
Adriana Kobylak86013f32020-05-13 12:12:38 -0500124elif get_option('bmc-layout').contains('ubi')
Adriana Kobylak436be812020-06-17 09:44:56 -0500125 image_updater_sources += files(
126 'ubi/flash.cpp',
127 'ubi/item_updater_helper.cpp'
128 )
129
130 unit_files += [
131 'ubi/obmc-flash-bmc-cleanup.service.in',
132 'ubi/obmc-flash-bmc-mirroruboot.service.in',
133 'ubi/obmc-flash-bmc-ubiremount.service.in',
134 'ubi/obmc-flash-bmc-ubiro@.service.in',
135 'ubi/obmc-flash-bmc-ubiro-remove@.service.in',
136 'ubi/obmc-flash-bmc-ubirw.service.in',
137 'ubi/obmc-flash-bmc-ubirw-remove.service.in',
138 'ubi/obmc-flash-bmc-updateubootvars@.service.in'
139 ]
Adriana Kobylak86013f32020-05-13 12:12:38 -0500140elif get_option('bmc-layout').contains('mmc')
Adriana Kobylak436be812020-06-17 09:44:56 -0500141 image_updater_sources += files(
142 'mmc/flash.cpp',
143 'mmc/item_updater_helper.cpp'
144 )
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500145
146 unit_files += [
147 'mmc/obmc-flash-mmc@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500148 'mmc/obmc-flash-mmc-mount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500149 'mmc/obmc-flash-mmc-remove@.service.in',
Adriana Kobylak34124352020-05-22 09:40:40 -0500150 'mmc/obmc-flash-mmc-setprimary@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500151 'mmc/obmc-flash-mmc-umount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500152 ]
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500153endif
154
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500155if get_option('host-bios-upgrade').enabled()
Adriana Kobylak436be812020-06-17 09:44:56 -0500156 unit_files += 'obmc-flash-host-bios@.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500157endif
158
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500159if get_option('sync-bmc-files').enabled()
160 executable(
161 'phosphor-sync-software-manager',
162 'sync_manager.cpp',
163 'sync_manager_main.cpp',
164 'sync_watch.cpp',
165 dependencies: deps,
166 install: true
167 )
Adriana Kobylak817209f2020-05-07 09:52:03 -0500168
169 install_data('synclist',
170 install_dir: get_option('sysconfdir')
171 )
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500172endif
173
174if get_option('verify-signature').enabled()
175 image_updater_sources += files(
George Liu0a06e972020-12-17 09:17:04 +0800176 'utils.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500177 'image_verify.cpp',
178 'openssl_alloc.cpp'
179 )
180endif
181
182executable(
183 'phosphor-download-manager',
184 'download_manager.cpp',
185 'download_manager_main.cpp',
186 dependencies: deps,
187 install: true
188)
189
190executable(
191 'phosphor-image-updater',
192 image_error_cpp,
193 image_error_hpp,
194 image_updater_sources,
195 dependencies: [deps, ssl],
196 install: true
197)
198
199executable(
200 'phosphor-version-software-manager',
201 image_error_cpp,
202 image_error_hpp,
203 'image_manager.cpp',
204 'image_manager_main.cpp',
205 'version.cpp',
206 'watch.cpp',
207 dependencies: [deps, ssl],
208 install: true
209)
Adriana Kobylak817209f2020-05-07 09:52:03 -0500210
211install_data('obmc-flash-bmc',
212 install_mode: 'rwxr-xr-x',
213 install_dir: get_option('bindir')
214)
215
216install_data('software.conf',
217 install_dir: '/usr/lib/tmpfiles.d/'
218)
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500219
220foreach u : unit_files
221 configure_file(
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500222 input: u,
Adriana Kobylak436be812020-06-17 09:44:56 -0500223 output: '@BASENAME@',
224 configuration: conf,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500225 install: true,
226 install_dir: systemd_system_unit_dir,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500227 )
228endforeach
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500229
230# If test coverage of source files within the root directory are wanted,
231# need to define and build the tests from here
232build_tests = get_option('tests')
233if not build_tests.disabled()
234 oe_sdk = get_option('oe-sdk')
235 if oe_sdk.enabled()
236 # Setup OE SYSROOT
237 OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
238 if OECORE_TARGET_SYSROOT == ''
239 error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
240 endif
241 message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
242 rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
243 ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
244 dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
245 else
246 dynamic_linker = []
247 endif
248
249 gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
250 include_srcs = declare_dependency(sources: [
George Liu0a06e972020-12-17 09:17:04 +0800251 'utils.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500252 'image_verify.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500253 'images.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500254 'version.cpp']
255 )
256
257 test('utest',
258 executable(
259 'utest',
260 './test/utest.cpp',
261 link_args: dynamic_linker,
262 build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
263 dependencies: [deps, gtest, include_srcs, ssl]
264 )
265)
266endif