blob: 86d04994ea89893c020cd2816ba5aa07d30bf607 [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)
Patrick Williams62bc9682022-03-21 09:23:11 -050013cpp = meson.get_compiler('cpp')
Patrick Williamsf06056b2021-04-16 13:38:55 -050014
William A. Kennington IIIe0538842021-06-11 02:01:58 -070015python_prog = find_program('python3', native: true)
16systemd_dep = dependency('systemd')
Patrick Williamsf06056b2021-04-16 13:38:55 -050017
Patrick Williams62bc9682022-03-21 09:23:11 -050018sdbusplus_dep = dependency('sdbusplus')
19sdbusplusplus_prog = find_program('sdbus++', native: true)
20sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true)
Patrick Williamsf06056b2021-04-16 13:38:55 -050021
Patrick Williams62bc9682022-03-21 09:23:11 -050022pdi_dep = dependency('phosphor-dbus-interfaces')
William A. Kennington IIIe0538842021-06-11 02:01:58 -070023
24# Find the installed YAML directory, either from a configure option or
25# by pulling it from the PDI dependency.
26yamldir = get_option('yamldir')
27if yamldir == ''
28 yamldir = pdi_dep.get_variable(pkgconfig: 'yamldir', internal: 'yamldir')
29endif
30
31subdir('config')
32subdir('tools')
33subdir('lib')
34
35if get_option('libonly')
36 subdir_done()
37endif
38
Patrick Williams62bc9682022-03-21 09:23:11 -050039sdeventplus_dep = dependency('sdeventplus')
Patrick Williamsf06056b2021-04-16 13:38:55 -050040
Patrick Williams0bb89f82021-04-16 16:30:04 -050041# Get Cereal dependency.
William A. Kennington III0b087762021-05-17 18:56:48 -070042cereal_dep = dependency('cereal', required: false)
43has_cereal = cpp.has_header_symbol(
44 'cereal/cereal.hpp',
45 'cereal::specialize',
46 dependencies: cereal_dep,
47 required: false)
48if not has_cereal
49 cereal_opts = import('cmake').subproject_options()
50 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
51 cereal_proj = import('cmake').subproject(
52 'cereal',
53 options: cereal_opts,
54 required: false)
55 assert(cereal_proj.found(), 'cereal is required')
Patrick Williams3e55d4d2021-08-26 16:44:26 -050056 cereal_dep = cereal_proj.dependency('cereal')
Patrick Williams0bb89f82021-04-16 16:30:04 -050057endif
58
Patrick Williams0bb89f82021-04-16 16:30:04 -050059# Generate sdbus++ files.
60generated_sources = []
61generated_others = []
62subdir('gen')
63subdir('gen/xyz')
64
Patrick Williamsf06056b2021-04-16 13:38:55 -050065# Generate callouts-gen.hpp.
66callouts_gen = custom_target('callouts-gen.hpp'.underscorify(),
67 input: [
68 'callouts/callouts.py',
69 'callouts/callouts-gen.mako.hpp',
70 get_option('callout_yaml'),
71 ],
72 output: 'callouts-gen.hpp',
73 command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@', '-o', '@OUTPUT0@' ],
74)
Patrick Williams0bb89f82021-04-16 16:30:04 -050075# Generate elog-lookup.cpp
76elog_lookup_gen = custom_target('elog-lookup.cpp'.underscorify(),
77 input: files(
78 'tools/elog-gen.py',
79 'tools/phosphor-logging/templates/elog-lookup-template.mako.cpp',
80 ),
81 output: 'elog-lookup.cpp',
82 command: [
83 python_prog, '@INPUT0@',
84 '-t', '',
85 '-m', '@INPUT1@',
86 '-y', yamldir,
Tim Lee47c77342021-07-08 09:27:58 +080087 '-u', meson.current_source_dir() / 'tools/',
Patrick Williams0bb89f82021-04-16 16:30:04 -050088 '-o', '@OUTPUT0@',
89 ],
90)
91# Generate elog-process-metadata.cpp
92elog_process_gen = custom_target('elog-process-metadata.cpp'.underscorify(),
93 input: files(
94 'tools/elog-gen.py',
95 'tools/phosphor-logging/templates/elog-process-metadata.mako.cpp',
96 ),
97 output: 'elog-process-metadata.cpp',
98 command: [
99 python_prog, '@INPUT0@',
100 '-t', '',
101 '-m', '@INPUT1@',
102 '-y', yamldir,
Tim Lee47c77342021-07-08 09:27:58 +0800103 '-u', meson.current_source_dir() / 'tools/',
Patrick Williams0bb89f82021-04-16 16:30:04 -0500104 '-o', '@OUTPUT0@',
105 ],
106)
Patrick Williamsf06056b2021-04-16 13:38:55 -0500107
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500108log_manager_ext_sources = []
109log_manager_ext_deps = []
William A. Kennington III8fd187e2021-07-26 13:36:56 -0700110log_manager_ext_args = []
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500111
112subdir('extensions')
Patrick Williamsb2b27082021-04-16 20:24:12 -0500113subdir('phosphor-rsyslog-config')
Patrick Williamsf06056b2021-04-16 13:38:55 -0500114
Patrick Williams0bb89f82021-04-16 16:30:04 -0500115# Generate daemon.
Patrick Williamsa5171972021-04-16 20:10:01 -0500116log_manager_sources = [
Patrick Williams0bb89f82021-04-16 16:30:04 -0500117 generated_sources,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700118 callouts_gen,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500119 elog_lookup_gen,
120 elog_process_gen,
Patrick Williamsa5171972021-04-16 20:10:01 -0500121 files(
122 'elog_entry.cpp',
123 'elog_meta.cpp',
124 'elog_serialize.cpp',
125 'extensions.cpp',
126 'log_manager.cpp',
Patrick Williamsa5171972021-04-16 20:10:01 -0500127 'util.cpp',
128 )
129]
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500130log_manager_deps = [
131 cereal_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700132 conf_h_dep,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500133 pdi_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700134 phosphor_logging_dep,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500135 sdbusplus_dep,
136 sdeventplus_dep,
137]
Patrick Williamsa5171972021-04-16 20:10:01 -0500138executable('phosphor-log-manager',
139 log_manager_sources,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500140 log_manager_ext_sources,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500141 'log_manager_main.cpp',
Patrick Williams0bb89f82021-04-16 16:30:04 -0500142 include_directories: include_directories('gen'),
William A. Kennington III8fd187e2021-07-26 13:36:56 -0700143 cpp_args: log_manager_ext_args,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500144 dependencies: [
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500145 log_manager_deps,
146 log_manager_ext_deps,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500147 ],
148 install: true,
149)
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500150# Generate test executables which run in obmc env (qemu, real hardware).
151executable('logging-test',
152 'logging_test.cpp',
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500153 dependencies: [
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500154 pdi_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700155 phosphor_logging_dep,
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500156 sdbusplus_dep,
157 ],
158 install: true,
159)
160executable('callout-test',
161 'callouts/callout_test.cpp',
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500162 dependencies: [
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700163 conf_h_dep,
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500164 pdi_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700165 phosphor_logging_dep,
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500166 sdbusplus_dep,
167 sdeventplus_dep,
168 ],
169 install: true,
170)
Patrick Williamsa5171972021-04-16 20:10:01 -0500171
Anton D. Kachalov271408b2021-03-30 13:29:00 +0200172subdir('dist')
173
Patrick Williamsa5171972021-04-16 20:10:01 -0500174if not get_option('tests').disabled()
175 subdir('test')
176endif