blob: 68db1ccefabbd46c6c4d4d03efb1997c9cd4d2af [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 IIIe0538842021-06-11 02:01:58 -07008 'libonly=' + (meson.is_subproject() ? 'true' : 'false'),
William A. Kennington III515653b2021-05-17 19:28:17 -07009 'tests=' + (meson.is_subproject() ? 'disabled' : 'auto'),
Patrick Williamsf06056b2021-04-16 13:38:55 -050010 ],
11 version: '1.0.0',
12)
13
William A. Kennington IIIe0538842021-06-11 02:01:58 -070014python_prog = find_program('python3', native: true)
15systemd_dep = dependency('systemd')
Patrick Williamsf06056b2021-04-16 13:38:55 -050016
Patrick Williamsf06056b2021-04-16 13:38:55 -050017sdbusplus_dep = dependency('sdbusplus', required: false)
William A. Kennington IIIe0538842021-06-11 02:01:58 -070018sdbusplus_proj = dependency('', required: false)
19if not sdbusplus_dep.found() or sdbusplus_dep.type_name() == 'internal'
20 sdbusplus_proj = subproject('sdbusplus')
21endif
22if not sdbusplus_dep.found()
Patrick Williamsf06056b2021-04-16 13:38:55 -050023 sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep')
Patrick Williamsf06056b2021-04-16 13:38:55 -050024endif
25
Patrick Williamsd9f0d642021-04-21 15:43:21 -050026pdi_vars = []
27if not get_option('openpower-pel-extension').disabled()
William A. Kennington IIIe0538842021-06-11 02:01:58 -070028 pdi_vars += ['data_org_open_power=true']
Patrick Williamsd9f0d642021-04-21 15:43:21 -050029endif
Patrick Williamsf06056b2021-04-16 13:38:55 -050030pdi_dep = dependency(
31 'phosphor-dbus-interfaces',
32 fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep'],
Patrick Williamsd9f0d642021-04-21 15:43:21 -050033 default_options: pdi_vars,
Patrick Williamsf06056b2021-04-16 13:38:55 -050034)
William A. Kennington IIIe0538842021-06-11 02:01:58 -070035
36# Find the installed YAML directory, either from a configure option or
37# by pulling it from the PDI dependency.
38yamldir = get_option('yamldir')
39if yamldir == ''
40 yamldir = pdi_dep.get_variable(pkgconfig: 'yamldir', internal: 'yamldir')
41endif
42
43subdir('config')
44subdir('tools')
45subdir('lib')
46
47if get_option('libonly')
48 subdir_done()
49endif
50
51cpp = meson.get_compiler('cpp')
52
53if sdbusplus_proj.found()
54 sdbusplusplus_prog = sdbusplus_proj.get_variable('sdbusplusplus_prog')
55 sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable(
56 'sdbuspp_gen_meson_prog')
57else
58 sdbusplusplus_prog = find_program('sdbus++', native: true)
59 sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true)
60endif
61
Patrick Williamsf06056b2021-04-16 13:38:55 -050062sdeventplus_dep = dependency(
63 'sdeventplus',
64 fallback: ['sdeventplus', 'sdeventplus_dep' ],
65)
66
Patrick Williams0bb89f82021-04-16 16:30:04 -050067# Get Cereal dependency.
William A. Kennington III0b087762021-05-17 18:56:48 -070068cereal_dep = dependency('cereal', required: false)
69has_cereal = cpp.has_header_symbol(
70 'cereal/cereal.hpp',
71 'cereal::specialize',
72 dependencies: cereal_dep,
73 required: false)
74if not has_cereal
75 cereal_opts = import('cmake').subproject_options()
76 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
77 cereal_proj = import('cmake').subproject(
78 'cereal',
79 options: cereal_opts,
80 required: false)
81 assert(cereal_proj.found(), 'cereal is required')
82 cereal_dep = cereal_proj.get_variable('cm_cereal_dep')
Patrick Williams0bb89f82021-04-16 16:30:04 -050083endif
84
Patrick Williams0bb89f82021-04-16 16:30:04 -050085# Generate sdbus++ files.
86generated_sources = []
87generated_others = []
88subdir('gen')
89subdir('gen/xyz')
90
Patrick Williamsf06056b2021-04-16 13:38:55 -050091# Generate callouts-gen.hpp.
92callouts_gen = custom_target('callouts-gen.hpp'.underscorify(),
93 input: [
94 'callouts/callouts.py',
95 'callouts/callouts-gen.mako.hpp',
96 get_option('callout_yaml'),
97 ],
98 output: 'callouts-gen.hpp',
99 command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@', '-o', '@OUTPUT0@' ],
100)
Patrick Williams0bb89f82021-04-16 16:30:04 -0500101# Generate elog-lookup.cpp
102elog_lookup_gen = custom_target('elog-lookup.cpp'.underscorify(),
103 input: files(
104 'tools/elog-gen.py',
105 'tools/phosphor-logging/templates/elog-lookup-template.mako.cpp',
106 ),
107 output: 'elog-lookup.cpp',
108 command: [
109 python_prog, '@INPUT0@',
110 '-t', '',
111 '-m', '@INPUT1@',
112 '-y', yamldir,
Tim Lee47c77342021-07-08 09:27:58 +0800113 '-u', meson.current_source_dir() / 'tools/',
Patrick Williams0bb89f82021-04-16 16:30:04 -0500114 '-o', '@OUTPUT0@',
115 ],
116)
117# Generate elog-process-metadata.cpp
118elog_process_gen = custom_target('elog-process-metadata.cpp'.underscorify(),
119 input: files(
120 'tools/elog-gen.py',
121 'tools/phosphor-logging/templates/elog-process-metadata.mako.cpp',
122 ),
123 output: 'elog-process-metadata.cpp',
124 command: [
125 python_prog, '@INPUT0@',
126 '-t', '',
127 '-m', '@INPUT1@',
128 '-y', yamldir,
Tim Lee47c77342021-07-08 09:27:58 +0800129 '-u', meson.current_source_dir() / 'tools/',
Patrick Williams0bb89f82021-04-16 16:30:04 -0500130 '-o', '@OUTPUT0@',
131 ],
132)
Patrick Williamsf06056b2021-04-16 13:38:55 -0500133
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500134log_manager_ext_sources = []
135log_manager_ext_deps = []
William A. Kennington III8fd187e2021-07-26 13:36:56 -0700136log_manager_ext_args = []
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500137
138subdir('extensions')
Patrick Williamsb2b27082021-04-16 20:24:12 -0500139subdir('phosphor-rsyslog-config')
Patrick Williamsf06056b2021-04-16 13:38:55 -0500140
Patrick Williams0bb89f82021-04-16 16:30:04 -0500141# Generate daemon.
Patrick Williamsa5171972021-04-16 20:10:01 -0500142log_manager_sources = [
Patrick Williams0bb89f82021-04-16 16:30:04 -0500143 generated_sources,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700144 callouts_gen,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500145 elog_lookup_gen,
146 elog_process_gen,
Patrick Williamsa5171972021-04-16 20:10:01 -0500147 files(
148 'elog_entry.cpp',
149 'elog_meta.cpp',
150 'elog_serialize.cpp',
151 'extensions.cpp',
152 'log_manager.cpp',
Patrick Williamsa5171972021-04-16 20:10:01 -0500153 'util.cpp',
154 )
155]
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500156log_manager_deps = [
157 cereal_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700158 conf_h_dep,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500159 pdi_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700160 phosphor_logging_dep,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500161 sdbusplus_dep,
162 sdeventplus_dep,
163]
Patrick Williamsa5171972021-04-16 20:10:01 -0500164executable('phosphor-log-manager',
165 log_manager_sources,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500166 log_manager_ext_sources,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500167 'log_manager_main.cpp',
Patrick Williams0bb89f82021-04-16 16:30:04 -0500168 include_directories: include_directories('gen'),
William A. Kennington III8fd187e2021-07-26 13:36:56 -0700169 cpp_args: log_manager_ext_args,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500170 dependencies: [
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500171 log_manager_deps,
172 log_manager_ext_deps,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500173 ],
174 install: true,
175)
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500176# Generate test executables which run in obmc env (qemu, real hardware).
177executable('logging-test',
178 'logging_test.cpp',
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500179 dependencies: [
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500180 pdi_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700181 phosphor_logging_dep,
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500182 sdbusplus_dep,
183 ],
184 install: true,
185)
186executable('callout-test',
187 'callouts/callout_test.cpp',
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500188 dependencies: [
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700189 conf_h_dep,
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500190 pdi_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700191 phosphor_logging_dep,
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500192 sdbusplus_dep,
193 sdeventplus_dep,
194 ],
195 install: true,
196)
Patrick Williamsa5171972021-04-16 20:10:01 -0500197
Anton D. Kachalov271408b2021-03-30 13:29:00 +0200198subdir('dist')
199
Patrick Williamsa5171972021-04-16 20:10:01 -0500200if not get_option('tests').disabled()
201 subdir('test')
202endif