1project('phosphor-logging', 'cpp', 2 meson_version: '>=1.1.1', 3 default_options: [ 4 'buildtype=debugoptimized', 5 'cpp_std=c++23', 6 'warning_level=3', 7 'werror=true', 8 'libonly=' + (meson.is_subproject() ? 'true' : 'false'), 9 'tests=' + (meson.is_subproject() ? 'disabled' : 'auto'), 10 ], 11 version: '1.0.0', 12) 13cpp = meson.get_compiler('cpp') 14 15python_prog = find_program('python3', native: true) 16systemd_dep = dependency('systemd') 17 18sdbusplus_dep = dependency('sdbusplus') 19sdbusplusplus_prog = find_program('sdbus++', native: true) 20sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true) 21sdbusplusplus_depfiles = files() 22if sdbusplus_dep.type_name() == 'internal' 23 sdbusplusplus_depfiles = subproject('sdbusplus').get_variable('sdbusplusplus_depfiles') 24endif 25 26pdi_dep = dependency('phosphor-dbus-interfaces') 27 28# Find the installed YAML directory, either from a configure option or 29# by pulling it from the PDI dependency. 30yamldir = get_option('yamldir') 31if yamldir == '' 32 yamldir = pdi_dep.get_variable('yamldir') 33endif 34 35subdir('config') 36subdir('tools') 37subdir('lib') 38 39if get_option('libonly') 40 subdir_done() 41endif 42 43sdeventplus_dep = dependency('sdeventplus') 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.dependency('cereal') 61endif 62 63# Generate sdbus++ files. 64generated_sources = [] 65generated_others = [] 66subdir('gen') 67subdir('gen/xyz') 68 69# Generate callouts-gen.hpp. 70callouts_gen = custom_target('callouts-gen.hpp'.underscorify(), 71 input: [ 72 'callouts/callouts.py', 73 'callouts/callouts-gen.mako.hpp', 74 get_option('callout_yaml'), 75 ], 76 output: 'callouts-gen.hpp', 77 command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@', '-o', '@OUTPUT0@' ], 78) 79# Generate elog-lookup.cpp 80elog_lookup_gen = custom_target('elog-lookup.cpp'.underscorify(), 81 input: files( 82 'tools/elog-gen.py', 83 'tools/phosphor-logging/templates/elog-lookup-template.mako.cpp', 84 ), 85 output: 'elog-lookup.cpp', 86 command: [ 87 python_prog, '@INPUT0@', 88 '-t', '', 89 '-m', '@INPUT1@', 90 '-y', yamldir, 91 '-u', meson.current_source_dir() / 'tools/', 92 '-o', '@OUTPUT0@', 93 ], 94) 95# Generate elog-process-metadata.cpp 96elog_process_gen = custom_target('elog-process-metadata.cpp'.underscorify(), 97 input: files( 98 'tools/elog-gen.py', 99 'tools/phosphor-logging/templates/elog-process-metadata.mako.cpp', 100 ), 101 output: 'elog-process-metadata.cpp', 102 command: [ 103 python_prog, '@INPUT0@', 104 '-t', '', 105 '-m', '@INPUT1@', 106 '-y', yamldir, 107 '-u', meson.current_source_dir() / 'tools/', 108 '-o', '@OUTPUT0@', 109 ], 110) 111 112log_manager_ext_sources = [] 113log_manager_ext_deps = [] 114log_manager_ext_args = [] 115 116subdir('extensions') 117subdir('phosphor-rsyslog-config') 118 119# Generate daemon. 120log_manager_sources = [ 121 generated_sources, 122 callouts_gen, 123 elog_lookup_gen, 124 elog_process_gen, 125 files( 126 'elog_entry.cpp', 127 'elog_meta.cpp', 128 'elog_serialize.cpp', 129 'extensions.cpp', 130 'log_manager.cpp', 131 'util.cpp', 132 ) 133] 134log_manager_deps = [ 135 cereal_dep, 136 conf_h_dep, 137 pdi_dep, 138 phosphor_logging_dep, 139 sdbusplus_dep, 140 sdeventplus_dep, 141] 142executable('phosphor-log-manager', 143 log_manager_sources, 144 log_manager_ext_sources, 145 'log_manager_main.cpp', 146 include_directories: include_directories('gen'), 147 cpp_args: log_manager_ext_args, 148 dependencies: [ 149 log_manager_deps, 150 log_manager_ext_deps, 151 ], 152 install: true, 153) 154# Generate test executables which run in obmc env (qemu, real hardware). 155executable('logging-test', 156 'logging_test.cpp', 157 dependencies: [ 158 pdi_dep, 159 phosphor_logging_dep, 160 sdbusplus_dep, 161 ], 162 install: true, 163) 164executable('callout-test', 165 'callouts/callout_test.cpp', 166 dependencies: [ 167 conf_h_dep, 168 pdi_dep, 169 phosphor_logging_dep, 170 sdbusplus_dep, 171 sdeventplus_dep, 172 ], 173 install: true, 174) 175 176subdir('dist') 177 178if not get_option('tests').disabled() 179 subdir('test') 180endif 181