blob: e3498c02b293b759415d447d3bc275167e4676d5 [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'))
Benjamin Fairaa5d03b2021-06-15 18:44:03 -070074conf_data.set('rsyslog_server_conf', get_option('rsyslog_server_conf'))
Jayanth Othayothe8bdeea2021-06-03 03:01:16 -050075
Patrick Williamsf06056b2021-04-16 13:38:55 -050076configure_file(
77 input: 'config.h.meson',
78 output: 'config.h',
79 configuration: conf_data,
80)
81
Patrick Williams0bb89f82021-04-16 16:30:04 -050082# Generate sdbus++ files.
83generated_sources = []
84generated_others = []
85subdir('gen')
86subdir('gen/xyz')
87
Patrick Williamsf06056b2021-04-16 13:38:55 -050088# Generate callouts-gen.hpp.
89callouts_gen = custom_target('callouts-gen.hpp'.underscorify(),
90 input: [
91 'callouts/callouts.py',
92 'callouts/callouts-gen.mako.hpp',
93 get_option('callout_yaml'),
94 ],
95 output: 'callouts-gen.hpp',
96 command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@', '-o', '@OUTPUT0@' ],
97)
Patrick Williams0bb89f82021-04-16 16:30:04 -050098# Generate elog-lookup.cpp
99elog_lookup_gen = custom_target('elog-lookup.cpp'.underscorify(),
100 input: files(
101 'tools/elog-gen.py',
102 'tools/phosphor-logging/templates/elog-lookup-template.mako.cpp',
103 ),
104 output: 'elog-lookup.cpp',
105 command: [
106 python_prog, '@INPUT0@',
107 '-t', '',
108 '-m', '@INPUT1@',
109 '-y', yamldir,
110 '-u', meson.current_source_dir() / '../tools/',
111 '-o', '@OUTPUT0@',
112 ],
113)
114# Generate elog-process-metadata.cpp
115elog_process_gen = custom_target('elog-process-metadata.cpp'.underscorify(),
116 input: files(
117 'tools/elog-gen.py',
118 'tools/phosphor-logging/templates/elog-process-metadata.mako.cpp',
119 ),
120 output: 'elog-process-metadata.cpp',
121 command: [
122 python_prog, '@INPUT0@',
123 '-t', '',
124 '-m', '@INPUT1@',
125 '-y', yamldir,
126 '-u', meson.current_source_dir() / '../tools/',
127 '-o', '@OUTPUT0@',
128 ],
129)
Patrick Williamsf06056b2021-04-16 13:38:55 -0500130
Matt Spinler23517522021-06-03 08:08:52 -0600131# Install elog-gen.py and its template for others to use
132install_data('tools/elog-gen.py',
133 install_dir : get_option('datadir') / 'phosphor-logging/elog/tools'
134)
135
136install_data('tools/phosphor-logging/templates/elog-gen-template.mako.hpp',
137 install_dir : get_option('datadir') /
138 'phosphor-logging/elog/tools/phosphor-logging/templates'
139)
140
Patrick Williamsf06056b2021-04-16 13:38:55 -0500141subdir('phosphor-logging')
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500142
143log_manager_ext_sources = []
144log_manager_ext_deps = []
145
146subdir('extensions')
Patrick Williamsb2b27082021-04-16 20:24:12 -0500147subdir('phosphor-rsyslog-config')
Patrick Williamsf06056b2021-04-16 13:38:55 -0500148
149# Build libphosphor-logging.
150libphosphor_logging = library(
151 'phosphor_logging',
152 files(
153 'elog.cpp',
154 'elog_meta.cpp',
155 'sdjournal.cpp',
156 ),
157 callouts_gen,
158 elog_errors_gen,
159 dependencies: [ sdbusplus_dep, pdi_dep, sdeventplus_dep ],
160 version: meson.project_version(),
161 install: true,
162)
163
164import('pkgconfig').generate(
165 libphosphor_logging,
166 name: meson.project_name(),
167 version: meson.project_version(),
168 requires: [
169 'libsystemd',
170 'phosphor-dbus-interfaces',
171 'sdbusplus',
172 ],
173 description: 'Phosphor logging utilities',
174)
175
176# Create dependency for use as subproject.
177phosphor_logging_dep = declare_dependency(
178 include_directories: include_directories('.'),
179 link_with: libphosphor_logging,
180 sources: [ callouts_gen, elog_errors_gen ],
181 dependencies: [ sdbusplus_dep, pdi_dep, sdeventplus_dep],
182)
Patrick Williams0bb89f82021-04-16 16:30:04 -0500183
184# Generate daemon.
Patrick Williamsa5171972021-04-16 20:10:01 -0500185log_manager_sources = [
Patrick Williams0bb89f82021-04-16 16:30:04 -0500186 generated_sources,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500187 elog_errors_gen,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500188 elog_lookup_gen,
189 elog_process_gen,
Patrick Williamsa5171972021-04-16 20:10:01 -0500190 files(
191 'elog_entry.cpp',
192 'elog_meta.cpp',
193 'elog_serialize.cpp',
194 'extensions.cpp',
195 'log_manager.cpp',
196 'sdjournal.cpp',
197 'util.cpp',
198 )
199]
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500200log_manager_deps = [
201 cereal_dep,
202 pdi_dep,
203 sdbusplus_dep,
204 sdeventplus_dep,
205]
Patrick Williamsa5171972021-04-16 20:10:01 -0500206executable('phosphor-log-manager',
207 log_manager_sources,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500208 log_manager_ext_sources,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500209 'log_manager_main.cpp',
Patrick Williams0bb89f82021-04-16 16:30:04 -0500210 include_directories: include_directories('gen'),
211 link_with: libphosphor_logging,
212 dependencies: [
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500213 log_manager_deps,
214 log_manager_ext_deps,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500215 ],
216 install: true,
217)
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500218# Generate test executables which run in obmc env (qemu, real hardware).
219executable('logging-test',
220 'logging_test.cpp',
221 link_with: libphosphor_logging,
222 dependencies: [
223 elog_errors_dep,
224 pdi_dep,
225 sdbusplus_dep,
226 ],
227 install: true,
228)
229executable('callout-test',
230 'callouts/callout_test.cpp',
231 link_with: libphosphor_logging,
232 dependencies: [
233 elog_errors_dep,
234 pdi_dep,
235 sdbusplus_dep,
236 sdeventplus_dep,
237 ],
238 install: true,
239)
Patrick Williamsa5171972021-04-16 20:10:01 -0500240
Anton D. Kachalov271408b2021-03-30 13:29:00 +0200241subdir('dist')
242
Patrick Williamsa5171972021-04-16 20:10:01 -0500243if not get_option('tests').disabled()
244 subdir('test')
245endif