xref: /openbmc/phosphor-logging/meson.build (revision 66580a90)
1project('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',
8      'libonly=' + (meson.is_subproject() ? 'true' : 'false'),
9      'tests=' + (meson.is_subproject() ? 'disabled' : 'auto'),
10    ],
11    version: '1.0.0',
12)
13
14python_prog = find_program('python3', native: true)
15systemd_dep = dependency('systemd')
16
17sdbusplus_dep = dependency('sdbusplus', required: false)
18sdbusplus_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()
23    sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep')
24endif
25
26pdi_vars = []
27if not get_option('openpower-pel-extension').disabled()
28    pdi_vars += ['data_org_open_power=true']
29endif
30pdi_dep = dependency(
31    'phosphor-dbus-interfaces',
32    fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep'],
33    default_options: pdi_vars,
34)
35
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
62sdeventplus_dep = dependency(
63    'sdeventplus',
64    fallback: ['sdeventplus', 'sdeventplus_dep' ],
65)
66
67# Get Cereal dependency.
68cereal_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.dependency('cereal')
83endif
84
85# Generate sdbus++ files.
86generated_sources = []
87generated_others = []
88subdir('gen')
89subdir('gen/xyz')
90
91# 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)
101# 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,
113        '-u', meson.current_source_dir() / 'tools/',
114        '-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,
129        '-u', meson.current_source_dir() / 'tools/',
130        '-o', '@OUTPUT0@',
131    ],
132)
133
134log_manager_ext_sources = []
135log_manager_ext_deps = []
136log_manager_ext_args = []
137
138subdir('extensions')
139subdir('phosphor-rsyslog-config')
140
141# Generate daemon.
142log_manager_sources = [
143    generated_sources,
144    callouts_gen,
145    elog_lookup_gen,
146    elog_process_gen,
147    files(
148        'elog_entry.cpp',
149        'elog_meta.cpp',
150        'elog_serialize.cpp',
151        'extensions.cpp',
152        'log_manager.cpp',
153        'util.cpp',
154    )
155]
156log_manager_deps = [
157    cereal_dep,
158    conf_h_dep,
159    pdi_dep,
160    phosphor_logging_dep,
161    sdbusplus_dep,
162    sdeventplus_dep,
163]
164executable('phosphor-log-manager',
165    log_manager_sources,
166    log_manager_ext_sources,
167    'log_manager_main.cpp',
168    include_directories: include_directories('gen'),
169    cpp_args: log_manager_ext_args,
170    dependencies: [
171        log_manager_deps,
172        log_manager_ext_deps,
173    ],
174    install: true,
175)
176# Generate test executables which run in obmc env (qemu, real hardware).
177executable('logging-test',
178    'logging_test.cpp',
179    dependencies: [
180        pdi_dep,
181        phosphor_logging_dep,
182        sdbusplus_dep,
183    ],
184    install: true,
185)
186executable('callout-test',
187    'callouts/callout_test.cpp',
188    dependencies: [
189        conf_h_dep,
190        pdi_dep,
191        phosphor_logging_dep,
192        sdbusplus_dep,
193        sdeventplus_dep,
194    ],
195    install: true,
196)
197
198subdir('dist')
199
200if not get_option('tests').disabled()
201    subdir('test')
202endif
203