blob: 3a121be74cf23244d0a243948e19224b663e1901 [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',
8 ],
9 version: '1.0.0',
10)
11
Patrick Williamsd9f0d642021-04-21 15:43:21 -050012cpp = meson.get_compiler('cpp')
Patrick Williamsf06056b2021-04-16 13:38:55 -050013python_prog = find_program('python3')
14
15# Get sdbusplus dependency.
16sdbusplus_dep = dependency('sdbusplus', required: false)
17if sdbusplus_dep.found()
18 sdbusplusplus_prog = find_program('sdbus++')
19 sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson')
20else
21 sdbusplus_proj = subproject('sdbusplus', required: true)
22 sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep')
23 sdbusplusplus_prog = sdbusplus_proj.get_variable('sdbusplusplus_prog')
24 sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable(
25 'sdbuspp_gen_meson_prog'
26 )
27endif
28
29# Get PDI and sdeventplus dependency.
Patrick Williamsd9f0d642021-04-21 15:43:21 -050030pdi_vars = []
31if not get_option('openpower-pel-extension').disabled()
32 pdi_vars += [ 'data_org_open_power=true' ]
33endif
Patrick Williamsf06056b2021-04-16 13:38:55 -050034pdi_dep = dependency(
35 'phosphor-dbus-interfaces',
36 fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep'],
Patrick Williamsd9f0d642021-04-21 15:43:21 -050037 default_options: pdi_vars,
Patrick Williamsf06056b2021-04-16 13:38:55 -050038)
39sdeventplus_dep = dependency(
40 'sdeventplus',
41 fallback: ['sdeventplus', 'sdeventplus_dep' ],
42)
43
Patrick Williams0bb89f82021-04-16 16:30:04 -050044# Get Cereal dependency.
William A. Kennington III0b087762021-05-17 18:56:48 -070045cereal_dep = dependency('cereal', required: false)
46has_cereal = cpp.has_header_symbol(
47 'cereal/cereal.hpp',
48 'cereal::specialize',
49 dependencies: cereal_dep,
50 required: false)
51if not has_cereal
52 cereal_opts = import('cmake').subproject_options()
53 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
54 cereal_proj = import('cmake').subproject(
55 'cereal',
56 options: cereal_opts,
57 required: false)
58 assert(cereal_proj.found(), 'cereal is required')
59 cereal_dep = cereal_proj.get_variable('cm_cereal_dep')
Patrick Williams0bb89f82021-04-16 16:30:04 -050060endif
61
Patrick Williamsf06056b2021-04-16 13:38:55 -050062# Find the installed YAML directory, either from a configure option or
63# by pulling it from the PDI dependency.
64yamldir = get_option('yamldir')
65if yamldir == ''
66 yamldir = pdi_dep.get_variable(pkgconfig: 'yamldir', internal: 'yamldir')
67endif
68
69# Create config.h with constants that use to come from autoconf.
70conf_data = configuration_data()
Patrick Williams0bb89f82021-04-16 16:30:04 -050071conf_data.set('error_cap', get_option('error_cap'))
72conf_data.set('error_info_cap', get_option('error_info_cap'))
Patrick Williamsf06056b2021-04-16 13:38:55 -050073configure_file(
74 input: 'config.h.meson',
75 output: 'config.h',
76 configuration: conf_data,
77)
78
Patrick Williams0bb89f82021-04-16 16:30:04 -050079# Generate sdbus++ files.
80generated_sources = []
81generated_others = []
82subdir('gen')
83subdir('gen/xyz')
84
Patrick Williamsf06056b2021-04-16 13:38:55 -050085# Generate callouts-gen.hpp.
86callouts_gen = custom_target('callouts-gen.hpp'.underscorify(),
87 input: [
88 'callouts/callouts.py',
89 'callouts/callouts-gen.mako.hpp',
90 get_option('callout_yaml'),
91 ],
92 output: 'callouts-gen.hpp',
93 command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@', '-o', '@OUTPUT0@' ],
94)
Patrick Williams0bb89f82021-04-16 16:30:04 -050095# Generate elog-lookup.cpp
96elog_lookup_gen = custom_target('elog-lookup.cpp'.underscorify(),
97 input: files(
98 'tools/elog-gen.py',
99 'tools/phosphor-logging/templates/elog-lookup-template.mako.cpp',
100 ),
101 output: 'elog-lookup.cpp',
102 command: [
103 python_prog, '@INPUT0@',
104 '-t', '',
105 '-m', '@INPUT1@',
106 '-y', yamldir,
107 '-u', meson.current_source_dir() / '../tools/',
108 '-o', '@OUTPUT0@',
109 ],
110)
111# Generate elog-process-metadata.cpp
112elog_process_gen = custom_target('elog-process-metadata.cpp'.underscorify(),
113 input: files(
114 'tools/elog-gen.py',
115 'tools/phosphor-logging/templates/elog-process-metadata.mako.cpp',
116 ),
117 output: 'elog-process-metadata.cpp',
118 command: [
119 python_prog, '@INPUT0@',
120 '-t', '',
121 '-m', '@INPUT1@',
122 '-y', yamldir,
123 '-u', meson.current_source_dir() / '../tools/',
124 '-o', '@OUTPUT0@',
125 ],
126)
Patrick Williamsf06056b2021-04-16 13:38:55 -0500127
128subdir('phosphor-logging')
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500129
130log_manager_ext_sources = []
131log_manager_ext_deps = []
132
133subdir('extensions')
Patrick Williamsb2b27082021-04-16 20:24:12 -0500134subdir('phosphor-rsyslog-config')
Patrick Williamsf06056b2021-04-16 13:38:55 -0500135
136# Build libphosphor-logging.
137libphosphor_logging = library(
138 'phosphor_logging',
139 files(
140 'elog.cpp',
141 'elog_meta.cpp',
142 'sdjournal.cpp',
143 ),
144 callouts_gen,
145 elog_errors_gen,
146 dependencies: [ sdbusplus_dep, pdi_dep, sdeventplus_dep ],
147 version: meson.project_version(),
148 install: true,
149)
150
151import('pkgconfig').generate(
152 libphosphor_logging,
153 name: meson.project_name(),
154 version: meson.project_version(),
155 requires: [
156 'libsystemd',
157 'phosphor-dbus-interfaces',
158 'sdbusplus',
159 ],
160 description: 'Phosphor logging utilities',
161)
162
163# Create dependency for use as subproject.
164phosphor_logging_dep = declare_dependency(
165 include_directories: include_directories('.'),
166 link_with: libphosphor_logging,
167 sources: [ callouts_gen, elog_errors_gen ],
168 dependencies: [ sdbusplus_dep, pdi_dep, sdeventplus_dep],
169)
Patrick Williams0bb89f82021-04-16 16:30:04 -0500170
171# Generate daemon.
Patrick Williamsa5171972021-04-16 20:10:01 -0500172log_manager_sources = [
Patrick Williams0bb89f82021-04-16 16:30:04 -0500173 generated_sources,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500174 elog_errors_gen,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500175 elog_lookup_gen,
176 elog_process_gen,
Patrick Williamsa5171972021-04-16 20:10:01 -0500177 files(
178 'elog_entry.cpp',
179 'elog_meta.cpp',
180 'elog_serialize.cpp',
181 'extensions.cpp',
182 'log_manager.cpp',
183 'sdjournal.cpp',
184 'util.cpp',
185 )
186]
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500187log_manager_deps = [
188 cereal_dep,
189 pdi_dep,
190 sdbusplus_dep,
191 sdeventplus_dep,
192]
Patrick Williamsa5171972021-04-16 20:10:01 -0500193executable('phosphor-log-manager',
194 log_manager_sources,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500195 log_manager_ext_sources,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500196 'log_manager_main.cpp',
Patrick Williams0bb89f82021-04-16 16:30:04 -0500197 include_directories: include_directories('gen'),
198 link_with: libphosphor_logging,
199 dependencies: [
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500200 log_manager_deps,
201 log_manager_ext_deps,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500202 ],
203 install: true,
204)
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500205# Generate test executables which run in obmc env (qemu, real hardware).
206executable('logging-test',
207 'logging_test.cpp',
208 link_with: libphosphor_logging,
209 dependencies: [
210 elog_errors_dep,
211 pdi_dep,
212 sdbusplus_dep,
213 ],
214 install: true,
215)
216executable('callout-test',
217 'callouts/callout_test.cpp',
218 link_with: libphosphor_logging,
219 dependencies: [
220 elog_errors_dep,
221 pdi_dep,
222 sdbusplus_dep,
223 sdeventplus_dep,
224 ],
225 install: true,
226)
Patrick Williamsa5171972021-04-16 20:10:01 -0500227
Anton D. Kachalov271408b2021-03-30 13:29:00 +0200228subdir('dist')
229
Patrick Williamsa5171972021-04-16 20:10:01 -0500230if not get_option('tests').disabled()
231 subdir('test')
232endif