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