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) 16libsystemd_dep = dependency('libsystemd') 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', 'SKIP_PERFORMANCE_COMPARISON': 'ON'}) 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# Get CLI11 dependency 64if cpp.has_header('CLI/CLI.hpp') 65 CLI11_dep = declare_dependency() 66else 67 CLI11_dep = dependency('CLI11') 68endif 69 70nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') 71 72# Generate sdbus++ files. 73generated_sources = [] 74generated_others = [] 75subdir('gen') 76subdir('gen/xyz') 77 78# Generate callouts-gen.hpp. 79callouts_gen = custom_target('callouts-gen.hpp'.underscorify(), 80 input: [ 81 'callouts/callouts.py', 82 'callouts/callouts-gen.mako.hpp', 83 get_option('callout_yaml'), 84 ], 85 output: 'callouts-gen.hpp', 86 command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@', '-o', '@OUTPUT0@' ], 87) 88# Generate elog-lookup.cpp 89elog_lookup_gen = custom_target('elog-lookup.cpp'.underscorify(), 90 input: files( 91 'tools/elog-gen.py', 92 'tools/phosphor-logging/templates/elog-lookup-template.mako.cpp', 93 ), 94 output: 'elog-lookup.cpp', 95 command: [ 96 python_prog, '@INPUT0@', 97 '-t', '', 98 '-m', '@INPUT1@', 99 '-y', yamldir, 100 '-u', meson.current_source_dir() / 'tools/', 101 '-o', '@OUTPUT0@', 102 ], 103) 104# Generate elog-process-metadata.cpp 105elog_process_gen = custom_target('elog-process-metadata.cpp'.underscorify(), 106 input: files( 107 'tools/elog-gen.py', 108 'tools/phosphor-logging/templates/elog-process-metadata.mako.cpp', 109 ), 110 output: 'elog-process-metadata.cpp', 111 command: [ 112 python_prog, '@INPUT0@', 113 '-t', '', 114 '-m', '@INPUT1@', 115 '-y', yamldir, 116 '-u', meson.current_source_dir() / 'tools/', 117 '-o', '@OUTPUT0@', 118 ], 119) 120 121log_manager_ext_sources = [] 122log_manager_ext_deps = [] 123log_manager_ext_args = [] 124 125subdir('extensions') 126subdir('phosphor-rsyslog-config') 127 128# Generate daemon. 129log_manager_sources = [ 130 generated_sources, 131 callouts_gen, 132 elog_lookup_gen, 133 elog_process_gen, 134 files( 135 'elog_entry.cpp', 136 'elog_meta.cpp', 137 'elog_serialize.cpp', 138 'extensions.cpp', 139 'log_manager.cpp', 140 'paths.cpp', 141 'util.cpp', 142 ) 143] 144log_manager_deps = [ 145 cereal_dep, 146 conf_h_dep, 147 pdi_dep, 148 phosphor_logging_dep, 149 sdbusplus_dep, 150 sdeventplus_dep, 151] 152executable('phosphor-log-manager', 153 log_manager_sources, 154 log_manager_ext_sources, 155 'log_manager_main.cpp', 156 include_directories: include_directories('gen'), 157 cpp_args: log_manager_ext_args, 158 dependencies: [ 159 log_manager_deps, 160 log_manager_ext_deps, 161 ], 162 install: true, 163) 164 165executable('log-create', 166 'log_create_main.cpp', 167 dependencies: [ 168 CLI11_dep, 169 nlohmann_json_dep, 170 pdi_dep, 171 phosphor_logging_dep, 172 sdbusplus_dep, 173 ], 174 install: true, 175) 176 177# Generate test executables which run in obmc env (qemu, real hardware). 178executable('logging-test', 179 'logging_test.cpp', 180 dependencies: [ 181 pdi_dep, 182 phosphor_logging_dep, 183 sdbusplus_dep, 184 ], 185 install: true, 186) 187executable('callout-test', 188 'callouts/callout_test.cpp', 189 dependencies: [ 190 conf_h_dep, 191 pdi_dep, 192 phosphor_logging_dep, 193 sdbusplus_dep, 194 sdeventplus_dep, 195 ], 196 install: true, 197) 198 199subdir('dist') 200 201if not get_option('tests').disabled() 202 subdir('test') 203endif 204