blob: 0bbf14b4ebebe0e416487351d5b317c6a0dce398 [file] [log] [blame]
Patrick Williamsf06056b2021-04-16 13:38:55 -05001project('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 III515653b2021-05-17 19:28:17 -07008 'tests=' + (meson.is_subproject() ? 'disabled' : 'auto'),
Patrick Williamsf06056b2021-04-16 13:38:55 -05009 ],
10 version: '1.0.0',
11)
12
Patrick Williamsd9f0d642021-04-21 15:43:21 -050013cpp = meson.get_compiler('cpp')
Patrick Williamsf06056b2021-04-16 13:38:55 -050014python_prog = find_program('python3')
15
16# Get sdbusplus dependency.
17sdbusplus_dep = dependency('sdbusplus', required: false)
18if sdbusplus_dep.found()
19 sdbusplusplus_prog = find_program('sdbus++')
20 sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson')
21else
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 )
28endif
29
30# Get PDI and sdeventplus dependency.
Patrick Williamsd9f0d642021-04-21 15:43:21 -050031pdi_vars = []
32if not get_option('openpower-pel-extension').disabled()
33 pdi_vars += [ 'data_org_open_power=true' ]
34endif
Patrick Williamsf06056b2021-04-16 13:38:55 -050035pdi_dep = dependency(
36 'phosphor-dbus-interfaces',
37 fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep'],
Patrick Williamsd9f0d642021-04-21 15:43:21 -050038 default_options: pdi_vars,
Patrick Williamsf06056b2021-04-16 13:38:55 -050039)
40sdeventplus_dep = dependency(
41 'sdeventplus',
42 fallback: ['sdeventplus', 'sdeventplus_dep' ],
43)
44
Patrick Williams0bb89f82021-04-16 16:30:04 -050045# Get Cereal dependency.
William A. Kennington III0b087762021-05-17 18:56:48 -070046cereal_dep = dependency('cereal', required: false)
47has_cereal = cpp.has_header_symbol(
48 'cereal/cereal.hpp',
49 'cereal::specialize',
50 dependencies: cereal_dep,
51 required: false)
52if 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 Williams0bb89f82021-04-16 16:30:04 -050061endif
62
Patrick Williamsf06056b2021-04-16 13:38:55 -050063# Find the installed YAML directory, either from a configure option or
64# by pulling it from the PDI dependency.
65yamldir = get_option('yamldir')
66if yamldir == ''
67 yamldir = pdi_dep.get_variable(pkgconfig: 'yamldir', internal: 'yamldir')
68endif
69
70# Create config.h with constants that use to come from autoconf.
71conf_data = configuration_data()
Patrick Williams0bb89f82021-04-16 16:30:04 -050072conf_data.set('error_cap', get_option('error_cap'))
73conf_data.set('error_info_cap', get_option('error_info_cap'))
Jayanth Othayothe8bdeea2021-06-03 03:01:16 -050074
Patrick Williamsf06056b2021-04-16 13:38:55 -050075configure_file(
76 input: 'config.h.meson',
77 output: 'config.h',
78 configuration: conf_data,
79)
80
Patrick Williams0bb89f82021-04-16 16:30:04 -050081# Generate sdbus++ files.
82generated_sources = []
83generated_others = []
84subdir('gen')
85subdir('gen/xyz')
86
Patrick Williamsf06056b2021-04-16 13:38:55 -050087# Generate callouts-gen.hpp.
88callouts_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 Williams0bb89f82021-04-16 16:30:04 -050097# Generate elog-lookup.cpp
98elog_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
114elog_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 Williamsf06056b2021-04-16 13:38:55 -0500129
Matt Spinler23517522021-06-03 08:08:52 -0600130# Install elog-gen.py and its template for others to use
131install_data('tools/elog-gen.py',
132 install_dir : get_option('datadir') / 'phosphor-logging/elog/tools'
133)
134
135install_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 Williamsf06056b2021-04-16 13:38:55 -0500140subdir('phosphor-logging')
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500141
142log_manager_ext_sources = []
143log_manager_ext_deps = []
144
145subdir('extensions')
Patrick Williamsb2b27082021-04-16 20:24:12 -0500146subdir('phosphor-rsyslog-config')
Patrick Williamsf06056b2021-04-16 13:38:55 -0500147
148# Build libphosphor-logging.
149libphosphor_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
163import('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.
176phosphor_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 Williams0bb89f82021-04-16 16:30:04 -0500182
183# Generate daemon.
Patrick Williamsa5171972021-04-16 20:10:01 -0500184log_manager_sources = [
Patrick Williams0bb89f82021-04-16 16:30:04 -0500185 generated_sources,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500186 elog_errors_gen,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500187 elog_lookup_gen,
188 elog_process_gen,
Patrick Williamsa5171972021-04-16 20:10:01 -0500189 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 Williamsd9f0d642021-04-21 15:43:21 -0500199log_manager_deps = [
200 cereal_dep,
201 pdi_dep,
202 sdbusplus_dep,
203 sdeventplus_dep,
204]
Patrick Williamsa5171972021-04-16 20:10:01 -0500205executable('phosphor-log-manager',
206 log_manager_sources,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500207 log_manager_ext_sources,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500208 'log_manager_main.cpp',
Patrick Williams0bb89f82021-04-16 16:30:04 -0500209 include_directories: include_directories('gen'),
210 link_with: libphosphor_logging,
211 dependencies: [
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500212 log_manager_deps,
213 log_manager_ext_deps,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500214 ],
215 install: true,
216)
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500217# Generate test executables which run in obmc env (qemu, real hardware).
218executable('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)
228executable('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 Williamsa5171972021-04-16 20:10:01 -0500239
Anton D. Kachalov271408b2021-03-30 13:29:00 +0200240subdir('dist')
241
Patrick Williamsa5171972021-04-16 20:10:01 -0500242if not get_option('tests').disabled()
243 subdir('test')
244endif