1# SPDX-License-Identifier: Apache-2.0
2
3project('phosphor-debug-collector',
4        'cpp',
5        default_options: [
6                          'cpp_std=c++17',
7                          'warning_level=3',
8                          'werror=true',
9                          'buildtype=debugoptimized'
10                         ],
11        version: '1.0',
12        license: 'Apache-2.0'
13       )
14
15# Checking dependency external library
16
17cppfs = meson.get_compiler('cpp').find_library('stdc++fs')
18libsystemd = dependency('libsystemd', version : '>=221')
19phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
20sdbusplus = dependency('sdbusplus')
21phosphor_logging = dependency('phosphor-logging')
22
23# Disable FORTIFY_SOURCE when compiling with no optimization
24if(get_option('optimization') == '0')
25  add_project_arguments('-U_FORTIFY_SOURCE',language:['cpp','c'])
26  message('Disabling FORTIFY_SOURCE as optimization is set to 0')
27endif
28
29# Configuration header file(config.h) generation
30
31conf_data = configuration_data()
32
33conf_data.set_quoted('DUMP_BUSNAME', get_option('DUMP_BUSNAME'),
34                      description : 'The Dbus busname to own'
35                    )
36conf_data.set_quoted('DUMP_OBJPATH', get_option('DUMP_OBJPATH'),
37                      description : 'The Dump manager Dbus root'
38                    )
39conf_data.set_quoted('BMC_DUMP_OBJPATH', get_option('BMC_DUMP_OBJPATH'),
40                      description : 'The BMC Dump manager Dbus path'
41                    )
42conf_data.set_quoted('SYSTEM_DUMP_OBJPATH', get_option('SYSTEM_DUMP_OBJPATH'),
43                      description : 'The system Dump manager Dbus path'
44                    )
45conf_data.set_quoted('RESOURCE_DUMP_OBJPATH', get_option('RESOURCE_DUMP_OBJPATH'),
46                      description : 'The resource Dump manager Dbus path'
47                    )
48conf_data.set_quoted('CORE_FILE_DIR', get_option('CORE_FILE_DIR'),
49                      description : 'Directory where core dumps are placed'
50                    )
51conf_data.set_quoted('OBJ_INTERNAL', get_option('OBJ_INTERNAL'),
52                      description : 'Internal Dump manager Dbus object path'
53                    )
54conf_data.set_quoted('SYSTEM_DUMP_OBJ_ENTRY', get_option('SYSTEM_DUMP_OBJ_ENTRY'),
55                      description : 'The system dump entry DBus object path'
56                    )
57conf_data.set_quoted('RESOURCE_DUMP_OBJ_ENTRY', get_option('RESOURCE_DUMP_OBJ_ENTRY'),
58                      description : 'The resource dump entry DBus object path'
59                    )
60conf_data.set_quoted('BMC_DUMP_OBJ_ENTRY', get_option('BMC_DUMP_OBJ_ENTRY'),
61                      description : 'The BMC dump entry DBus object path'
62                    )
63conf_data.set_quoted('BMC_DUMP_PATH', get_option('BMC_DUMP_PATH'),
64                     description : 'Directory where bmc dumps are placed')
65conf_data.set('BMC_DUMP_MAX_SIZE', get_option('BMC_DUMP_MAX_SIZE'),
66               description : 'Maximum size of one bmc dump in kilo bytes'
67             )
68conf_data.set('BMC_DUMP_MIN_SPACE_REQD', get_option('BMC_DUMP_MIN_SPACE_REQD'),
69               description : 'Minimum space required for one bmc dump in kilo bytes'
70             )
71conf_data.set('BMC_DUMP_TOTAL_SIZE', get_option('BMC_DUMP_TOTAL_SIZE'),
72               description : 'Total size of the dump in kilo bytes'
73             )
74conf_data.set_quoted('OBJ_LOGGING', '/xyz/openbmc_project/logging',
75                      description : 'The log manager DBus object path'
76                    )
77conf_data.set_quoted('ELOG_ID_PERSIST_PATH', get_option('ELOG_ID_PERSIST_PATH'),
78                      description : 'Path of file for storing elog id\'s, which have associated dumps'
79                    )
80conf_data.set('CLASS_VERSION', get_option('CLASS_VERSION'),
81               description : 'Class version to register with Cereal'
82             )
83conf_data.set('ERROR_MAP_YAML', get_option('ERROR_MAP_YAML'),
84               description : 'YAML filepath containing error object paths'
85             )
86conf_data.set('JFFS_CORE_FILE_WORKAROUND', get_option('jffs-workaround').enabled(),
87               description : 'Turn on jffs workaround for core file'
88             )
89
90configure_file(configuration : conf_data,
91               output : 'config.h'
92              )
93
94subdir('xyz/openbmc_project/Dump/Internal/Create')
95
96python = find_program('python3')
97errors_map_gen_file_loc = meson.source_root()
98errors_map_gen_file_loc += '/errors_map_gen.py'
99
100errors_map_hpp = custom_target(
101                    'errors_map.hpp',
102                    command : [
103                        python,
104                        errors_map_gen_file_loc,
105                        '-i',
106                        get_option('ERROR_MAP_YAML')
107                    ],
108                    depend_files : [ 'errors_map.mako.hpp',
109                                     'errors_map_gen.py',
110                                     get_option('ERROR_MAP_YAML')
111                                   ],
112                    output : 'errors_map.hpp'
113                 )
114
115phosphor_dump_manager_sources = [
116        'dump_entry.cpp',
117        'dump_manager.cpp',
118        'dump_manager_bmc.cpp',
119        'dump_manager_main.cpp',
120        'dump_serialize.cpp',
121        'elog_watch.cpp',
122        errors_map_hpp,
123        server_hpp,
124        server_cpp,
125        'watch.cpp',
126        'bmc_dump_entry.cpp',
127        'dump_utils.cpp',
128        'dump_offload.cpp'
129    ]
130
131phosphor_dump_manager_dependency = [
132        phosphor_dbus_interfaces,
133        sdbusplus,
134        phosphor_logging,
135        cppfs
136    ]
137
138phosphor_dump_manager_install = true
139
140phosphor_dump_manager_incdir = []
141
142# To get host transport based interface to take respective host
143# dump actions. It will contain required sources and dependency
144# list for phosphor_dump_manager.
145subdir('host-transport-extensions')
146
147#pick any architecture specific dumps
148subdir('dump-extensions')
149
150phosphor_dump_monitor_sources = [
151        'core_manager.cpp',
152        'core_manager_main.cpp',
153        'watch.cpp'
154    ]
155
156phosphor_dump_monitor_dependency = [
157        phosphor_dbus_interfaces,
158        phosphor_logging,
159        cppfs
160    ]
161
162phosphor_dump_monitor_install = true
163
164phosphor_dump_monitor_incdir = []
165
166executables = [[ 'phosphor-dump-manager',
167                  phosphor_dump_manager_sources,
168                  phosphor_dump_manager_dependency,
169                  phosphor_dump_manager_install,
170                  phosphor_dump_manager_incdir
171               ],
172               [ 'phosphor-dump-monitor',
173                  phosphor_dump_monitor_sources,
174                  phosphor_dump_monitor_dependency,
175                  phosphor_dump_monitor_install,
176                  phosphor_dump_monitor_incdir
177               ]
178              ]
179
180foreach executable : executables
181    binary = executable(
182                        executable[0],
183                        executable[1],
184                        dependencies: executable[2],
185                        install : executable[3],
186                        include_directories : executable[4]
187                       )
188endforeach
189
190if get_option('tests').enabled()
191  subdir('test')
192endif
193