xref: /openbmc/phosphor-bmc-code-mgmt/meson.build (revision 42bd99361cdad9971e76c228bf83b7010fc7b249)
1project('phosphor-bmc-code-mgmt', 'cpp',
2    default_options: [
3        'buildtype=debugoptimized',
4        'cpp_std=c++17',
5        'warning_level=3',
6        'werror=true'
7    ],
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'))
52conf.set('MMC_LAYOUT', get_option('bmc-layout').contains('mmc'))
53
54# Configurable features
55conf.set('HOST_BIOS_UPGRADE', get_option('host-bios-upgrade').enabled())
56conf.set('WANT_SIGNATURE_VERIFY', \
57    get_option('verify-signature').enabled() or \
58    get_option('verify-full-signature').enabled())
59conf.set('WANT_SIGNATURE_FULL_VERIFY', get_option('verify-full-signature').enabled())
60
61# Configurable variables
62conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed'))
63conf.set_quoted('HASH_FILE_NAME', get_option('hash-file-name'))
64conf.set_quoted('IMG_UPLOAD_DIR', get_option('img-upload-dir'))
65conf.set_quoted('MANIFEST_FILE_NAME', get_option('manifest-file-name'))
66conf.set_quoted('MEDIA_DIR', get_option('media-dir'))
67optional_array = get_option('optional-images')
68optional_images = ''
69foreach optiona_image : optional_array
70    optional_images = ' '.join([optional_images, optiona_image])
71endforeach
72conf.set_quoted('OPTIONAL_IMAGES', optional_images)
73conf.set_quoted('PUBLICKEY_FILE_NAME', get_option('publickey-file-name'))
74conf.set_quoted('SIGNATURE_FILE_EXT', get_option('signature-file-ext'))
75conf.set_quoted('SIGNED_IMAGE_CONF_PATH', get_option('signed-image-conf-path'))
76conf.set_quoted('SYNC_LIST_DIR_PATH', get_option('sync-list-dir-path'))
77conf.set_quoted('SYNC_LIST_FILE_NAME', get_option('sync-list-file-name'))
78conf.set_quoted('BMC_MSL', get_option('bmc-msl'))
79conf.set_quoted('REGEX_BMC_MSL', get_option('regex-bmc-msl'))
80
81
82configure_file(output: 'config.h', configuration: conf)
83
84deps = [
85    dependency('phosphor-dbus-interfaces'),
86    dependency('phosphor-logging'),
87    dependency('sdbusplus')
88]
89
90ssl = dependency('openssl')
91
92systemd = dependency('systemd')
93systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
94
95unit_files = [
96    'obmc-flash-bmc-setenv@.service.in',
97    'reboot-guard-disable.service.in',
98    'reboot-guard-enable.service.in',
99    'force-reboot.service.in',
100    'usr-local.mount.in',
101    'xyz.openbmc_project.Software.BMC.Updater.service.in',
102    'xyz.openbmc_project.Software.Download.service.in',
103    'xyz.openbmc_project.Software.Sync.service.in',
104    'xyz.openbmc_project.Software.Version.service.in'
105]
106
107sdbuspp = find_program('sdbus++')
108subdir('xyz/openbmc_project/Software/Image')
109
110image_updater_sources = files(
111    'activation.cpp',
112    'images.cpp',
113    'item_updater.cpp',
114    'item_updater_main.cpp',
115    'serialize.cpp',
116    'version.cpp',
117    'utils.cpp',
118    'msl_verify.cpp'
119)
120
121if get_option('bmc-layout').contains('static')
122    image_updater_sources += files(
123        'static/flash.cpp',
124        'static/item_updater_helper.cpp'
125    )
126elif get_option('bmc-layout').contains('ubi')
127    image_updater_sources += files(
128        'ubi/flash.cpp',
129        'ubi/item_updater_helper.cpp'
130    )
131
132    unit_files += [
133        'ubi/obmc-flash-bmc-cleanup.service.in',
134        'ubi/obmc-flash-bmc-mirroruboot.service.in',
135        'ubi/obmc-flash-bmc-ubiremount.service.in',
136        'ubi/obmc-flash-bmc-ubiro@.service.in',
137        'ubi/obmc-flash-bmc-ubiro-remove@.service.in',
138        'ubi/obmc-flash-bmc-ubirw.service.in',
139        'ubi/obmc-flash-bmc-ubirw-remove.service.in',
140        'ubi/obmc-flash-bmc-updateubootvars@.service.in'
141    ]
142elif get_option('bmc-layout').contains('mmc')
143    image_updater_sources += files(
144        'mmc/flash.cpp',
145        'mmc/item_updater_helper.cpp'
146    )
147
148    unit_files += [
149        'mmc/obmc-flash-mmc@.service.in',
150        'mmc/obmc-flash-mmc-mount.service.in',
151        'mmc/obmc-flash-mmc-remove@.service.in',
152        'mmc/obmc-flash-mmc-setprimary@.service.in',
153        'mmc/obmc-flash-mmc-umount.service.in',
154    ]
155endif
156
157if get_option('host-bios-upgrade').enabled()
158    unit_files += 'obmc-flash-host-bios@.service.in'
159endif
160
161if get_option('sync-bmc-files').enabled()
162    executable(
163        'phosphor-sync-software-manager',
164        'sync_manager.cpp',
165        'sync_manager_main.cpp',
166        'sync_watch.cpp',
167        dependencies: deps,
168        install: true
169    )
170
171    install_data('synclist',
172        install_dir:  get_option('sysconfdir')
173    )
174endif
175
176if (get_option('verify-signature').enabled() or \
177    get_option('verify-full-signature').enabled())
178    image_updater_sources += files(
179        'utils.cpp',
180        'image_verify.cpp',
181        'openssl_alloc.cpp'
182    )
183endif
184
185executable(
186    'phosphor-download-manager',
187    'download_manager.cpp',
188    'download_manager_main.cpp',
189    dependencies: deps,
190    install: true
191)
192
193executable(
194    'phosphor-image-updater',
195    image_error_cpp,
196    image_error_hpp,
197    image_updater_sources,
198    dependencies: [deps, ssl],
199    install: true
200)
201
202executable(
203    'phosphor-version-software-manager',
204    image_error_cpp,
205    image_error_hpp,
206    'image_manager.cpp',
207    'image_manager_main.cpp',
208    'version.cpp',
209    'watch.cpp',
210    dependencies: [deps, ssl],
211    install: true
212)
213
214install_data('obmc-flash-bmc',
215    install_mode: 'rwxr-xr-x',
216    install_dir: get_option('bindir')
217)
218
219install_data('software.conf',
220    install_dir: '/usr/lib/tmpfiles.d/'
221)
222
223foreach u : unit_files
224    configure_file(
225        input: u,
226        output: '@BASENAME@',
227        configuration: conf,
228        install: true,
229        install_dir: systemd_system_unit_dir,
230    )
231endforeach
232
233# If test coverage of source files within the root directory are wanted,
234# need to define and build the tests from here
235build_tests = get_option('tests')
236if not build_tests.disabled()
237    oe_sdk = get_option('oe-sdk')
238    if oe_sdk.enabled()
239        # Setup OE SYSROOT
240        OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
241        if OECORE_TARGET_SYSROOT == ''
242            error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
243        endif
244        message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
245        rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
246        ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
247        dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
248    else
249        dynamic_linker = []
250    endif
251
252    gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
253    include_srcs = declare_dependency(sources: [
254        'utils.cpp',
255        'image_verify.cpp',
256        'images.cpp',
257        'version.cpp']
258    )
259
260    test('utest',
261        executable(
262            'utest',
263            './test/utest.cpp',
264            link_args: dynamic_linker,
265            build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
266            dependencies: [deps, gtest, include_srcs, ssl]
267        )
268)
269endif
270