blob: b2fe71e058c678adeb62f90b2f1c99e7bd2f4b63 [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.
Patrick Williams60356ad2021-04-30 10:16:51 -050045if cpp.has_header('cereal/cereal.hpp')
46 cereal_dep = declare_dependency()
47else
Patrick Williams0bb89f82021-04-16 16:30:04 -050048 subproject('cereal', required: false)
49 cereal_dep = declare_dependency(
50 include_directories: [ 'subprojects/cereal/include' ],
51 )
52endif
53
Patrick Williamsf06056b2021-04-16 13:38:55 -050054# Find the installed YAML directory, either from a configure option or
55# by pulling it from the PDI dependency.
56yamldir = get_option('yamldir')
57if yamldir == ''
58 yamldir = pdi_dep.get_variable(pkgconfig: 'yamldir', internal: 'yamldir')
59endif
60
61# Create config.h with constants that use to come from autoconf.
62conf_data = configuration_data()
Patrick Williams0bb89f82021-04-16 16:30:04 -050063conf_data.set('error_cap', get_option('error_cap'))
64conf_data.set('error_info_cap', get_option('error_info_cap'))
Patrick Williamsf06056b2021-04-16 13:38:55 -050065configure_file(
66 input: 'config.h.meson',
67 output: 'config.h',
68 configuration: conf_data,
69)
70
Patrick Williams0bb89f82021-04-16 16:30:04 -050071# Generate sdbus++ files.
72generated_sources = []
73generated_others = []
74subdir('gen')
75subdir('gen/xyz')
76
Patrick Williamsf06056b2021-04-16 13:38:55 -050077# Generate callouts-gen.hpp.
78callouts_gen = custom_target('callouts-gen.hpp'.underscorify(),
79 input: [
80 'callouts/callouts.py',
81 'callouts/callouts-gen.mako.hpp',
82 get_option('callout_yaml'),
83 ],
84 output: 'callouts-gen.hpp',
85 command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@', '-o', '@OUTPUT0@' ],
86)
Patrick Williams0bb89f82021-04-16 16:30:04 -050087# Generate elog-lookup.cpp
88elog_lookup_gen = custom_target('elog-lookup.cpp'.underscorify(),
89 input: files(
90 'tools/elog-gen.py',
91 'tools/phosphor-logging/templates/elog-lookup-template.mako.cpp',
92 ),
93 output: 'elog-lookup.cpp',
94 command: [
95 python_prog, '@INPUT0@',
96 '-t', '',
97 '-m', '@INPUT1@',
98 '-y', yamldir,
99 '-u', meson.current_source_dir() / '../tools/',
100 '-o', '@OUTPUT0@',
101 ],
102)
103# Generate elog-process-metadata.cpp
104elog_process_gen = custom_target('elog-process-metadata.cpp'.underscorify(),
105 input: files(
106 'tools/elog-gen.py',
107 'tools/phosphor-logging/templates/elog-process-metadata.mako.cpp',
108 ),
109 output: 'elog-process-metadata.cpp',
110 command: [
111 python_prog, '@INPUT0@',
112 '-t', '',
113 '-m', '@INPUT1@',
114 '-y', yamldir,
115 '-u', meson.current_source_dir() / '../tools/',
116 '-o', '@OUTPUT0@',
117 ],
118)
Patrick Williamsf06056b2021-04-16 13:38:55 -0500119
120subdir('phosphor-logging')
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500121
122log_manager_ext_sources = []
123log_manager_ext_deps = []
124
125subdir('extensions')
Patrick Williamsb2b27082021-04-16 20:24:12 -0500126subdir('phosphor-rsyslog-config')
Patrick Williamsf06056b2021-04-16 13:38:55 -0500127
128# Build libphosphor-logging.
129libphosphor_logging = library(
130 'phosphor_logging',
131 files(
132 'elog.cpp',
133 'elog_meta.cpp',
134 'sdjournal.cpp',
135 ),
136 callouts_gen,
137 elog_errors_gen,
138 dependencies: [ sdbusplus_dep, pdi_dep, sdeventplus_dep ],
139 version: meson.project_version(),
140 install: true,
141)
142
143import('pkgconfig').generate(
144 libphosphor_logging,
145 name: meson.project_name(),
146 version: meson.project_version(),
147 requires: [
148 'libsystemd',
149 'phosphor-dbus-interfaces',
150 'sdbusplus',
151 ],
152 description: 'Phosphor logging utilities',
153)
154
155# Create dependency for use as subproject.
156phosphor_logging_dep = declare_dependency(
157 include_directories: include_directories('.'),
158 link_with: libphosphor_logging,
159 sources: [ callouts_gen, elog_errors_gen ],
160 dependencies: [ sdbusplus_dep, pdi_dep, sdeventplus_dep],
161)
Patrick Williams0bb89f82021-04-16 16:30:04 -0500162
163# Generate daemon.
Patrick Williamsa5171972021-04-16 20:10:01 -0500164log_manager_sources = [
Patrick Williams0bb89f82021-04-16 16:30:04 -0500165 generated_sources,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500166 elog_errors_gen,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500167 elog_lookup_gen,
168 elog_process_gen,
Patrick Williamsa5171972021-04-16 20:10:01 -0500169 files(
170 'elog_entry.cpp',
171 'elog_meta.cpp',
172 'elog_serialize.cpp',
173 'extensions.cpp',
174 'log_manager.cpp',
175 'sdjournal.cpp',
176 'util.cpp',
177 )
178]
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500179log_manager_deps = [
180 cereal_dep,
181 pdi_dep,
182 sdbusplus_dep,
183 sdeventplus_dep,
184]
Patrick Williamsa5171972021-04-16 20:10:01 -0500185executable('phosphor-log-manager',
186 log_manager_sources,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500187 log_manager_ext_sources,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500188 'log_manager_main.cpp',
Patrick Williams0bb89f82021-04-16 16:30:04 -0500189 include_directories: include_directories('gen'),
190 link_with: libphosphor_logging,
191 dependencies: [
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500192 log_manager_deps,
193 log_manager_ext_deps,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500194 ],
195 install: true,
196)
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500197# Generate test executables which run in obmc env (qemu, real hardware).
198executable('logging-test',
199 'logging_test.cpp',
200 link_with: libphosphor_logging,
201 dependencies: [
202 elog_errors_dep,
203 pdi_dep,
204 sdbusplus_dep,
205 ],
206 install: true,
207)
208executable('callout-test',
209 'callouts/callout_test.cpp',
210 link_with: libphosphor_logging,
211 dependencies: [
212 elog_errors_dep,
213 pdi_dep,
214 sdbusplus_dep,
215 sdeventplus_dep,
216 ],
217 install: true,
218)
Patrick Williamsa5171972021-04-16 20:10:01 -0500219
Anton D. Kachalov271408b2021-03-30 13:29:00 +0200220subdir('dist')
221
Patrick Williamsa5171972021-04-16 20:10:01 -0500222if not get_option('tests').disabled()
223 subdir('test')
224endif