blob: f39520e428c63da6fe7dc5b24f4beba1027cbf43 [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'))
52
53# Configurable features
54conf.set('HOST_BIOS_UPGRADE', get_option('host-bios-upgrade').enabled())
55conf.set('WANT_SIGNATURE_VERIFY', get_option('verify-signature').enabled())
56
57# Configurable variables
58conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed'))
59conf.set_quoted('HASH_FILE_NAME', get_option('hash-file-name'))
60conf.set_quoted('IMG_UPLOAD_DIR', get_option('img-upload-dir'))
61conf.set_quoted('MANIFEST_FILE_NAME', get_option('manifest-file-name'))
62conf.set_quoted('MEDIA_DIR', get_option('media-dir'))
63conf.set_quoted('PUBLICKEY_FILE_NAME', get_option('publickey-file-name'))
64conf.set_quoted('SIGNATURE_FILE_EXT', get_option('signature-file-ext'))
65conf.set_quoted('SIGNED_IMAGE_CONF_PATH', get_option('signed-image-conf-path'))
66conf.set_quoted('SYNC_LIST_DIR_PATH', get_option('sync-list-dir-path'))
67conf.set_quoted('SYNC_LIST_FILE_NAME', get_option('sync-list-file-name'))
68
69configure_file(output: 'config.h', configuration: conf)
Adriana Kobylak113492e2020-05-05 13:45:45 -050070
Adriana Kobylake0aa7802020-05-05 13:54:49 -050071deps = [
72 dependency('phosphor-dbus-interfaces'),
73 dependency('phosphor-logging'),
74 dependency('sdbusplus')
75]
76
77ssl = dependency('openssl')
78
Adriana Kobylak29a0d902020-05-05 13:59:49 -050079systemd = dependency('systemd')
80systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
81
82unit_files = [
Adriana Kobylak436be812020-06-17 09:44:56 -050083 'obmc-flash-bmc-setenv@.service.in',
84 'reboot-guard-disable.service.in',
85 'reboot-guard-enable.service.in',
86 'force-reboot.service.in',
87 'usr-local.mount.in',
88 'xyz.openbmc_project.Software.BMC.Updater.service.in',
89 'xyz.openbmc_project.Software.Download.service.in',
90 'xyz.openbmc_project.Software.Sync.service.in',
91 'xyz.openbmc_project.Software.Version.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -050092]
93
Adriana Kobylak113492e2020-05-05 13:45:45 -050094sdbuspp = find_program('sdbus++')
95subdir('xyz/openbmc_project/Software/Image')
Adriana Kobylake0aa7802020-05-05 13:54:49 -050096
97image_updater_sources = files(
98 'activation.cpp',
99 'item_updater.cpp',
100 'item_updater_main.cpp',
101 'serialize.cpp',
102 'version.cpp',
103 'utils.cpp'
104)
105
106if get_option('bmc-layout').contains('static')
Adriana Kobylak436be812020-06-17 09:44:56 -0500107 image_updater_sources += files(
108 'static/flash.cpp',
109 'static/item_updater_helper.cpp'
110 )
Adriana Kobylak86013f32020-05-13 12:12:38 -0500111elif get_option('bmc-layout').contains('ubi')
Adriana Kobylak436be812020-06-17 09:44:56 -0500112 image_updater_sources += files(
113 'ubi/flash.cpp',
114 'ubi/item_updater_helper.cpp'
115 )
116
117 unit_files += [
118 'ubi/obmc-flash-bmc-cleanup.service.in',
119 'ubi/obmc-flash-bmc-mirroruboot.service.in',
120 'ubi/obmc-flash-bmc-ubiremount.service.in',
121 'ubi/obmc-flash-bmc-ubiro@.service.in',
122 'ubi/obmc-flash-bmc-ubiro-remove@.service.in',
123 'ubi/obmc-flash-bmc-ubirw.service.in',
124 'ubi/obmc-flash-bmc-ubirw-remove.service.in',
125 'ubi/obmc-flash-bmc-updateubootvars@.service.in'
126 ]
Adriana Kobylak86013f32020-05-13 12:12:38 -0500127elif get_option('bmc-layout').contains('mmc')
Adriana Kobylak436be812020-06-17 09:44:56 -0500128 image_updater_sources += files(
129 'mmc/flash.cpp',
130 'mmc/item_updater_helper.cpp'
131 )
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500132endif
133
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500134if get_option('host-bios-upgrade').enabled()
Adriana Kobylak436be812020-06-17 09:44:56 -0500135 unit_files += 'obmc-flash-host-bios@.service.in'
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500136endif
137
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500138if get_option('sync-bmc-files').enabled()
139 executable(
140 'phosphor-sync-software-manager',
141 'sync_manager.cpp',
142 'sync_manager_main.cpp',
143 'sync_watch.cpp',
144 dependencies: deps,
145 install: true
146 )
Adriana Kobylak817209f2020-05-07 09:52:03 -0500147
148 install_data('synclist',
149 install_dir: get_option('sysconfdir')
150 )
Adriana Kobylake0aa7802020-05-05 13:54:49 -0500151endif
152
153if get_option('verify-signature').enabled()
154 image_updater_sources += files(
155 'image_verify.cpp',
156 'openssl_alloc.cpp'
157 )
158endif
159
160executable(
161 'phosphor-download-manager',
162 'download_manager.cpp',
163 'download_manager_main.cpp',
164 dependencies: deps,
165 install: true
166)
167
168executable(
169 'phosphor-image-updater',
170 image_error_cpp,
171 image_error_hpp,
172 image_updater_sources,
173 dependencies: [deps, ssl],
174 install: true
175)
176
177executable(
178 'phosphor-version-software-manager',
179 image_error_cpp,
180 image_error_hpp,
181 'image_manager.cpp',
182 'image_manager_main.cpp',
183 'version.cpp',
184 'watch.cpp',
185 dependencies: [deps, ssl],
186 install: true
187)
Adriana Kobylak817209f2020-05-07 09:52:03 -0500188
189install_data('obmc-flash-bmc',
190 install_mode: 'rwxr-xr-x',
191 install_dir: get_option('bindir')
192)
193
194install_data('software.conf',
195 install_dir: '/usr/lib/tmpfiles.d/'
196)
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500197
198foreach u : unit_files
199 configure_file(
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500200 input: u,
Adriana Kobylak436be812020-06-17 09:44:56 -0500201 output: '@BASENAME@',
202 configuration: conf,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500203 install: true,
204 install_dir: systemd_system_unit_dir,
Adriana Kobylak29a0d902020-05-05 13:59:49 -0500205 )
206endforeach
Adriana Kobylak78e72d92020-05-05 14:01:54 -0500207
208# If test coverage of source files within the root directory are wanted,
209# need to define and build the tests from here
210build_tests = get_option('tests')
211if not build_tests.disabled()
212 oe_sdk = get_option('oe-sdk')
213 if oe_sdk.enabled()
214 # Setup OE SYSROOT
215 OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
216 if OECORE_TARGET_SYSROOT == ''
217 error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
218 endif
219 message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
220 rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
221 ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
222 dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
223 else
224 dynamic_linker = []
225 endif
226
227 gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
228 include_srcs = declare_dependency(sources: [
229 'image_verify.cpp',
230 'version.cpp']
231 )
232
233 test('utest',
234 executable(
235 'utest',
236 './test/utest.cpp',
237 link_args: dynamic_linker,
238 build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
239 dependencies: [deps, gtest, include_srcs, ssl]
240 )
241)
242endif