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