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