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')) |
Jayanth Othayoth | e8bdeea | 2021-06-03 03:01:16 -0500 | [diff] [blame] | 74 | |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 75 | configure_file( |
| 76 | input: 'config.h.meson', |
| 77 | output: 'config.h', |
| 78 | configuration: conf_data, |
| 79 | ) |
| 80 | |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 81 | # Generate sdbus++ files. |
| 82 | generated_sources = [] |
| 83 | generated_others = [] |
| 84 | subdir('gen') |
| 85 | subdir('gen/xyz') |
| 86 | |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 87 | # Generate callouts-gen.hpp. |
| 88 | callouts_gen = custom_target('callouts-gen.hpp'.underscorify(), |
| 89 | input: [ |
| 90 | 'callouts/callouts.py', |
| 91 | 'callouts/callouts-gen.mako.hpp', |
| 92 | get_option('callout_yaml'), |
| 93 | ], |
| 94 | output: 'callouts-gen.hpp', |
| 95 | command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@', '-o', '@OUTPUT0@' ], |
| 96 | ) |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 97 | # Generate elog-lookup.cpp |
| 98 | elog_lookup_gen = custom_target('elog-lookup.cpp'.underscorify(), |
| 99 | input: files( |
| 100 | 'tools/elog-gen.py', |
| 101 | 'tools/phosphor-logging/templates/elog-lookup-template.mako.cpp', |
| 102 | ), |
| 103 | output: 'elog-lookup.cpp', |
| 104 | command: [ |
| 105 | python_prog, '@INPUT0@', |
| 106 | '-t', '', |
| 107 | '-m', '@INPUT1@', |
| 108 | '-y', yamldir, |
| 109 | '-u', meson.current_source_dir() / '../tools/', |
| 110 | '-o', '@OUTPUT0@', |
| 111 | ], |
| 112 | ) |
| 113 | # Generate elog-process-metadata.cpp |
| 114 | elog_process_gen = custom_target('elog-process-metadata.cpp'.underscorify(), |
| 115 | input: files( |
| 116 | 'tools/elog-gen.py', |
| 117 | 'tools/phosphor-logging/templates/elog-process-metadata.mako.cpp', |
| 118 | ), |
| 119 | output: 'elog-process-metadata.cpp', |
| 120 | command: [ |
| 121 | python_prog, '@INPUT0@', |
| 122 | '-t', '', |
| 123 | '-m', '@INPUT1@', |
| 124 | '-y', yamldir, |
| 125 | '-u', meson.current_source_dir() / '../tools/', |
| 126 | '-o', '@OUTPUT0@', |
| 127 | ], |
| 128 | ) |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 129 | |
Matt Spinler | 2351752 | 2021-06-03 08:08:52 -0600 | [diff] [blame] | 130 | # Install elog-gen.py and its template for others to use |
| 131 | install_data('tools/elog-gen.py', |
| 132 | install_dir : get_option('datadir') / 'phosphor-logging/elog/tools' |
| 133 | ) |
| 134 | |
| 135 | install_data('tools/phosphor-logging/templates/elog-gen-template.mako.hpp', |
| 136 | install_dir : get_option('datadir') / |
| 137 | 'phosphor-logging/elog/tools/phosphor-logging/templates' |
| 138 | ) |
| 139 | |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 140 | subdir('phosphor-logging') |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 141 | |
| 142 | log_manager_ext_sources = [] |
| 143 | log_manager_ext_deps = [] |
| 144 | |
| 145 | subdir('extensions') |
Patrick Williams | b2b2708 | 2021-04-16 20:24:12 -0500 | [diff] [blame] | 146 | subdir('phosphor-rsyslog-config') |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 147 | |
| 148 | # Build libphosphor-logging. |
| 149 | libphosphor_logging = library( |
| 150 | 'phosphor_logging', |
| 151 | files( |
| 152 | 'elog.cpp', |
| 153 | 'elog_meta.cpp', |
| 154 | 'sdjournal.cpp', |
| 155 | ), |
| 156 | callouts_gen, |
| 157 | elog_errors_gen, |
| 158 | dependencies: [ sdbusplus_dep, pdi_dep, sdeventplus_dep ], |
| 159 | version: meson.project_version(), |
| 160 | install: true, |
| 161 | ) |
| 162 | |
| 163 | import('pkgconfig').generate( |
| 164 | libphosphor_logging, |
| 165 | name: meson.project_name(), |
| 166 | version: meson.project_version(), |
| 167 | requires: [ |
| 168 | 'libsystemd', |
| 169 | 'phosphor-dbus-interfaces', |
| 170 | 'sdbusplus', |
| 171 | ], |
| 172 | description: 'Phosphor logging utilities', |
| 173 | ) |
| 174 | |
| 175 | # Create dependency for use as subproject. |
| 176 | phosphor_logging_dep = declare_dependency( |
| 177 | include_directories: include_directories('.'), |
| 178 | link_with: libphosphor_logging, |
| 179 | sources: [ callouts_gen, elog_errors_gen ], |
| 180 | dependencies: [ sdbusplus_dep, pdi_dep, sdeventplus_dep], |
| 181 | ) |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 182 | |
| 183 | # Generate daemon. |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 184 | log_manager_sources = [ |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 185 | generated_sources, |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 186 | elog_errors_gen, |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 187 | elog_lookup_gen, |
| 188 | elog_process_gen, |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 189 | files( |
| 190 | 'elog_entry.cpp', |
| 191 | 'elog_meta.cpp', |
| 192 | 'elog_serialize.cpp', |
| 193 | 'extensions.cpp', |
| 194 | 'log_manager.cpp', |
| 195 | 'sdjournal.cpp', |
| 196 | 'util.cpp', |
| 197 | ) |
| 198 | ] |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 199 | log_manager_deps = [ |
| 200 | cereal_dep, |
| 201 | pdi_dep, |
| 202 | sdbusplus_dep, |
| 203 | sdeventplus_dep, |
| 204 | ] |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 205 | executable('phosphor-log-manager', |
| 206 | log_manager_sources, |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 207 | log_manager_ext_sources, |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 208 | 'log_manager_main.cpp', |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 209 | include_directories: include_directories('gen'), |
| 210 | link_with: libphosphor_logging, |
| 211 | dependencies: [ |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 212 | log_manager_deps, |
| 213 | log_manager_ext_deps, |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 214 | ], |
| 215 | install: true, |
| 216 | ) |
Patrick Williams | ddd4fac | 2021-04-16 16:40:43 -0500 | [diff] [blame] | 217 | # Generate test executables which run in obmc env (qemu, real hardware). |
| 218 | executable('logging-test', |
| 219 | 'logging_test.cpp', |
| 220 | link_with: libphosphor_logging, |
| 221 | dependencies: [ |
| 222 | elog_errors_dep, |
| 223 | pdi_dep, |
| 224 | sdbusplus_dep, |
| 225 | ], |
| 226 | install: true, |
| 227 | ) |
| 228 | executable('callout-test', |
| 229 | 'callouts/callout_test.cpp', |
| 230 | link_with: libphosphor_logging, |
| 231 | dependencies: [ |
| 232 | elog_errors_dep, |
| 233 | pdi_dep, |
| 234 | sdbusplus_dep, |
| 235 | sdeventplus_dep, |
| 236 | ], |
| 237 | install: true, |
| 238 | ) |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 239 | |
Anton D. Kachalov | 271408b | 2021-03-30 13:29:00 +0200 | [diff] [blame] | 240 | subdir('dist') |
| 241 | |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 242 | if not get_option('tests').disabled() |
| 243 | subdir('test') |
| 244 | endif |