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 '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) 21 22pdi_dep = dependency('phosphor-dbus-interfaces') 23 24# Find the installed YAML directory, either from a configure option or 25# by pulling it from the PDI dependency. 26yamldir = get_option('yamldir') 27if yamldir == '' 28 yamldir = pdi_dep.get_variable(pkgconfig: 'yamldir', internal: 'yamldir') 29endif 30 31subdir('config') 32subdir('tools') 33subdir('lib') 34 35if get_option('libonly') 36 subdir_done() 37endif 38 39sdeventplus_dep = dependency('sdeventplus') 40 41# Get Cereal dependency. 42cereal_dep = dependency('cereal', required: false) 43has_cereal = cpp.has_header_symbol( 44 'cereal/cereal.hpp', 45 'cereal::specialize', 46 dependencies: cereal_dep, 47 required: false) 48if not has_cereal 49 cereal_opts = import('cmake').subproject_options() 50 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'}) 51 cereal_proj = import('cmake').subproject( 52 'cereal', 53 options: cereal_opts, 54 required: false) 55 assert(cereal_proj.found(), 'cereal is required') 56 cereal_dep = cereal_proj.dependency('cereal') 57endif 58 59# Generate sdbus++ files. 60generated_sources = [] 61generated_others = [] 62subdir('gen') 63subdir('gen/xyz') 64 65# Generate callouts-gen.hpp. 66callouts_gen = custom_target('callouts-gen.hpp'.underscorify(), 67 input: [ 68 'callouts/callouts.py', 69 'callouts/callouts-gen.mako.hpp', 70 get_option('callout_yaml'), 71 ], 72 output: 'callouts-gen.hpp', 73 command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@', '-o', '@OUTPUT0@' ], 74) 75# Generate elog-lookup.cpp 76elog_lookup_gen = custom_target('elog-lookup.cpp'.underscorify(), 77 input: files( 78 'tools/elog-gen.py', 79 'tools/phosphor-logging/templates/elog-lookup-template.mako.cpp', 80 ), 81 output: 'elog-lookup.cpp', 82 command: [ 83 python_prog, '@INPUT0@', 84 '-t', '', 85 '-m', '@INPUT1@', 86 '-y', yamldir, 87 '-u', meson.current_source_dir() / 'tools/', 88 '-o', '@OUTPUT0@', 89 ], 90) 91# Generate elog-process-metadata.cpp 92elog_process_gen = custom_target('elog-process-metadata.cpp'.underscorify(), 93 input: files( 94 'tools/elog-gen.py', 95 'tools/phosphor-logging/templates/elog-process-metadata.mako.cpp', 96 ), 97 output: 'elog-process-metadata.cpp', 98 command: [ 99 python_prog, '@INPUT0@', 100 '-t', '', 101 '-m', '@INPUT1@', 102 '-y', yamldir, 103 '-u', meson.current_source_dir() / 'tools/', 104 '-o', '@OUTPUT0@', 105 ], 106) 107 108log_manager_ext_sources = [] 109log_manager_ext_deps = [] 110log_manager_ext_args = [] 111 112subdir('extensions') 113subdir('phosphor-rsyslog-config') 114 115# Generate daemon. 116log_manager_sources = [ 117 generated_sources, 118 callouts_gen, 119 elog_lookup_gen, 120 elog_process_gen, 121 files( 122 'elog_entry.cpp', 123 'elog_meta.cpp', 124 'elog_serialize.cpp', 125 'extensions.cpp', 126 'log_manager.cpp', 127 'util.cpp', 128 ) 129] 130log_manager_deps = [ 131 cereal_dep, 132 conf_h_dep, 133 pdi_dep, 134 phosphor_logging_dep, 135 sdbusplus_dep, 136 sdeventplus_dep, 137] 138executable('phosphor-log-manager', 139 log_manager_sources, 140 log_manager_ext_sources, 141 'log_manager_main.cpp', 142 include_directories: include_directories('gen'), 143 cpp_args: log_manager_ext_args, 144 dependencies: [ 145 log_manager_deps, 146 log_manager_ext_deps, 147 ], 148 install: true, 149) 150# Generate test executables which run in obmc env (qemu, real hardware). 151executable('logging-test', 152 'logging_test.cpp', 153 dependencies: [ 154 pdi_dep, 155 phosphor_logging_dep, 156 sdbusplus_dep, 157 ], 158 install: true, 159) 160executable('callout-test', 161 'callouts/callout_test.cpp', 162 dependencies: [ 163 conf_h_dep, 164 pdi_dep, 165 phosphor_logging_dep, 166 sdbusplus_dep, 167 sdeventplus_dep, 168 ], 169 install: true, 170) 171 172subdir('dist') 173 174if not get_option('tests').disabled() 175 subdir('test') 176endif 177