blob: 1923fb8e00a82b0e639e26a25cd0df1d0dbe3000 [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'))
75
76configure_file(output: 'config.h', configuration: conf)
Adriana Kobylak113492e2020-05-05 13:45:45 -050077
Adriana Kobylake0aa7802020-05-05 13:54:49 -050078deps = [
79 dependency('phosphor-dbus-interfaces'),
80 dependency('phosphor-logging'),
81 dependency('sdbusplus')
82]
83
84ssl = dependency('openssl')
85
Adriana Kobylak29a0d902020-05-05 13:59:49 -050086systemd = dependency('systemd')
87systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
88
89unit_files = [
Adriana Kobylak436be812020-06-17 09:44:56 -050090 'obmc-flash-bmc-setenv@.service.in',
91 'reboot-guard-disable.service.in',
92 'reboot-guard-enable.service.in',
93 'force-reboot.service.in',
94 'usr-local.mount.in',
95 'xyz.openbmc_project.Software.BMC.Updater.service.in',
96 'xyz.openbmc_project.Software.Download.service.in',
97 'xyz.openbmc_project.Software.Sync.service.in',
98 'xyz.openbmc_project.Software.Version.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -050099]
100
Adriana Kobylak113492e2020-05-05 13:45:45 -0500101sdbuspp = find_program('sdbus++')
102subdir('xyz/openbmc_project/Software/Image')
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500103
104image_updater_sources = files(
105 'activation.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500106 'images.cpp',
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500107 'item_updater.cpp',
108 'item_updater_main.cpp',
109 'serialize.cpp',
110 'version.cpp',
111 'utils.cpp'
112)
113
114if get_option('bmc-layout').contains('static')
Adriana Kobylak436be812020-06-17 09:44:56 -0500115 image_updater_sources += files(
116 'static/flash.cpp',
117 'static/item_updater_helper.cpp'
118 )
Adriana Kobylak86013f32020-05-13 12:12:38 -0500119elif get_option('bmc-layout').contains('ubi')
Adriana Kobylak436be812020-06-17 09:44:56 -0500120 image_updater_sources += files(
121 'ubi/flash.cpp',
122 'ubi/item_updater_helper.cpp'
123 )
124
125 unit_files += [
126 'ubi/obmc-flash-bmc-cleanup.service.in',
127 'ubi/obmc-flash-bmc-mirroruboot.service.in',
128 'ubi/obmc-flash-bmc-ubiremount.service.in',
129 'ubi/obmc-flash-bmc-ubiro@.service.in',
130 'ubi/obmc-flash-bmc-ubiro-remove@.service.in',
131 'ubi/obmc-flash-bmc-ubirw.service.in',
132 'ubi/obmc-flash-bmc-ubirw-remove.service.in',
133 'ubi/obmc-flash-bmc-updateubootvars@.service.in'
134 ]
Adriana Kobylak86013f32020-05-13 12:12:38 -0500135elif get_option('bmc-layout').contains('mmc')
Adriana Kobylak436be812020-06-17 09:44:56 -0500136 image_updater_sources += files(
137 'mmc/flash.cpp',
138 'mmc/item_updater_helper.cpp'
139 )
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500140
141 unit_files += [
142 'mmc/obmc-flash-mmc@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500143 'mmc/obmc-flash-mmc-mount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500144 'mmc/obmc-flash-mmc-remove@.service.in',
Adriana Kobylak34124352020-05-22 09:40:40 -0500145 'mmc/obmc-flash-mmc-setprimary@.service.in',
Adriana Kobylakd7fbc1e2020-06-06 07:46:40 -0500146 'mmc/obmc-flash-mmc-umount.service.in',
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500147 ]
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500148endif
149
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500150if get_option('host-bios-upgrade').enabled()
Adriana Kobylak436be812020-06-17 09:44:56 -0500151 unit_files += 'obmc-flash-host-bios@.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500152endif
153
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500154if get_option('sync-bmc-files').enabled()
155 executable(
156 'phosphor-sync-software-manager',
157 'sync_manager.cpp',
158 'sync_manager_main.cpp',
159 'sync_watch.cpp',
160 dependencies: deps,
161 install: true
162 )
Adriana Kobylak817209f2020-05-07 09:52:03 -0500163
164 install_data('synclist',
165 install_dir: get_option('sysconfdir')
166 )
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500167endif
168
169if get_option('verify-signature').enabled()
170 image_updater_sources += files(
171 'image_verify.cpp',
172 'openssl_alloc.cpp'
173 )
174endif
175
176executable(
177 'phosphor-download-manager',
178 'download_manager.cpp',
179 'download_manager_main.cpp',
180 dependencies: deps,
181 install: true
182)
183
184executable(
185 'phosphor-image-updater',
186 image_error_cpp,
187 image_error_hpp,
188 image_updater_sources,
189 dependencies: [deps, ssl],
190 install: true
191)
192
193executable(
194 'phosphor-version-software-manager',
195 image_error_cpp,
196 image_error_hpp,
197 'image_manager.cpp',
198 'image_manager_main.cpp',
199 'version.cpp',
200 'watch.cpp',
201 dependencies: [deps, ssl],
202 install: true
203)
Adriana Kobylak817209f2020-05-07 09:52:03 -0500204
205install_data('obmc-flash-bmc',
206 install_mode: 'rwxr-xr-x',
207 install_dir: get_option('bindir')
208)
209
210install_data('software.conf',
211 install_dir: '/usr/lib/tmpfiles.d/'
212)
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500213
214foreach u : unit_files
215 configure_file(
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500216 input: u,
Adriana Kobylak436be812020-06-17 09:44:56 -0500217 output: '@BASENAME@',
218 configuration: conf,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500219 install: true,
220 install_dir: systemd_system_unit_dir,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500221 )
222endforeach
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500223
224# If test coverage of source files within the root directory are wanted,
225# need to define and build the tests from here
226build_tests = get_option('tests')
227if not build_tests.disabled()
228 oe_sdk = get_option('oe-sdk')
229 if oe_sdk.enabled()
230 # Setup OE SYSROOT
231 OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
232 if OECORE_TARGET_SYSROOT == ''
233 error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
234 endif
235 message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
236 rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
237 ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
238 dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
239 else
240 dynamic_linker = []
241 endif
242
243 gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
244 include_srcs = declare_dependency(sources: [
245 'image_verify.cpp',
Adriana Kobylak73609bb2020-06-18 15:05:40 -0500246 'images.cpp',
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500247 'version.cpp']
248 )
249
250 test('utest',
251 executable(
252 'utest',
253 './test/utest.cpp',
254 link_args: dynamic_linker,
255 build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
256 dependencies: [deps, gtest, include_srcs, ssl]
257 )
258)
259endif