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