blob: c35f26af7a562613af46100460984c59b5c55e94 [file] [log] [blame]
Ramesh Iyyarbb410df2020-08-03 03:13:04 -05001# SPDX-License-Identifier: Apache-2.0
2
3project('phosphor-debug-collector',
4 'cpp',
Patrick Williams6c84a8c2023-04-12 08:10:41 -05005 meson_version: '>= 0.58.0',
Ramesh Iyyarbb410df2020-08-03 03:13:04 -05006 default_options: [
Patrick Williams8f4cc942021-10-01 16:05:41 -05007 'cpp_std=c++20',
Ramesh Iyyarbb410df2020-08-03 03:13:04 -05008 'warning_level=3',
PriyangaRamasamy01c66462021-02-23 05:46:25 -06009 'werror=true',
10 'buildtype=debugoptimized'
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050011 ],
12 version: '1.0',
13 license: 'Apache-2.0'
14 )
15
Patrick Williamsabbe1592021-10-01 16:04:19 -050016cpp = meson.get_compiler('cpp')
17
Dhruvaraj Subhashchandran9f557362021-05-12 06:28:20 -050018# list of unit files, the path as input and service name
19# as output
20# eg: unit_file += {'input:'<path>, 'output':<service name>}
21unit_files = []
22
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050023# Checking dependency external library
24
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050025libsystemd = dependency('libsystemd', version : '>=221')
George Liu73e0bab2021-06-29 15:57:43 +080026
Patrick Williams02634e52022-03-21 11:16:11 -050027sdbusplus_dep = dependency('sdbusplus')
28sdbusplusplus_prog = find_program('sdbus++')
29sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson')
Marri Devender Rao3ed02c32022-06-28 23:12:14 -050030sdeventplus_dep = dependency('sdeventplus')
Patrick Williams02634e52022-03-21 11:16:11 -050031
32phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
33phosphor_logging_dep = dependency('phosphor-logging')
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050034
Patrick Williamsabbe1592021-10-01 16:04:19 -050035# Get Cereal dependency.
36cereal_dep = dependency('cereal', required: false)
37has_cereal = cpp.has_header_symbol(
38 'cereal/cereal.hpp',
39 'cereal::specialize',
40 dependencies: cereal_dep,
41 required: false)
42if not has_cereal
43 cereal_opts = import('cmake').subproject_options()
44 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
45 cereal_proj = import('cmake').subproject(
46 'cereal',
47 options: cereal_opts,
48 required: false)
49 assert(cereal_proj.found(), 'cereal is required')
50 cereal_dep = cereal_proj.dependency('cereal')
51endif
52
PriyangaRamasamy01c66462021-02-23 05:46:25 -060053# Disable FORTIFY_SOURCE when compiling with no optimization
54if(get_option('optimization') == '0')
55 add_project_arguments('-U_FORTIFY_SOURCE',language:['cpp','c'])
56 message('Disabling FORTIFY_SOURCE as optimization is set to 0')
57endif
58
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050059# Configuration header file(config.h) generation
60
61conf_data = configuration_data()
62
63conf_data.set_quoted('DUMP_BUSNAME', get_option('DUMP_BUSNAME'),
64 description : 'The Dbus busname to own'
65 )
66conf_data.set_quoted('DUMP_OBJPATH', get_option('DUMP_OBJPATH'),
67 description : 'The Dump manager Dbus root'
68 )
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050069conf_data.set_quoted('BMC_DUMP_OBJPATH', get_option('BMC_DUMP_OBJPATH'),
70 description : 'The BMC Dump manager Dbus path'
71 )
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050072conf_data.set_quoted('CORE_FILE_DIR', get_option('CORE_FILE_DIR'),
73 description : 'Directory where core dumps are placed'
74 )
75conf_data.set_quoted('OBJ_INTERNAL', get_option('OBJ_INTERNAL'),
76 description : 'Internal Dump manager Dbus object path'
77 )
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050078conf_data.set_quoted('BMC_DUMP_OBJ_ENTRY', get_option('BMC_DUMP_OBJ_ENTRY'),
79 description : 'The BMC dump entry DBus object path'
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050080 )
81conf_data.set_quoted('BMC_DUMP_PATH', get_option('BMC_DUMP_PATH'),
82 description : 'Directory where bmc dumps are placed')
George Liuff92ffe2021-02-09 15:01:53 +080083conf_data.set_quoted('SYSTEMD_PSTORE_PATH', get_option('SYSTEMD_PSTORE_PATH'),
84 description : 'Path to the systemd pstore directory')
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050085conf_data.set('BMC_DUMP_MAX_SIZE', get_option('BMC_DUMP_MAX_SIZE'),
86 description : 'Maximum size of one bmc dump in kilo bytes'
87 )
88conf_data.set('BMC_DUMP_MIN_SPACE_REQD', get_option('BMC_DUMP_MIN_SPACE_REQD'),
89 description : 'Minimum space required for one bmc dump in kilo bytes'
90 )
91conf_data.set('BMC_DUMP_TOTAL_SIZE', get_option('BMC_DUMP_TOTAL_SIZE'),
92 description : 'Total size of the dump in kilo bytes'
93 )
94conf_data.set_quoted('OBJ_LOGGING', '/xyz/openbmc_project/logging',
95 description : 'The log manager DBus object path'
96 )
97conf_data.set_quoted('ELOG_ID_PERSIST_PATH', get_option('ELOG_ID_PERSIST_PATH'),
98 description : 'Path of file for storing elog id\'s, which have associated dumps'
99 )
100conf_data.set('CLASS_VERSION', get_option('CLASS_VERSION'),
101 description : 'Class version to register with Cereal'
102 )
103conf_data.set('ERROR_MAP_YAML', get_option('ERROR_MAP_YAML'),
104 description : 'YAML filepath containing error object paths'
105 )
Chirag Sharmae22aca72021-01-18 09:55:29 -0600106conf_data.set('JFFS_CORE_FILE_WORKAROUND', get_option('jffs-workaround').enabled(),
107 description : 'Turn on jffs workaround for core file'
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500108 )
Claire Weinan919f71c2022-03-01 19:02:07 -0800109conf_data.set_quoted('FAULTLOG_DUMP_OBJ_ENTRY', get_option('FAULTLOG_DUMP_OBJ_ENTRY'),
110 description : 'The Fault Log dump entry DBus object path'
111 )
112conf_data.set_quoted('FAULTLOG_DUMP_OBJPATH', get_option('FAULTLOG_DUMP_OBJPATH'),
113 description : 'The Fault Log Dump manager Dbus path'
114 )
115conf_data.set_quoted('FAULTLOG_DUMP_PATH', get_option('FAULTLOG_DUMP_PATH'),
116 description : 'Directory where fault logs are placed'
117 )
Xie Ningfc69f352022-05-17 16:06:52 +0800118conf_data.set('BMC_DUMP_ROTATE_CONFIG', get_option('dump_rotate_config').enabled(),
119 description : 'Turn on rotate config for bmc dump'
120 )
Dhruvaraj Subhashchandran3c5def32023-07-09 04:31:28 -0500121conf_data.set('DUMP_TYPES_YAML', get_option('DUMP_TYPES_YAML'),
122 description : 'YAML filepath containing dump types'
123 )
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500124
125configure_file(configuration : conf_data,
126 output : 'config.h'
127 )
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500128python = find_program('python3')
Dhruvaraj Subhashchandran3c5def32023-07-09 04:31:28 -0500129map_gen_file_loc = meson.project_source_root()
130map_gen_file_loc += '/map_gen.py'
131
132dump_types_hpp = custom_target(
133 'dump_types.hpp',
134 command : [
135 python,
136 map_gen_file_loc,
137 '-i',
138 get_option('DUMP_TYPES_YAML'),
139 '-t',
140 'dump_types.mako.hpp',
141 '-v',
142 'DUMP_TYPE_TABLE',
143 '-o',
144 'dump_types.hpp'
145 ],
146 depend_files : [ 'dump_types.mako.hpp',
147 'map_gen.py',
148 get_option('DUMP_TYPES_YAML')
149 ],
150 output : 'dump_types.hpp'
151 )
152
153dump_types_cpp = custom_target(
154 'dump_types.cpp',
155 command : [
156 python,
157 map_gen_file_loc,
158 '-i',
159 get_option('DUMP_TYPES_YAML'),
160 '-t',
161 'dump_types.mako.cpp',
162 '-v',
163 'DUMP_TYPE_TABLE',
164 '-o',
165 'dump_types.cpp'
166 ],
167 depend_files : [ 'dump_types.mako.cpp',
168 'map_gen.py',
169 get_option('DUMP_TYPES_YAML')
170 ],
171 output : 'dump_types.cpp'
172 )
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500173
Dhruvaraj Subhashchandran0518b742023-05-31 14:58:47 -0500174errors_map_cpp = custom_target(
175 'errors_map.cpp',
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500176 command : [
177 python,
Dhruvaraj Subhashchandran3c5def32023-07-09 04:31:28 -0500178 map_gen_file_loc,
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500179 '-i',
Dhruvaraj Subhashchandran3c5def32023-07-09 04:31:28 -0500180 get_option('ERROR_MAP_YAML'),
181 '-t',
182 'errors_map.mako.cpp',
183 '-v',
184 'errDict',
185 '-o',
186 'errors_map.cpp'
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500187 ],
Dhruvaraj Subhashchandran0518b742023-05-31 14:58:47 -0500188 depend_files : [ 'errors_map.mako.cpp',
Dhruvaraj Subhashchandran3c5def32023-07-09 04:31:28 -0500189 'map_gen.py',
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500190 get_option('ERROR_MAP_YAML')
191 ],
Dhruvaraj Subhashchandran0518b742023-05-31 14:58:47 -0500192 output : 'errors_map.cpp'
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500193 )
194
195phosphor_dump_manager_sources = [
196 'dump_entry.cpp',
197 'dump_manager.cpp',
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -0500198 'dump_manager_bmc.cpp',
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500199 'dump_manager_main.cpp',
200 'dump_serialize.cpp',
201 'elog_watch.cpp',
Dhruvaraj Subhashchandran0518b742023-05-31 14:58:47 -0500202 errors_map_cpp,
Dhruvaraj Subhashchandran3c5def32023-07-09 04:31:28 -0500203 dump_types_hpp,
204 dump_types_cpp,
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500205 'watch.cpp',
206 'bmc_dump_entry.cpp',
207 'dump_utils.cpp',
Claire Weinan919f71c2022-03-01 19:02:07 -0800208 'dump_offload.cpp',
209 'dump_manager_faultlog.cpp',
Dhruvaraj Subhashchandran3c5def32023-07-09 04:31:28 -0500210 'faultlog_dump_entry.cpp'
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500211 ]
212
213phosphor_dump_manager_dependency = [
George Liu73e0bab2021-06-29 15:57:43 +0800214 phosphor_dbus_interfaces_dep,
215 sdbusplus_dep,
Marri Devender Rao3ed02c32022-06-28 23:12:14 -0500216 sdeventplus_dep,
George Liu73e0bab2021-06-29 15:57:43 +0800217 phosphor_logging_dep,
Patrick Williamsabbe1592021-10-01 16:04:19 -0500218 cereal_dep,
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500219 ]
220
221phosphor_dump_manager_install = true
222
Ramesh Iyyar3af5c322020-12-04 00:38:42 -0600223phosphor_dump_manager_incdir = []
224
Ramesh Iyyar131994b2020-12-03 08:35:36 -0600225# To get host transport based interface to take respective host
226# dump actions. It will contain required sources and dependency
227# list for phosphor_dump_manager.
228subdir('host-transport-extensions')
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500229
Dhruvaraj Subhashchandran8b9b4692020-09-24 11:59:42 -0500230#pick any architecture specific dumps
231subdir('dump-extensions')
232
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500233phosphor_dump_monitor_sources = [
234 'core_manager.cpp',
235 'core_manager_main.cpp',
236 'watch.cpp'
237 ]
238
239phosphor_dump_monitor_dependency = [
George Liu73e0bab2021-06-29 15:57:43 +0800240 phosphor_dbus_interfaces_dep,
Dhruvaraj Subhashchandrand1f670f2023-06-05 22:19:25 -0500241 phosphor_logging_dep
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500242 ]
243
244phosphor_dump_monitor_install = true
245
Ramesh Iyyar3af5c322020-12-04 00:38:42 -0600246phosphor_dump_monitor_incdir = []
247
George Liuff92ffe2021-02-09 15:01:53 +0800248phosphor_ramoops_monitor_sources = [
249 'ramoops_manager.cpp',
250 'ramoops_manager_main.cpp',
251 'watch.cpp'
252 ]
253
254phosphor_ramoops_monitor_dependency = [
George Liu858fbb22021-07-01 12:25:44 +0800255 phosphor_dbus_interfaces_dep,
Dhruvaraj Subhashchandrand1f670f2023-06-05 22:19:25 -0500256 phosphor_logging_dep
George Liuff92ffe2021-02-09 15:01:53 +0800257 ]
258
259phosphor_ramoops_monitor_install = true
260
261phosphor_ramoops_monitor_incdir = []
262
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500263executables = [[ 'phosphor-dump-manager',
264 phosphor_dump_manager_sources,
265 phosphor_dump_manager_dependency,
Ramesh Iyyar3af5c322020-12-04 00:38:42 -0600266 phosphor_dump_manager_install,
267 phosphor_dump_manager_incdir
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500268 ],
269 [ 'phosphor-dump-monitor',
270 phosphor_dump_monitor_sources,
271 phosphor_dump_monitor_dependency,
Ramesh Iyyar3af5c322020-12-04 00:38:42 -0600272 phosphor_dump_monitor_install,
273 phosphor_dump_monitor_incdir
George Liuff92ffe2021-02-09 15:01:53 +0800274 ],
275 [ 'phosphor-ramoops-monitor',
276 phosphor_ramoops_monitor_sources,
277 phosphor_ramoops_monitor_dependency,
278 phosphor_ramoops_monitor_install,
279 phosphor_ramoops_monitor_incdir
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500280 ]
281 ]
282
283foreach executable : executables
284 binary = executable(
285 executable[0],
286 executable[1],
287 dependencies: executable[2],
Ramesh Iyyar3af5c322020-12-04 00:38:42 -0600288 install : executable[3],
289 include_directories : executable[4]
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500290 )
291endforeach
Chirag Sharma50427252020-08-11 12:11:38 -0500292
Dhruvaraj Subhashchandran9f557362021-05-12 06:28:20 -0500293unit_subs = configuration_data()
294unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
Patrick Williams6c84a8c2023-04-12 08:10:41 -0500295systemd_system_unit_dir = dependency('systemd').get_variable(
Dhruvaraj Subhashchandran9f557362021-05-12 06:28:20 -0500296 'systemdsystemunitdir',
Patrick Williams6c84a8c2023-04-12 08:10:41 -0500297 pkgconfig_define: ['prefix', get_option('prefix')])
Dhruvaraj Subhashchandran9f557362021-05-12 06:28:20 -0500298foreach u : unit_files
299 configure_file(
300 configuration: unit_subs,
301 input: u.get('input'),
302 install: true,
303 install_dir: systemd_system_unit_dir,
304 output: u.get('output')
305 )
306endforeach
307
Chirag Sharma50427252020-08-11 12:11:38 -0500308if get_option('tests').enabled()
309 subdir('test')
310endif