blob: e35fb69bfd714df0fe3642e05c973f62e258a25a [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.
Patrick Williamsad0d7522025-01-10 14:49:12 -050073should_generate_cpp = true
74should_generate_markdown = false
75should_generate_registry = false
76yaml_selected_subdirs = [ 'xyz' ]
Patrick Williams0bb89f82021-04-16 16:30:04 -050077subdir('gen')
Patrick Williams0bb89f82021-04-16 16:30:04 -050078
Patrick Williamsf06056b2021-04-16 13:38:55 -050079# Generate callouts-gen.hpp.
80callouts_gen = custom_target('callouts-gen.hpp'.underscorify(),
81 input: [
82 'callouts/callouts.py',
83 'callouts/callouts-gen.mako.hpp',
84 get_option('callout_yaml'),
85 ],
86 output: 'callouts-gen.hpp',
87 command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@', '-o', '@OUTPUT0@' ],
88)
Patrick Williams0bb89f82021-04-16 16:30:04 -050089# Generate elog-lookup.cpp
90elog_lookup_gen = custom_target('elog-lookup.cpp'.underscorify(),
91 input: files(
92 'tools/elog-gen.py',
93 'tools/phosphor-logging/templates/elog-lookup-template.mako.cpp',
94 ),
95 output: 'elog-lookup.cpp',
96 command: [
97 python_prog, '@INPUT0@',
98 '-t', '',
99 '-m', '@INPUT1@',
100 '-y', yamldir,
Tim Lee47c77342021-07-08 09:27:58 +0800101 '-u', meson.current_source_dir() / 'tools/',
Patrick Williams0bb89f82021-04-16 16:30:04 -0500102 '-o', '@OUTPUT0@',
103 ],
104)
105# Generate elog-process-metadata.cpp
106elog_process_gen = custom_target('elog-process-metadata.cpp'.underscorify(),
107 input: files(
108 'tools/elog-gen.py',
109 'tools/phosphor-logging/templates/elog-process-metadata.mako.cpp',
110 ),
111 output: 'elog-process-metadata.cpp',
112 command: [
113 python_prog, '@INPUT0@',
114 '-t', '',
115 '-m', '@INPUT1@',
116 '-y', yamldir,
Tim Lee47c77342021-07-08 09:27:58 +0800117 '-u', meson.current_source_dir() / 'tools/',
Patrick Williams0bb89f82021-04-16 16:30:04 -0500118 '-o', '@OUTPUT0@',
119 ],
120)
Patrick Williamsf06056b2021-04-16 13:38:55 -0500121
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500122log_manager_ext_sources = []
123log_manager_ext_deps = []
William A. Kennington III8fd187e2021-07-26 13:36:56 -0700124log_manager_ext_args = []
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500125
126subdir('extensions')
Patrick Williamsb2b27082021-04-16 20:24:12 -0500127subdir('phosphor-rsyslog-config')
Patrick Williamsf06056b2021-04-16 13:38:55 -0500128
Patrick Williams0bb89f82021-04-16 16:30:04 -0500129# Generate daemon.
Patrick Williamsa5171972021-04-16 20:10:01 -0500130log_manager_sources = [
Patrick Williams0bb89f82021-04-16 16:30:04 -0500131 generated_sources,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700132 callouts_gen,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500133 elog_lookup_gen,
134 elog_process_gen,
Patrick Williamsa5171972021-04-16 20:10:01 -0500135 files(
136 'elog_entry.cpp',
137 'elog_meta.cpp',
138 'elog_serialize.cpp',
139 'extensions.cpp',
140 'log_manager.cpp',
Patrick Williamsfa2d9622024-09-30 16:25:43 -0400141 'paths.cpp',
Patrick Williamsa5171972021-04-16 20:10:01 -0500142 'util.cpp',
143 )
144]
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500145log_manager_deps = [
146 cereal_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700147 conf_h_dep,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500148 pdi_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700149 phosphor_logging_dep,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500150 sdbusplus_dep,
151 sdeventplus_dep,
152]
Patrick Williamsa5171972021-04-16 20:10:01 -0500153executable('phosphor-log-manager',
154 log_manager_sources,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500155 log_manager_ext_sources,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500156 'log_manager_main.cpp',
Patrick Williams0bb89f82021-04-16 16:30:04 -0500157 include_directories: include_directories('gen'),
William A. Kennington III8fd187e2021-07-26 13:36:56 -0700158 cpp_args: log_manager_ext_args,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500159 dependencies: [
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500160 log_manager_deps,
161 log_manager_ext_deps,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500162 ],
163 install: true,
164)
Patrick Williamsdc35e302024-11-05 23:35:02 -0500165
166executable('log-create',
167 'log_create_main.cpp',
168 dependencies: [
169 CLI11_dep,
170 nlohmann_json_dep,
171 pdi_dep,
172 phosphor_logging_dep,
173 sdbusplus_dep,
174 ],
175 install: true,
176)
177
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500178# Generate test executables which run in obmc env (qemu, real hardware).
179executable('logging-test',
180 'logging_test.cpp',
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500181 dependencies: [
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500182 pdi_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700183 phosphor_logging_dep,
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500184 sdbusplus_dep,
185 ],
186 install: true,
187)
188executable('callout-test',
189 'callouts/callout_test.cpp',
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500190 dependencies: [
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700191 conf_h_dep,
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500192 pdi_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700193 phosphor_logging_dep,
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500194 sdbusplus_dep,
195 sdeventplus_dep,
196 ],
197 install: true,
198)
Patrick Williamsa5171972021-04-16 20:10:01 -0500199
Anton D. Kachalov271408b2021-03-30 13:29:00 +0200200subdir('dist')
201
Patrick Williams1f2bb812025-01-30 17:47:16 -0500202if get_option('tests').allowed()
Patrick Williamsa5171972021-04-16 20:10:01 -0500203 subdir('test')
204endif