blob: e183fd7e01eff840c48932ba1ddede810c170d6b [file] [log] [blame]
Patrick Williamsf06056b2021-04-16 13:38:55 -05001project('phosphor-logging', 'cpp',
Patrick Williamsff5f42f2023-04-12 08:01:04 -05002 meson_version: '>= 0.58.0',
Patrick Williamsf06056b2021-04-16 13:38:55 -05003 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 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()
54 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
55 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 Williams0bb89f82021-04-16 16:30:04 -050063# Generate sdbus++ files.
64generated_sources = []
65generated_others = []
66subdir('gen')
67subdir('gen/xyz')
68
Patrick Williamsf06056b2021-04-16 13:38:55 -050069# Generate callouts-gen.hpp.
70callouts_gen = custom_target('callouts-gen.hpp'.underscorify(),
71 input: [
72 'callouts/callouts.py',
73 'callouts/callouts-gen.mako.hpp',
74 get_option('callout_yaml'),
75 ],
76 output: 'callouts-gen.hpp',
77 command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@', '-o', '@OUTPUT0@' ],
78)
Patrick Williams0bb89f82021-04-16 16:30:04 -050079# Generate elog-lookup.cpp
80elog_lookup_gen = custom_target('elog-lookup.cpp'.underscorify(),
81 input: files(
82 'tools/elog-gen.py',
83 'tools/phosphor-logging/templates/elog-lookup-template.mako.cpp',
84 ),
85 output: 'elog-lookup.cpp',
86 command: [
87 python_prog, '@INPUT0@',
88 '-t', '',
89 '-m', '@INPUT1@',
90 '-y', yamldir,
Tim Lee47c77342021-07-08 09:27:58 +080091 '-u', meson.current_source_dir() / 'tools/',
Patrick Williams0bb89f82021-04-16 16:30:04 -050092 '-o', '@OUTPUT0@',
93 ],
94)
95# Generate elog-process-metadata.cpp
96elog_process_gen = custom_target('elog-process-metadata.cpp'.underscorify(),
97 input: files(
98 'tools/elog-gen.py',
99 'tools/phosphor-logging/templates/elog-process-metadata.mako.cpp',
100 ),
101 output: 'elog-process-metadata.cpp',
102 command: [
103 python_prog, '@INPUT0@',
104 '-t', '',
105 '-m', '@INPUT1@',
106 '-y', yamldir,
Tim Lee47c77342021-07-08 09:27:58 +0800107 '-u', meson.current_source_dir() / 'tools/',
Patrick Williams0bb89f82021-04-16 16:30:04 -0500108 '-o', '@OUTPUT0@',
109 ],
110)
Patrick Williamsf06056b2021-04-16 13:38:55 -0500111
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500112log_manager_ext_sources = []
113log_manager_ext_deps = []
William A. Kennington III8fd187e2021-07-26 13:36:56 -0700114log_manager_ext_args = []
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500115
116subdir('extensions')
Patrick Williamsb2b27082021-04-16 20:24:12 -0500117subdir('phosphor-rsyslog-config')
Patrick Williamsf06056b2021-04-16 13:38:55 -0500118
Patrick Williams0bb89f82021-04-16 16:30:04 -0500119# Generate daemon.
Patrick Williamsa5171972021-04-16 20:10:01 -0500120log_manager_sources = [
Patrick Williams0bb89f82021-04-16 16:30:04 -0500121 generated_sources,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700122 callouts_gen,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500123 elog_lookup_gen,
124 elog_process_gen,
Patrick Williamsa5171972021-04-16 20:10:01 -0500125 files(
126 'elog_entry.cpp',
127 'elog_meta.cpp',
128 'elog_serialize.cpp',
129 'extensions.cpp',
130 'log_manager.cpp',
Patrick Williamsa5171972021-04-16 20:10:01 -0500131 'util.cpp',
132 )
133]
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500134log_manager_deps = [
135 cereal_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700136 conf_h_dep,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500137 pdi_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700138 phosphor_logging_dep,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500139 sdbusplus_dep,
140 sdeventplus_dep,
141]
Patrick Williamsa5171972021-04-16 20:10:01 -0500142executable('phosphor-log-manager',
143 log_manager_sources,
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500144 log_manager_ext_sources,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500145 'log_manager_main.cpp',
Patrick Williams0bb89f82021-04-16 16:30:04 -0500146 include_directories: include_directories('gen'),
William A. Kennington III8fd187e2021-07-26 13:36:56 -0700147 cpp_args: log_manager_ext_args,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500148 dependencies: [
Patrick Williamsd9f0d642021-04-21 15:43:21 -0500149 log_manager_deps,
150 log_manager_ext_deps,
Patrick Williams0bb89f82021-04-16 16:30:04 -0500151 ],
152 install: true,
153)
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500154# Generate test executables which run in obmc env (qemu, real hardware).
155executable('logging-test',
156 'logging_test.cpp',
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500157 dependencies: [
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500158 pdi_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700159 phosphor_logging_dep,
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500160 sdbusplus_dep,
161 ],
162 install: true,
163)
164executable('callout-test',
165 'callouts/callout_test.cpp',
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500166 dependencies: [
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700167 conf_h_dep,
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500168 pdi_dep,
William A. Kennington IIIe0538842021-06-11 02:01:58 -0700169 phosphor_logging_dep,
Patrick Williamsddd4fac2021-04-16 16:40:43 -0500170 sdbusplus_dep,
171 sdeventplus_dep,
172 ],
173 install: true,
174)
Patrick Williamsa5171972021-04-16 20:10:01 -0500175
Anton D. Kachalov271408b2021-03-30 13:29:00 +0200176subdir('dist')
177
Patrick Williamsa5171972021-04-16 20:10:01 -0500178if not get_option('tests').disabled()
179 subdir('test')
180endif