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