1project('phosphor-logging', 'cpp', 2 meson_version: '>= 0.57.0', 3 default_options: [ 4 'buildtype=debugoptimized', 5 'cpp_std=c++20', 6 'warning_level=3', 7 'werror=true', 8 'tests=' + (meson.is_subproject() ? 'disabled' : 'auto'), 9 ], 10 version: '1.0.0', 11) 12 13cpp = meson.get_compiler('cpp') 14python_prog = find_program('python3') 15 16# Get sdbusplus dependency. 17sdbusplus_dep = dependency('sdbusplus', required: false) 18if sdbusplus_dep.found() 19 sdbusplusplus_prog = find_program('sdbus++') 20 sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson') 21else 22 sdbusplus_proj = subproject('sdbusplus', required: true) 23 sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep') 24 sdbusplusplus_prog = sdbusplus_proj.get_variable('sdbusplusplus_prog') 25 sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable( 26 'sdbuspp_gen_meson_prog' 27 ) 28endif 29 30# Get PDI and sdeventplus dependency. 31pdi_vars = [] 32if not get_option('openpower-pel-extension').disabled() 33 pdi_vars += [ 'data_org_open_power=true' ] 34endif 35pdi_dep = dependency( 36 'phosphor-dbus-interfaces', 37 fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep'], 38 default_options: pdi_vars, 39) 40sdeventplus_dep = dependency( 41 'sdeventplus', 42 fallback: ['sdeventplus', 'sdeventplus_dep' ], 43) 44 45# Get Cereal dependency. 46cereal_dep = dependency('cereal', required: false) 47has_cereal = cpp.has_header_symbol( 48 'cereal/cereal.hpp', 49 'cereal::specialize', 50 dependencies: cereal_dep, 51 required: false) 52if not has_cereal 53 cereal_opts = import('cmake').subproject_options() 54 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'}) 55 cereal_proj = import('cmake').subproject( 56 'cereal', 57 options: cereal_opts, 58 required: false) 59 assert(cereal_proj.found(), 'cereal is required') 60 cereal_dep = cereal_proj.get_variable('cm_cereal_dep') 61endif 62 63# Find the installed YAML directory, either from a configure option or 64# by pulling it from the PDI dependency. 65yamldir = get_option('yamldir') 66if yamldir == '' 67 yamldir = pdi_dep.get_variable(pkgconfig: 'yamldir', internal: 'yamldir') 68endif 69 70# Create config.h with constants that use to come from autoconf. 71conf_data = configuration_data() 72conf_data.set('error_cap', get_option('error_cap')) 73conf_data.set('error_info_cap', get_option('error_info_cap')) 74configure_file( 75 input: 'config.h.meson', 76 output: 'config.h', 77 configuration: conf_data, 78) 79 80# Generate sdbus++ files. 81generated_sources = [] 82generated_others = [] 83subdir('gen') 84subdir('gen/xyz') 85 86# Generate callouts-gen.hpp. 87callouts_gen = custom_target('callouts-gen.hpp'.underscorify(), 88 input: [ 89 'callouts/callouts.py', 90 'callouts/callouts-gen.mako.hpp', 91 get_option('callout_yaml'), 92 ], 93 output: 'callouts-gen.hpp', 94 command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@', '-o', '@OUTPUT0@' ], 95) 96# Generate elog-lookup.cpp 97elog_lookup_gen = custom_target('elog-lookup.cpp'.underscorify(), 98 input: files( 99 'tools/elog-gen.py', 100 'tools/phosphor-logging/templates/elog-lookup-template.mako.cpp', 101 ), 102 output: 'elog-lookup.cpp', 103 command: [ 104 python_prog, '@INPUT0@', 105 '-t', '', 106 '-m', '@INPUT1@', 107 '-y', yamldir, 108 '-u', meson.current_source_dir() / '../tools/', 109 '-o', '@OUTPUT0@', 110 ], 111) 112# Generate elog-process-metadata.cpp 113elog_process_gen = custom_target('elog-process-metadata.cpp'.underscorify(), 114 input: files( 115 'tools/elog-gen.py', 116 'tools/phosphor-logging/templates/elog-process-metadata.mako.cpp', 117 ), 118 output: 'elog-process-metadata.cpp', 119 command: [ 120 python_prog, '@INPUT0@', 121 '-t', '', 122 '-m', '@INPUT1@', 123 '-y', yamldir, 124 '-u', meson.current_source_dir() / '../tools/', 125 '-o', '@OUTPUT0@', 126 ], 127) 128 129subdir('phosphor-logging') 130 131log_manager_ext_sources = [] 132log_manager_ext_deps = [] 133 134subdir('extensions') 135subdir('phosphor-rsyslog-config') 136 137# Build libphosphor-logging. 138libphosphor_logging = library( 139 'phosphor_logging', 140 files( 141 'elog.cpp', 142 'elog_meta.cpp', 143 'sdjournal.cpp', 144 ), 145 callouts_gen, 146 elog_errors_gen, 147 dependencies: [ sdbusplus_dep, pdi_dep, sdeventplus_dep ], 148 version: meson.project_version(), 149 install: true, 150) 151 152import('pkgconfig').generate( 153 libphosphor_logging, 154 name: meson.project_name(), 155 version: meson.project_version(), 156 requires: [ 157 'libsystemd', 158 'phosphor-dbus-interfaces', 159 'sdbusplus', 160 ], 161 description: 'Phosphor logging utilities', 162) 163 164# Create dependency for use as subproject. 165phosphor_logging_dep = declare_dependency( 166 include_directories: include_directories('.'), 167 link_with: libphosphor_logging, 168 sources: [ callouts_gen, elog_errors_gen ], 169 dependencies: [ sdbusplus_dep, pdi_dep, sdeventplus_dep], 170) 171 172# Generate daemon. 173log_manager_sources = [ 174 generated_sources, 175 elog_errors_gen, 176 elog_lookup_gen, 177 elog_process_gen, 178 files( 179 'elog_entry.cpp', 180 'elog_meta.cpp', 181 'elog_serialize.cpp', 182 'extensions.cpp', 183 'log_manager.cpp', 184 'sdjournal.cpp', 185 'util.cpp', 186 ) 187] 188log_manager_deps = [ 189 cereal_dep, 190 pdi_dep, 191 sdbusplus_dep, 192 sdeventplus_dep, 193] 194executable('phosphor-log-manager', 195 log_manager_sources, 196 log_manager_ext_sources, 197 'log_manager_main.cpp', 198 include_directories: include_directories('gen'), 199 link_with: libphosphor_logging, 200 dependencies: [ 201 log_manager_deps, 202 log_manager_ext_deps, 203 ], 204 install: true, 205) 206# Generate test executables which run in obmc env (qemu, real hardware). 207executable('logging-test', 208 'logging_test.cpp', 209 link_with: libphosphor_logging, 210 dependencies: [ 211 elog_errors_dep, 212 pdi_dep, 213 sdbusplus_dep, 214 ], 215 install: true, 216) 217executable('callout-test', 218 'callouts/callout_test.cpp', 219 link_with: libphosphor_logging, 220 dependencies: [ 221 elog_errors_dep, 222 pdi_dep, 223 sdbusplus_dep, 224 sdeventplus_dep, 225 ], 226 install: true, 227) 228 229subdir('dist') 230 231if not get_option('tests').disabled() 232 subdir('test') 233endif 234