blob: 4b544b0477340728668c60f02b373c4f86bafd2e [file] [log] [blame]
Patrick Williams5383d762025-02-01 08:36:24 -05001project(
2 'phosphor-logging',
3 'cpp',
Patrick Williams19257fd2023-07-12 11:15:09 -05004 meson_version: '>=1.1.1',
Patrick Williamsf06056b2021-04-16 13:38:55 -05005 default_options: [
Patrick Williams5383d762025-02-01 08:36:24 -05006 'buildtype=debugoptimized',
7 'cpp_std=c++23',
8 'warning_level=3',
9 'werror=true',
10 'libonly=' + (meson.is_subproject() ? 'true' : 'false'),
11 'tests=' + (meson.is_subproject() ? 'disabled' : 'auto'),
Patrick Williamsf06056b2021-04-16 13:38:55 -050012 ],
13 version: '1.0.0',
14)
Patrick Williams62bc9682022-03-21 09:23:11 -050015cpp = meson.get_compiler('cpp')
Patrick Williamsf06056b2021-04-16 13:38:55 -050016
William A. Kennington IIIe0538842021-06-11 02:01:58 -070017python_prog = find_program('python3', native: true)
Patrick Williams75762242024-09-03 15:56:43 -040018libsystemd_dep = dependency('libsystemd')
Patrick Williamsf06056b2021-04-16 13:38:55 -050019
Patrick Williams62bc9682022-03-21 09:23:11 -050020sdbusplus_dep = dependency('sdbusplus')
21sdbusplusplus_prog = find_program('sdbus++', native: true)
22sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true)
Patrick Williams1d038d52022-09-12 10:56:30 -050023sdbusplusplus_depfiles = files()
24if sdbusplus_dep.type_name() == 'internal'
Patrick Williams5383d762025-02-01 08:36:24 -050025 sdbusplusplus_depfiles = subproject('sdbusplus').get_variable(
26 'sdbusplusplus_depfiles',
27 )
Patrick Williams1d038d52022-09-12 10:56:30 -050028endif
Patrick Williamsf06056b2021-04-16 13:38:55 -050029
Patrick Williams62bc9682022-03-21 09:23:11 -050030pdi_dep = dependency('phosphor-dbus-interfaces')
William A. Kennington IIIe0538842021-06-11 02:01:58 -070031
32# Find the installed YAML directory, either from a configure option or
33# by pulling it from the PDI dependency.
34yamldir = get_option('yamldir')
35if yamldir == ''
Patrick Williamsff5f42f2023-04-12 08:01:04 -050036 yamldir = pdi_dep.get_variable('yamldir')
William A. Kennington IIIe0538842021-06-11 02:01:58 -070037endif
38
39subdir('config')
40subdir('tools')
41subdir('lib')
42
43if get_option('libonly')
Patrick Williams5383d762025-02-01 08:36:24 -050044 subdir_done()
William A. Kennington IIIe0538842021-06-11 02:01:58 -070045endif
46
Patrick Williams62bc9682022-03-21 09:23:11 -050047sdeventplus_dep = dependency('sdeventplus')
Patrick Williamsf06056b2021-04-16 13:38:55 -050048
Patrick Williams0bb89f82021-04-16 16:30:04 -050049# Get Cereal dependency.
William A. Kennington III0b087762021-05-17 18:56:48 -070050cereal_dep = dependency('cereal', required: false)
51has_cereal = cpp.has_header_symbol(
52 'cereal/cereal.hpp',
53 'cereal::specialize',
54 dependencies: cereal_dep,
Patrick Williams5383d762025-02-01 08:36:24 -050055 required: false,
56)
William A. Kennington III0b087762021-05-17 18:56:48 -070057if not has_cereal
58 cereal_opts = import('cmake').subproject_options()
Patrick Williams5383d762025-02-01 08:36:24 -050059 cereal_opts.add_cmake_defines(
60 {'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'},
61 )
William A. Kennington III0b087762021-05-17 18:56:48 -070062 cereal_proj = import('cmake').subproject(
63 'cereal',
64 options: cereal_opts,
Patrick Williams5383d762025-02-01 08:36:24 -050065 required: false,
66 )
William A. Kennington III0b087762021-05-17 18:56:48 -070067 assert(cereal_proj.found(), 'cereal is required')
Patrick Williams3e55d4d2021-08-26 16:44:26 -050068 cereal_dep = cereal_proj.dependency('cereal')
Patrick Williams0bb89f82021-04-16 16:30:04 -050069endif
70
Patrick Williamsdc35e302024-11-05 23:35:02 -050071# Get CLI11 dependency
72if cpp.has_header('CLI/CLI.hpp')
73 CLI11_dep = declare_dependency()
74else
75 CLI11_dep = dependency('CLI11')
76endif
77
78nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
79
Patrick Williams0bb89f82021-04-16 16:30:04 -050080# Generate sdbus++ files.
Patrick Williamsad0d7522025-01-10 14:49:12 -050081should_generate_cpp = true
82should_generate_markdown = false
83should_generate_registry = false
Patrick Williams5383d762025-02-01 08:36:24 -050084yaml_selected_subdirs = ['xyz']
Patrick Williams0bb89f82021-04-16 16:30:04 -050085subdir('gen')
Patrick Williams0bb89f82021-04-16 16:30:04 -050086
Patrick Williamsf06056b2021-04-16 13:38:55 -050087# Generate callouts-gen.hpp.
Patrick Williams5383d762025-02-01 08:36:24 -050088callouts_gen = custom_target(
89 'callouts-gen.hpp'.underscorify(),
Patrick Williamsf06056b2021-04-16 13:38:55 -050090 input: [
91 'callouts/callouts.py',
92 'callouts/callouts-gen.mako.hpp',
93 get_option('callout_yaml'),
94 ],
95 output: 'callouts-gen.hpp',
Patrick Williams5383d762025-02-01 08:36:24 -050096 command: [python_prog, '@INPUT0@', '-i', '@INPUT2@', '-o', '@OUTPUT0@'],
Patrick Williamsf06056b2021-04-16 13:38:55 -050097)
Patrick Williams0bb89f82021-04-16 16:30:04 -050098# Generate elog-lookup.cpp
Patrick Williams5383d762025-02-01 08:36:24 -050099elog_lookup_gen = custom_target(
100 'elog-lookup.cpp'.underscorify(),
Patrick Williams0bb89f82021-04-16 16:30:04 -0500101 input: files(
102 'tools/elog-gen.py',
103 'tools/phosphor-logging/templates/elog-lookup-template.mako.cpp',
104 ),
105 output: 'elog-lookup.cpp',
106 command: [
Patrick Williams5383d762025-02-01 08:36:24 -0500107 python_prog,
108 '@INPUT0@',
109 '-t',
110 '',
111 '-m',
112 '@INPUT1@',
113 '-y',
114 yamldir,
115 '-u',
116 meson.current_source_dir() / 'tools/',
117 '-o',
118 '@OUTPUT0@',
Patrick Williams0bb89f82021-04-16 16:30:04 -0500119 ],
120)
121# Generate elog-process-metadata.cpp
Patrick Williams5383d762025-02-01 08:36:24 -0500122elog_process_gen = custom_target(
123 'elog-process-metadata.cpp'.underscorify(),
Patrick Williams0bb89f82021-04-16 16:30:04 -0500124 input: files(
125 'tools/elog-gen.py',
126 'tools/phosphor-logging/templates/elog-process-metadata.mako.cpp',
127 ),
128 output: 'elog-process-metadata.cpp',
129 command: [
Patrick Williams5383d762025-02-01 08:36:24 -0500130 python_prog,
131 '@INPUT0@',
132 '-t',
133 '',
134 '-m',
135 '@INPUT1@',
136 '-y',
137 yamldir,
138 '-u',
139 meson.current_source_dir() / 'tools/',
140 '-o',
141 '@OUTPUT0@',
Patrick Williams0bb89f82021-04-16 16:30:04 -0500142 ],
143)
Patrick Williamsf06056b2021-04-16 13:38:55 -0500144
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500145log_manager_ext_sources = []
146log_manager_ext_deps = []
William A. Kennington III8fd187e2021-07-26 13:36:56 -0700147log_manager_ext_args = []
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500148
149subdir('extensions')
Patrick Williamsb2b27082021-04-16 20:24:12 -0500150subdir('phosphor-rsyslog-config')
Patrick Williamsf06056b2021-04-16 13:38:55 -0500151
Patrick Williams0bb89f82021-04-16 16:30:04 -0500152# Generate daemon.
Patrick Williamsa5171972021-04-16 20:10:01 -0500153log_manager_sources = [
Patrick Williams0bb89f82021-04-16 16:30:04 -0500154 generated_sources,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700155 callouts_gen,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500156 elog_lookup_gen,
157 elog_process_gen,
Patrick Williamsa5171972021-04-16 20:10:01 -0500158 files(
159 'elog_entry.cpp',
160 'elog_meta.cpp',
161 'elog_serialize.cpp',
162 'extensions.cpp',
163 'log_manager.cpp',
Patrick Williamsfa2d9622024-09-30 16:25:43 -0400164 'paths.cpp',
Patrick Williamsa5171972021-04-16 20:10:01 -0500165 'util.cpp',
Patrick Williams5383d762025-02-01 08:36:24 -0500166 ),
Patrick Williamsa5171972021-04-16 20:10:01 -0500167]
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500168log_manager_deps = [
169 cereal_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700170 conf_h_dep,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500171 pdi_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700172 phosphor_logging_dep,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500173 sdbusplus_dep,
174 sdeventplus_dep,
175]
Patrick Williams5383d762025-02-01 08:36:24 -0500176executable(
177 'phosphor-log-manager',
Patrick Williamsa5171972021-04-16 20:10:01 -0500178 log_manager_sources,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500179 log_manager_ext_sources,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500180 'log_manager_main.cpp',
Patrick Williams0bb89f82021-04-16 16:30:04 -0500181 include_directories: include_directories('gen'),
William A. Kennington III8fd187e2021-07-26 13:36:56 -0700182 cpp_args: log_manager_ext_args,
Patrick Williams5383d762025-02-01 08:36:24 -0500183 dependencies: [log_manager_deps, log_manager_ext_deps],
Patrick Williams0bb89f82021-04-16 16:30:04 -0500184 install: true,
185)
Patrick Williamsdc35e302024-11-05 23:35:02 -0500186
Patrick Williams5383d762025-02-01 08:36:24 -0500187executable(
188 'log-create',
Patrick Williamsdc35e302024-11-05 23:35:02 -0500189 'log_create_main.cpp',
190 dependencies: [
191 CLI11_dep,
192 nlohmann_json_dep,
193 pdi_dep,
194 phosphor_logging_dep,
195 sdbusplus_dep,
196 ],
197 install: true,
198)
199
Amithash Prasadeaa501f2025-01-23 15:37:13 -0800200executable(
201 'log-resolve',
202 'log_resolve_main.cpp',
203 dependencies: [
204 CLI11_dep,
205 nlohmann_json_dep,
206 pdi_dep,
207 phosphor_logging_dep,
208 sdbusplus_dep,
209 ],
210 install: true,
211)
212
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500213# Generate test executables which run in obmc env (qemu, real hardware).
Patrick Williams5383d762025-02-01 08:36:24 -0500214executable(
215 'logging-test',
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500216 'logging_test.cpp',
Patrick Williams5383d762025-02-01 08:36:24 -0500217 dependencies: [pdi_dep, phosphor_logging_dep, sdbusplus_dep],
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500218 install: true,
219)
Patrick Williams5383d762025-02-01 08:36:24 -0500220executable(
221 'callout-test',
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500222 'callouts/callout_test.cpp',
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500223 dependencies: [
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700224 conf_h_dep,
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500225 pdi_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700226 phosphor_logging_dep,
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500227 sdbusplus_dep,
228 sdeventplus_dep,
229 ],
230 install: true,
231)
Patrick Williamsa5171972021-04-16 20:10:01 -0500232
Anton D. Kachalov271408b2021-03-30 13:29:00 +0200233subdir('dist')
234
Patrick Williams1f2bb812025-01-30 17:47:16 -0500235if get_option('tests').allowed()
Patrick Williamsa5171972021-04-16 20:10:01 -0500236 subdir('test')
237endif