xref: /openbmc/phosphor-bmc-code-mgmt/meson.build (revision 70f5bc04d82ac9c236f13e825db31e7c96aa7f11)
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', 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)
71
72deps = [
73    dependency('phosphor-dbus-interfaces'),
74    dependency('phosphor-logging'),
75    dependency('sdbusplus')
76]
77
78ssl = dependency('openssl')
79
80systemd = dependency('systemd')
81systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
82
83unit_files = [
84    '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'
93]
94
95sdbuspp = find_program('sdbus++')
96subdir('xyz/openbmc_project/Software/Image')
97
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')
108    image_updater_sources += files(
109        'static/flash.cpp',
110        'static/item_updater_helper.cpp'
111    )
112elif get_option('bmc-layout').contains('ubi')
113    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    ]
128elif get_option('bmc-layout').contains('mmc')
129    image_updater_sources += files(
130        'mmc/flash.cpp',
131        'mmc/item_updater_helper.cpp'
132    )
133
134    unit_files += [
135        'mmc/obmc-flash-mmc@.service.in',
136        'mmc/obmc-flash-mmc-remove@.service.in',
137    ]
138endif
139
140if get_option('host-bios-upgrade').enabled()
141    unit_files += 'obmc-flash-host-bios@.service.in'
142endif
143
144if get_option('sync-bmc-files').enabled()
145    executable(
146        'phosphor-sync-software-manager',
147        'sync_manager.cpp',
148        'sync_manager_main.cpp',
149        'sync_watch.cpp',
150        dependencies: deps,
151        install: true
152    )
153
154    install_data('synclist',
155        install_dir:  get_option('sysconfdir')
156    )
157endif
158
159if get_option('verify-signature').enabled()
160    image_updater_sources += files(
161        'image_verify.cpp',
162        'openssl_alloc.cpp'
163    )
164endif
165
166executable(
167    'phosphor-download-manager',
168    'download_manager.cpp',
169    'download_manager_main.cpp',
170    dependencies: deps,
171    install: true
172)
173
174executable(
175    'phosphor-image-updater',
176    image_error_cpp,
177    image_error_hpp,
178    image_updater_sources,
179    dependencies: [deps, ssl],
180    install: true
181)
182
183executable(
184    'phosphor-version-software-manager',
185    image_error_cpp,
186    image_error_hpp,
187    'image_manager.cpp',
188    'image_manager_main.cpp',
189    'version.cpp',
190    'watch.cpp',
191    dependencies: [deps, ssl],
192    install: true
193)
194
195install_data('obmc-flash-bmc',
196    install_mode: 'rwxr-xr-x',
197    install_dir: get_option('bindir')
198)
199
200install_data('software.conf',
201    install_dir: '/usr/lib/tmpfiles.d/'
202)
203
204foreach u : unit_files
205    configure_file(
206        input: u,
207        output: '@BASENAME@',
208        configuration: conf,
209        install: true,
210        install_dir: systemd_system_unit_dir,
211    )
212endforeach
213
214# If test coverage of source files within the root directory are wanted,
215# need to define and build the tests from here
216build_tests = get_option('tests')
217if not build_tests.disabled()
218    oe_sdk = get_option('oe-sdk')
219    if oe_sdk.enabled()
220        # Setup OE SYSROOT
221        OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
222        if OECORE_TARGET_SYSROOT == ''
223            error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
224        endif
225        message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
226        rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
227        ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
228        dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
229    else
230        dynamic_linker = []
231    endif
232
233    gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
234    include_srcs = declare_dependency(sources: [
235        'image_verify.cpp',
236        'version.cpp']
237    )
238
239    test('utest',
240        executable(
241            'utest',
242            './test/utest.cpp',
243            link_args: dynamic_linker,
244            build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
245            dependencies: [deps, gtest, include_srcs, ssl]
246        )
247)
248endif
249