1f06056bcSPatrick Williamsproject('phosphor-logging', 'cpp', 2f06056bcSPatrick Williams meson_version: '>= 0.57.0', 3f06056bcSPatrick Williams default_options: [ 4f06056bcSPatrick Williams 'buildtype=debugoptimized', 5f06056bcSPatrick Williams 'cpp_std=c++20', 6f06056bcSPatrick Williams 'warning_level=3', 7f06056bcSPatrick Williams 'werror=true', 8f06056bcSPatrick Williams ], 9f06056bcSPatrick Williams version: '1.0.0', 10f06056bcSPatrick Williams) 11f06056bcSPatrick Williams 12f06056bcSPatrick Williamspython_prog = find_program('python3') 13f06056bcSPatrick Williams 14f06056bcSPatrick Williams# Get sdbusplus dependency. 15f06056bcSPatrick Williamssdbusplus_dep = dependency('sdbusplus', required: false) 16f06056bcSPatrick Williamsif sdbusplus_dep.found() 17f06056bcSPatrick Williams sdbusplusplus_prog = find_program('sdbus++') 18f06056bcSPatrick Williams sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson') 19f06056bcSPatrick Williamselse 20f06056bcSPatrick Williams sdbusplus_proj = subproject('sdbusplus', required: true) 21f06056bcSPatrick Williams sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep') 22f06056bcSPatrick Williams sdbusplusplus_prog = sdbusplus_proj.get_variable('sdbusplusplus_prog') 23f06056bcSPatrick Williams sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable( 24f06056bcSPatrick Williams 'sdbuspp_gen_meson_prog' 25f06056bcSPatrick Williams ) 26f06056bcSPatrick Williamsendif 27f06056bcSPatrick Williams 28f06056bcSPatrick Williams# Get PDI and sdeventplus dependency. 29f06056bcSPatrick Williamspdi_dep = dependency( 30f06056bcSPatrick Williams 'phosphor-dbus-interfaces', 31f06056bcSPatrick Williams fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep'], 32f06056bcSPatrick Williams) 33f06056bcSPatrick Williamssdeventplus_dep = dependency( 34f06056bcSPatrick Williams 'sdeventplus', 35f06056bcSPatrick Williams fallback: ['sdeventplus', 'sdeventplus_dep' ], 36f06056bcSPatrick Williams) 37f06056bcSPatrick Williams 380bb89f8aSPatrick Williams# Get Cereal dependency. 390bb89f8aSPatrick Williamscereal_dep = dependency('cereal', required: false) 400bb89f8aSPatrick Williamsif not cereal_dep.found() 410bb89f8aSPatrick Williams subproject('cereal', required: false) 420bb89f8aSPatrick Williams cereal_dep = declare_dependency( 430bb89f8aSPatrick Williams include_directories: [ 'subprojects/cereal/include' ], 440bb89f8aSPatrick Williams ) 450bb89f8aSPatrick Williamsendif 460bb89f8aSPatrick Williams 47f06056bcSPatrick Williams# Find the installed YAML directory, either from a configure option or 48f06056bcSPatrick Williams# by pulling it from the PDI dependency. 49f06056bcSPatrick Williamsyamldir = get_option('yamldir') 50f06056bcSPatrick Williamsif yamldir == '' 51f06056bcSPatrick Williams yamldir = pdi_dep.get_variable(pkgconfig: 'yamldir', internal: 'yamldir') 52f06056bcSPatrick Williamsendif 53f06056bcSPatrick Williams 54f06056bcSPatrick Williams# Create config.h with constants that use to come from autoconf. 55f06056bcSPatrick Williamsconf_data = configuration_data() 560bb89f8aSPatrick Williamsconf_data.set('error_cap', get_option('error_cap')) 570bb89f8aSPatrick Williamsconf_data.set('error_info_cap', get_option('error_info_cap')) 58f06056bcSPatrick Williamsconfigure_file( 59f06056bcSPatrick Williams input: 'config.h.meson', 60f06056bcSPatrick Williams output: 'config.h', 61f06056bcSPatrick Williams configuration: conf_data, 62f06056bcSPatrick Williams) 63f06056bcSPatrick Williams 640bb89f8aSPatrick Williams# Generate sdbus++ files. 650bb89f8aSPatrick Williamsgenerated_sources = [] 660bb89f8aSPatrick Williamsgenerated_others = [] 670bb89f8aSPatrick Williamssubdir('gen') 680bb89f8aSPatrick Williamssubdir('gen/xyz') 690bb89f8aSPatrick Williams 70f06056bcSPatrick Williams# Generate callouts-gen.hpp. 71f06056bcSPatrick Williamscallouts_gen = custom_target('callouts-gen.hpp'.underscorify(), 72f06056bcSPatrick Williams input: [ 73f06056bcSPatrick Williams 'callouts/callouts.py', 74f06056bcSPatrick Williams 'callouts/callouts-gen.mako.hpp', 75f06056bcSPatrick Williams get_option('callout_yaml'), 76f06056bcSPatrick Williams ], 77f06056bcSPatrick Williams output: 'callouts-gen.hpp', 78f06056bcSPatrick Williams command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@', '-o', '@OUTPUT0@' ], 79f06056bcSPatrick Williams) 800bb89f8aSPatrick Williams# Generate elog-lookup.cpp 810bb89f8aSPatrick Williamselog_lookup_gen = custom_target('elog-lookup.cpp'.underscorify(), 820bb89f8aSPatrick Williams input: files( 830bb89f8aSPatrick Williams 'tools/elog-gen.py', 840bb89f8aSPatrick Williams 'tools/phosphor-logging/templates/elog-lookup-template.mako.cpp', 850bb89f8aSPatrick Williams ), 860bb89f8aSPatrick Williams output: 'elog-lookup.cpp', 870bb89f8aSPatrick Williams command: [ 880bb89f8aSPatrick Williams python_prog, '@INPUT0@', 890bb89f8aSPatrick Williams '-t', '', 900bb89f8aSPatrick Williams '-m', '@INPUT1@', 910bb89f8aSPatrick Williams '-y', yamldir, 920bb89f8aSPatrick Williams '-u', meson.current_source_dir() / '../tools/', 930bb89f8aSPatrick Williams '-o', '@OUTPUT0@', 940bb89f8aSPatrick Williams ], 950bb89f8aSPatrick Williams) 960bb89f8aSPatrick Williams# Generate elog-process-metadata.cpp 970bb89f8aSPatrick Williamselog_process_gen = custom_target('elog-process-metadata.cpp'.underscorify(), 980bb89f8aSPatrick Williams input: files( 990bb89f8aSPatrick Williams 'tools/elog-gen.py', 1000bb89f8aSPatrick Williams 'tools/phosphor-logging/templates/elog-process-metadata.mako.cpp', 1010bb89f8aSPatrick Williams ), 1020bb89f8aSPatrick Williams output: 'elog-process-metadata.cpp', 1030bb89f8aSPatrick Williams command: [ 1040bb89f8aSPatrick Williams python_prog, '@INPUT0@', 1050bb89f8aSPatrick Williams '-t', '', 1060bb89f8aSPatrick Williams '-m', '@INPUT1@', 1070bb89f8aSPatrick Williams '-y', yamldir, 1080bb89f8aSPatrick Williams '-u', meson.current_source_dir() / '../tools/', 1090bb89f8aSPatrick Williams '-o', '@OUTPUT0@', 1100bb89f8aSPatrick Williams ], 1110bb89f8aSPatrick Williams) 112f06056bcSPatrick Williams 113f06056bcSPatrick Williamssubdir('phosphor-logging') 114*b2b27085SPatrick Williamssubdir('phosphor-rsyslog-config') 115f06056bcSPatrick Williams 116f06056bcSPatrick Williams# Build libphosphor-logging. 117f06056bcSPatrick Williamslibphosphor_logging = library( 118f06056bcSPatrick Williams 'phosphor_logging', 119f06056bcSPatrick Williams files( 120f06056bcSPatrick Williams 'elog.cpp', 121f06056bcSPatrick Williams 'elog_meta.cpp', 122f06056bcSPatrick Williams 'sdjournal.cpp', 123f06056bcSPatrick Williams ), 124f06056bcSPatrick Williams callouts_gen, 125f06056bcSPatrick Williams elog_errors_gen, 126f06056bcSPatrick Williams dependencies: [ sdbusplus_dep, pdi_dep, sdeventplus_dep ], 127f06056bcSPatrick Williams version: meson.project_version(), 128f06056bcSPatrick Williams install: true, 129f06056bcSPatrick Williams) 130f06056bcSPatrick Williams 131f06056bcSPatrick Williamsimport('pkgconfig').generate( 132f06056bcSPatrick Williams libphosphor_logging, 133f06056bcSPatrick Williams name: meson.project_name(), 134f06056bcSPatrick Williams version: meson.project_version(), 135f06056bcSPatrick Williams requires: [ 136f06056bcSPatrick Williams 'libsystemd', 137f06056bcSPatrick Williams 'phosphor-dbus-interfaces', 138f06056bcSPatrick Williams 'sdbusplus', 139f06056bcSPatrick Williams ], 140f06056bcSPatrick Williams description: 'Phosphor logging utilities', 141f06056bcSPatrick Williams) 142f06056bcSPatrick Williams 143f06056bcSPatrick Williams# Create dependency for use as subproject. 144f06056bcSPatrick Williamsphosphor_logging_dep = declare_dependency( 145f06056bcSPatrick Williams include_directories: include_directories('.'), 146f06056bcSPatrick Williams link_with: libphosphor_logging, 147f06056bcSPatrick Williams sources: [ callouts_gen, elog_errors_gen ], 148f06056bcSPatrick Williams dependencies: [ sdbusplus_dep, pdi_dep, sdeventplus_dep], 149f06056bcSPatrick Williams) 1500bb89f8aSPatrick Williams 1510bb89f8aSPatrick Williams# Generate daemon. 152a517197dSPatrick Williamslog_manager_sources = [ 1530bb89f8aSPatrick Williams generated_sources, 1540bb89f8aSPatrick Williams elog_lookup_gen, 1550bb89f8aSPatrick Williams elog_process_gen, 156a517197dSPatrick Williams files( 1570bb89f8aSPatrick Williams 'elog_entry.cpp', 1580bb89f8aSPatrick Williams 'elog_meta.cpp', 1590bb89f8aSPatrick Williams 'elog_serialize.cpp', 1600bb89f8aSPatrick Williams 'extensions.cpp', 1610bb89f8aSPatrick Williams 'log_manager.cpp', 1620bb89f8aSPatrick Williams 'sdjournal.cpp', 1630bb89f8aSPatrick Williams 'util.cpp', 164a517197dSPatrick Williams ) 165a517197dSPatrick Williams] 166a517197dSPatrick Williamsexecutable('phosphor-log-manager', 167a517197dSPatrick Williams log_manager_sources, 168a517197dSPatrick Williams 'log_manager_main.cpp', 1690bb89f8aSPatrick Williams include_directories: include_directories('gen'), 1700bb89f8aSPatrick Williams link_with: libphosphor_logging, 1710bb89f8aSPatrick Williams dependencies: [ 1720bb89f8aSPatrick Williams cereal_dep, 1730bb89f8aSPatrick Williams pdi_dep, 1740bb89f8aSPatrick Williams sdbusplus_dep, 1750bb89f8aSPatrick Williams sdeventplus_dep 1760bb89f8aSPatrick Williams ], 1770bb89f8aSPatrick Williams install: true, 1780bb89f8aSPatrick Williams) 179ddd4fac0SPatrick Williams# Generate test executables which run in obmc env (qemu, real hardware). 180ddd4fac0SPatrick Williamsexecutable('logging-test', 181ddd4fac0SPatrick Williams 'logging_test.cpp', 182ddd4fac0SPatrick Williams link_with: libphosphor_logging, 183ddd4fac0SPatrick Williams dependencies: [ 184ddd4fac0SPatrick Williams elog_errors_dep, 185ddd4fac0SPatrick Williams pdi_dep, 186ddd4fac0SPatrick Williams sdbusplus_dep, 187ddd4fac0SPatrick Williams ], 188ddd4fac0SPatrick Williams install: true, 189ddd4fac0SPatrick Williams) 190ddd4fac0SPatrick Williamsexecutable('callout-test', 191ddd4fac0SPatrick Williams 'callouts/callout_test.cpp', 192ddd4fac0SPatrick Williams link_with: libphosphor_logging, 193ddd4fac0SPatrick Williams dependencies: [ 194ddd4fac0SPatrick Williams elog_errors_dep, 195ddd4fac0SPatrick Williams pdi_dep, 196ddd4fac0SPatrick Williams sdbusplus_dep, 197ddd4fac0SPatrick Williams sdeventplus_dep, 198ddd4fac0SPatrick Williams ], 199ddd4fac0SPatrick Williams install: true, 200ddd4fac0SPatrick Williams) 201a517197dSPatrick Williams 202a517197dSPatrick Williamsif not get_option('tests').disabled() 203a517197dSPatrick Williams subdir('test') 204a517197dSPatrick Williamsendif 205