blob: c4263c14f944bfc1cc394cfa661dfe7176efa48d [file] [log] [blame]
Patrick Williamsf06056b2021-04-16 13:38:55 -05001project('phosphor-logging', 'cpp',
Patrick Williams19257fd2023-07-12 11:15:09 -05002 meson_version: '>=1.1.1',
Patrick Williamsf06056b2021-04-16 13:38:55 -05003 default_options: [
4 'buildtype=debugoptimized',
Patrick Williams19257fd2023-07-12 11:15:09 -05005 'cpp_std=c++23',
Patrick Williamsf06056b2021-04-16 13:38:55 -05006 '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)
Patrick Williams75762242024-09-03 15:56:43 -040016libsystemd_dep = dependency('libsystemd')
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 Williams1d038d52022-09-12 10:56:30 -050021sdbusplusplus_depfiles = files()
22if sdbusplus_dep.type_name() == 'internal'
23 sdbusplusplus_depfiles = subproject('sdbusplus').get_variable('sdbusplusplus_depfiles')
24endif
Patrick Williamsf06056b2021-04-16 13:38:55 -050025
Patrick Williams62bc9682022-03-21 09:23:11 -050026pdi_dep = dependency('phosphor-dbus-interfaces')
William A. Kennington IIIe0538842021-06-11 02:01:58 -070027
28# Find the installed YAML directory, either from a configure option or
29# by pulling it from the PDI dependency.
30yamldir = get_option('yamldir')
31if yamldir == ''
Patrick Williamsff5f42f2023-04-12 08:01:04 -050032 yamldir = pdi_dep.get_variable('yamldir')
William A. Kennington IIIe0538842021-06-11 02:01:58 -070033endif
34
35subdir('config')
36subdir('tools')
37subdir('lib')
38
39if get_option('libonly')
40 subdir_done()
41endif
42
Patrick Williams62bc9682022-03-21 09:23:11 -050043sdeventplus_dep = dependency('sdeventplus')
Patrick Williamsf06056b2021-04-16 13:38:55 -050044
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()
Konstantin Aladyshevf02b78c2024-04-02 16:17:57 +030054 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'})
William A. Kennington III0b087762021-05-17 18:56:48 -070055 cereal_proj = import('cmake').subproject(
56 'cereal',
57 options: cereal_opts,
58 required: false)
59 assert(cereal_proj.found(), 'cereal is required')
Patrick Williams3e55d4d2021-08-26 16:44:26 -050060 cereal_dep = cereal_proj.dependency('cereal')
Patrick Williams0bb89f82021-04-16 16:30:04 -050061endif
62
Patrick Williamsdc35e302024-11-05 23:35:02 -050063# Get CLI11 dependency
64if cpp.has_header('CLI/CLI.hpp')
65 CLI11_dep = declare_dependency()
66else
67 CLI11_dep = dependency('CLI11')
68endif
69
70nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
71
Patrick Williams0bb89f82021-04-16 16:30:04 -050072# Generate sdbus++ files.
73generated_sources = []
74generated_others = []
75subdir('gen')
76subdir('gen/xyz')
77
Patrick Williamsf06056b2021-04-16 13:38:55 -050078# Generate callouts-gen.hpp.
79callouts_gen = custom_target('callouts-gen.hpp'.underscorify(),
80 input: [
81 'callouts/callouts.py',
82 'callouts/callouts-gen.mako.hpp',
83 get_option('callout_yaml'),
84 ],
85 output: 'callouts-gen.hpp',
86 command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@', '-o', '@OUTPUT0@' ],
87)
Patrick Williams0bb89f82021-04-16 16:30:04 -050088# Generate elog-lookup.cpp
89elog_lookup_gen = custom_target('elog-lookup.cpp'.underscorify(),
90 input: files(
91 'tools/elog-gen.py',
92 'tools/phosphor-logging/templates/elog-lookup-template.mako.cpp',
93 ),
94 output: 'elog-lookup.cpp',
95 command: [
96 python_prog, '@INPUT0@',
97 '-t', '',
98 '-m', '@INPUT1@',
99 '-y', yamldir,
Tim Lee47c77342021-07-08 09:27:58 +0800100 '-u', meson.current_source_dir() / 'tools/',
Patrick Williams0bb89f82021-04-16 16:30:04 -0500101 '-o', '@OUTPUT0@',
102 ],
103)
104# Generate elog-process-metadata.cpp
105elog_process_gen = custom_target('elog-process-metadata.cpp'.underscorify(),
106 input: files(
107 'tools/elog-gen.py',
108 'tools/phosphor-logging/templates/elog-process-metadata.mako.cpp',
109 ),
110 output: 'elog-process-metadata.cpp',
111 command: [
112 python_prog, '@INPUT0@',
113 '-t', '',
114 '-m', '@INPUT1@',
115 '-y', yamldir,
Tim Lee47c77342021-07-08 09:27:58 +0800116 '-u', meson.current_source_dir() / 'tools/',
Patrick Williams0bb89f82021-04-16 16:30:04 -0500117 '-o', '@OUTPUT0@',
118 ],
119)
Patrick Williamsf06056b2021-04-16 13:38:55 -0500120
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500121log_manager_ext_sources = []
122log_manager_ext_deps = []
William A. Kennington III8fd187e2021-07-26 13:36:56 -0700123log_manager_ext_args = []
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500124
125subdir('extensions')
Patrick Williamsb2b27082021-04-16 20:24:12 -0500126subdir('phosphor-rsyslog-config')
Patrick Williamsf06056b2021-04-16 13:38:55 -0500127
Patrick Williams0bb89f82021-04-16 16:30:04 -0500128# Generate daemon.
Patrick Williamsa5171972021-04-16 20:10:01 -0500129log_manager_sources = [
Patrick Williams0bb89f82021-04-16 16:30:04 -0500130 generated_sources,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700131 callouts_gen,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500132 elog_lookup_gen,
133 elog_process_gen,
Patrick Williamsa5171972021-04-16 20:10:01 -0500134 files(
135 'elog_entry.cpp',
136 'elog_meta.cpp',
137 'elog_serialize.cpp',
138 'extensions.cpp',
139 'log_manager.cpp',
Patrick Williamsfa2d9622024-09-30 16:25:43 -0400140 'paths.cpp',
Patrick Williamsa5171972021-04-16 20:10:01 -0500141 'util.cpp',
142 )
143]
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500144log_manager_deps = [
145 cereal_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700146 conf_h_dep,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500147 pdi_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700148 phosphor_logging_dep,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500149 sdbusplus_dep,
150 sdeventplus_dep,
151]
Patrick Williamsa5171972021-04-16 20:10:01 -0500152executable('phosphor-log-manager',
153 log_manager_sources,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500154 log_manager_ext_sources,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500155 'log_manager_main.cpp',
Patrick Williams0bb89f82021-04-16 16:30:04 -0500156 include_directories: include_directories('gen'),
William A. Kennington III8fd187e2021-07-26 13:36:56 -0700157 cpp_args: log_manager_ext_args,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500158 dependencies: [
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500159 log_manager_deps,
160 log_manager_ext_deps,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500161 ],
162 install: true,
163)
Patrick Williamsdc35e302024-11-05 23:35:02 -0500164
165executable('log-create',
166 'log_create_main.cpp',
167 dependencies: [
168 CLI11_dep,
169 nlohmann_json_dep,
170 pdi_dep,
171 phosphor_logging_dep,
172 sdbusplus_dep,
173 ],
174 install: true,
175)
176
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500177# Generate test executables which run in obmc env (qemu, real hardware).
178executable('logging-test',
179 'logging_test.cpp',
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500180 dependencies: [
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500181 pdi_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700182 phosphor_logging_dep,
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500183 sdbusplus_dep,
184 ],
185 install: true,
186)
187executable('callout-test',
188 'callouts/callout_test.cpp',
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500189 dependencies: [
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700190 conf_h_dep,
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500191 pdi_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700192 phosphor_logging_dep,
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500193 sdbusplus_dep,
194 sdeventplus_dep,
195 ],
196 install: true,
197)
Patrick Williamsa5171972021-04-16 20:10:01 -0500198
Anton D. Kachalov271408b2021-03-30 13:29:00 +0200199subdir('dist')
200
Patrick Williamsa5171972021-04-16 20:10:01 -0500201if not get_option('tests').disabled()
202 subdir('test')
203endif