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 | e053884 | 2021-06-11 02:01:58 -0700 | [diff] [blame] | 8 | 'libonly=' + (meson.is_subproject() ? 'true' : 'false'), |
William A. Kennington III | 515653b | 2021-05-17 19:28:17 -0700 | [diff] [blame] | 9 | 'tests=' + (meson.is_subproject() ? 'disabled' : 'auto'), |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 10 | ], |
| 11 | version: '1.0.0', |
| 12 | ) |
| 13 | |
William A. Kennington III | e053884 | 2021-06-11 02:01:58 -0700 | [diff] [blame] | 14 | python_prog = find_program('python3', native: true) |
| 15 | systemd_dep = dependency('systemd') |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 16 | |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 17 | sdbusplus_dep = dependency('sdbusplus', required: false) |
William A. Kennington III | e053884 | 2021-06-11 02:01:58 -0700 | [diff] [blame] | 18 | sdbusplus_proj = dependency('', required: false) |
| 19 | if not sdbusplus_dep.found() or sdbusplus_dep.type_name() == 'internal' |
| 20 | sdbusplus_proj = subproject('sdbusplus') |
| 21 | endif |
| 22 | if not sdbusplus_dep.found() |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 23 | sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep') |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 24 | endif |
| 25 | |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 26 | pdi_vars = [] |
| 27 | if not get_option('openpower-pel-extension').disabled() |
William A. Kennington III | e053884 | 2021-06-11 02:01:58 -0700 | [diff] [blame] | 28 | pdi_vars += ['data_org_open_power=true'] |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 29 | endif |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 30 | pdi_dep = dependency( |
| 31 | 'phosphor-dbus-interfaces', |
| 32 | fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep'], |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 33 | default_options: pdi_vars, |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 34 | ) |
William A. Kennington III | e053884 | 2021-06-11 02:01:58 -0700 | [diff] [blame] | 35 | |
| 36 | # Find the installed YAML directory, either from a configure option or |
| 37 | # by pulling it from the PDI dependency. |
| 38 | yamldir = get_option('yamldir') |
| 39 | if yamldir == '' |
| 40 | yamldir = pdi_dep.get_variable(pkgconfig: 'yamldir', internal: 'yamldir') |
| 41 | endif |
| 42 | |
| 43 | subdir('config') |
| 44 | subdir('tools') |
| 45 | subdir('lib') |
| 46 | |
| 47 | if get_option('libonly') |
| 48 | subdir_done() |
| 49 | endif |
| 50 | |
| 51 | cpp = meson.get_compiler('cpp') |
| 52 | |
| 53 | if sdbusplus_proj.found() |
| 54 | sdbusplusplus_prog = sdbusplus_proj.get_variable('sdbusplusplus_prog') |
| 55 | sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable( |
| 56 | 'sdbuspp_gen_meson_prog') |
| 57 | else |
| 58 | sdbusplusplus_prog = find_program('sdbus++', native: true) |
| 59 | sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true) |
| 60 | endif |
| 61 | |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 62 | sdeventplus_dep = dependency( |
| 63 | 'sdeventplus', |
| 64 | fallback: ['sdeventplus', 'sdeventplus_dep' ], |
| 65 | ) |
| 66 | |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 67 | # Get Cereal dependency. |
William A. Kennington III | 0b08776 | 2021-05-17 18:56:48 -0700 | [diff] [blame] | 68 | cereal_dep = dependency('cereal', required: false) |
| 69 | has_cereal = cpp.has_header_symbol( |
| 70 | 'cereal/cereal.hpp', |
| 71 | 'cereal::specialize', |
| 72 | dependencies: cereal_dep, |
| 73 | required: false) |
| 74 | if not has_cereal |
| 75 | cereal_opts = import('cmake').subproject_options() |
| 76 | cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'}) |
| 77 | cereal_proj = import('cmake').subproject( |
| 78 | 'cereal', |
| 79 | options: cereal_opts, |
| 80 | required: false) |
| 81 | assert(cereal_proj.found(), 'cereal is required') |
| 82 | cereal_dep = cereal_proj.get_variable('cm_cereal_dep') |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 83 | endif |
| 84 | |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 85 | # Generate sdbus++ files. |
| 86 | generated_sources = [] |
| 87 | generated_others = [] |
| 88 | subdir('gen') |
| 89 | subdir('gen/xyz') |
| 90 | |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 91 | # Generate callouts-gen.hpp. |
| 92 | callouts_gen = custom_target('callouts-gen.hpp'.underscorify(), |
| 93 | input: [ |
| 94 | 'callouts/callouts.py', |
| 95 | 'callouts/callouts-gen.mako.hpp', |
| 96 | get_option('callout_yaml'), |
| 97 | ], |
| 98 | output: 'callouts-gen.hpp', |
| 99 | command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@', '-o', '@OUTPUT0@' ], |
| 100 | ) |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 101 | # Generate elog-lookup.cpp |
| 102 | elog_lookup_gen = custom_target('elog-lookup.cpp'.underscorify(), |
| 103 | input: files( |
| 104 | 'tools/elog-gen.py', |
| 105 | 'tools/phosphor-logging/templates/elog-lookup-template.mako.cpp', |
| 106 | ), |
| 107 | output: 'elog-lookup.cpp', |
| 108 | command: [ |
| 109 | python_prog, '@INPUT0@', |
| 110 | '-t', '', |
| 111 | '-m', '@INPUT1@', |
| 112 | '-y', yamldir, |
Tim Lee | 47c7734 | 2021-07-08 09:27:58 +0800 | [diff] [blame] | 113 | '-u', meson.current_source_dir() / 'tools/', |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 114 | '-o', '@OUTPUT0@', |
| 115 | ], |
| 116 | ) |
| 117 | # Generate elog-process-metadata.cpp |
| 118 | elog_process_gen = custom_target('elog-process-metadata.cpp'.underscorify(), |
| 119 | input: files( |
| 120 | 'tools/elog-gen.py', |
| 121 | 'tools/phosphor-logging/templates/elog-process-metadata.mako.cpp', |
| 122 | ), |
| 123 | output: 'elog-process-metadata.cpp', |
| 124 | command: [ |
| 125 | python_prog, '@INPUT0@', |
| 126 | '-t', '', |
| 127 | '-m', '@INPUT1@', |
| 128 | '-y', yamldir, |
Tim Lee | 47c7734 | 2021-07-08 09:27:58 +0800 | [diff] [blame] | 129 | '-u', meson.current_source_dir() / 'tools/', |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 130 | '-o', '@OUTPUT0@', |
| 131 | ], |
| 132 | ) |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 133 | |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 134 | log_manager_ext_sources = [] |
| 135 | log_manager_ext_deps = [] |
William A. Kennington III | 8fd187e | 2021-07-26 13:36:56 -0700 | [diff] [blame] | 136 | log_manager_ext_args = [] |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 137 | |
| 138 | subdir('extensions') |
Patrick Williams | b2b2708 | 2021-04-16 20:24:12 -0500 | [diff] [blame] | 139 | subdir('phosphor-rsyslog-config') |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 140 | |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 141 | # Generate daemon. |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 142 | log_manager_sources = [ |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 143 | generated_sources, |
William A. Kennington III | e053884 | 2021-06-11 02:01:58 -0700 | [diff] [blame] | 144 | callouts_gen, |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 145 | elog_lookup_gen, |
| 146 | elog_process_gen, |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 147 | files( |
| 148 | 'elog_entry.cpp', |
| 149 | 'elog_meta.cpp', |
| 150 | 'elog_serialize.cpp', |
| 151 | 'extensions.cpp', |
| 152 | 'log_manager.cpp', |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 153 | 'util.cpp', |
| 154 | ) |
| 155 | ] |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 156 | log_manager_deps = [ |
| 157 | cereal_dep, |
William A. Kennington III | e053884 | 2021-06-11 02:01:58 -0700 | [diff] [blame] | 158 | conf_h_dep, |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 159 | pdi_dep, |
William A. Kennington III | e053884 | 2021-06-11 02:01:58 -0700 | [diff] [blame] | 160 | phosphor_logging_dep, |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 161 | sdbusplus_dep, |
| 162 | sdeventplus_dep, |
| 163 | ] |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 164 | executable('phosphor-log-manager', |
| 165 | log_manager_sources, |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 166 | log_manager_ext_sources, |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 167 | 'log_manager_main.cpp', |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 168 | include_directories: include_directories('gen'), |
William A. Kennington III | 8fd187e | 2021-07-26 13:36:56 -0700 | [diff] [blame] | 169 | cpp_args: log_manager_ext_args, |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 170 | dependencies: [ |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 171 | log_manager_deps, |
| 172 | log_manager_ext_deps, |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 173 | ], |
| 174 | install: true, |
| 175 | ) |
Patrick Williams | ddd4fac | 2021-04-16 16:40:43 -0500 | [diff] [blame] | 176 | # Generate test executables which run in obmc env (qemu, real hardware). |
| 177 | executable('logging-test', |
| 178 | 'logging_test.cpp', |
Patrick Williams | ddd4fac | 2021-04-16 16:40:43 -0500 | [diff] [blame] | 179 | dependencies: [ |
Patrick Williams | ddd4fac | 2021-04-16 16:40:43 -0500 | [diff] [blame] | 180 | pdi_dep, |
William A. Kennington III | e053884 | 2021-06-11 02:01:58 -0700 | [diff] [blame] | 181 | phosphor_logging_dep, |
Patrick Williams | ddd4fac | 2021-04-16 16:40:43 -0500 | [diff] [blame] | 182 | sdbusplus_dep, |
| 183 | ], |
| 184 | install: true, |
| 185 | ) |
| 186 | executable('callout-test', |
| 187 | 'callouts/callout_test.cpp', |
Patrick Williams | ddd4fac | 2021-04-16 16:40:43 -0500 | [diff] [blame] | 188 | dependencies: [ |
William A. Kennington III | e053884 | 2021-06-11 02:01:58 -0700 | [diff] [blame] | 189 | conf_h_dep, |
Patrick Williams | ddd4fac | 2021-04-16 16:40:43 -0500 | [diff] [blame] | 190 | pdi_dep, |
William A. Kennington III | e053884 | 2021-06-11 02:01:58 -0700 | [diff] [blame] | 191 | phosphor_logging_dep, |
Patrick Williams | ddd4fac | 2021-04-16 16:40:43 -0500 | [diff] [blame] | 192 | sdbusplus_dep, |
| 193 | sdeventplus_dep, |
| 194 | ], |
| 195 | install: true, |
| 196 | ) |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 197 | |
Anton D. Kachalov | 271408b | 2021-03-30 13:29:00 +0200 | [diff] [blame] | 198 | subdir('dist') |
| 199 | |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 200 | if not get_option('tests').disabled() |
| 201 | subdir('test') |
| 202 | endif |