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