xref: /openbmc/phosphor-logging/meson.build (revision dc35e3073a4395aee9fa04b9bc4b259bca539836)
1f06056bcSPatrick Williamsproject('phosphor-logging', 'cpp',
219257fd2SPatrick Williams    meson_version: '>=1.1.1',
3f06056bcSPatrick Williams    default_options: [
4f06056bcSPatrick Williams      'buildtype=debugoptimized',
519257fd2SPatrick Williams      'cpp_std=c++23',
6f06056bcSPatrick Williams      'warning_level=3',
7f06056bcSPatrick Williams      'werror=true',
8e0538848SWilliam A. Kennington III      'libonly=' + (meson.is_subproject() ? 'true' : 'false'),
9515653b4SWilliam A. Kennington III      'tests=' + (meson.is_subproject() ? 'disabled' : 'auto'),
10f06056bcSPatrick Williams    ],
11f06056bcSPatrick Williams    version: '1.0.0',
12f06056bcSPatrick Williams)
1362bc968dSPatrick Williamscpp = meson.get_compiler('cpp')
14f06056bcSPatrick Williams
15e0538848SWilliam A. Kennington IIIpython_prog = find_program('python3', native: true)
167576224aSPatrick Williamslibsystemd_dep = dependency('libsystemd')
17f06056bcSPatrick Williams
1862bc968dSPatrick Williamssdbusplus_dep = dependency('sdbusplus')
1962bc968dSPatrick Williamssdbusplusplus_prog = find_program('sdbus++', native: true)
2062bc968dSPatrick Williamssdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true)
211d038d58SPatrick Williamssdbusplusplus_depfiles = files()
221d038d58SPatrick Williamsif sdbusplus_dep.type_name() == 'internal'
231d038d58SPatrick Williams    sdbusplusplus_depfiles = subproject('sdbusplus').get_variable('sdbusplusplus_depfiles')
241d038d58SPatrick Williamsendif
25f06056bcSPatrick Williams
2662bc968dSPatrick Williamspdi_dep = dependency('phosphor-dbus-interfaces')
27e0538848SWilliam A. Kennington III
28e0538848SWilliam A. Kennington III# Find the installed YAML directory, either from a configure option or
29e0538848SWilliam A. Kennington III# by pulling it from the PDI dependency.
30e0538848SWilliam A. Kennington IIIyamldir = get_option('yamldir')
31e0538848SWilliam A. Kennington IIIif yamldir == ''
32ff5f42faSPatrick Williams    yamldir = pdi_dep.get_variable('yamldir')
33e0538848SWilliam A. Kennington IIIendif
34e0538848SWilliam A. Kennington III
35e0538848SWilliam A. Kennington IIIsubdir('config')
36e0538848SWilliam A. Kennington IIIsubdir('tools')
37e0538848SWilliam A. Kennington IIIsubdir('lib')
38e0538848SWilliam A. Kennington III
39e0538848SWilliam A. Kennington IIIif get_option('libonly')
40e0538848SWilliam A. Kennington III  subdir_done()
41e0538848SWilliam A. Kennington IIIendif
42e0538848SWilliam A. Kennington III
4362bc968dSPatrick Williamssdeventplus_dep = dependency('sdeventplus')
44f06056bcSPatrick Williams
450bb89f8aSPatrick Williams# Get Cereal dependency.
460b08776aSWilliam A. Kennington IIIcereal_dep = dependency('cereal', required: false)
470b08776aSWilliam A. Kennington IIIhas_cereal = cpp.has_header_symbol(
480b08776aSWilliam A. Kennington III    'cereal/cereal.hpp',
490b08776aSWilliam A. Kennington III    'cereal::specialize',
500b08776aSWilliam A. Kennington III    dependencies: cereal_dep,
510b08776aSWilliam A. Kennington III    required: false)
520b08776aSWilliam A. Kennington IIIif not has_cereal
530b08776aSWilliam A. Kennington III    cereal_opts = import('cmake').subproject_options()
54f02b78c6SKonstantin Aladyshev    cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'})
550b08776aSWilliam A. Kennington III    cereal_proj = import('cmake').subproject(
560b08776aSWilliam A. Kennington III        'cereal',
570b08776aSWilliam A. Kennington III        options: cereal_opts,
580b08776aSWilliam A. Kennington III        required: false)
590b08776aSWilliam A. Kennington III    assert(cereal_proj.found(), 'cereal is required')
603e55d4dbSPatrick Williams    cereal_dep = cereal_proj.dependency('cereal')
610bb89f8aSPatrick Williamsendif
620bb89f8aSPatrick Williams
63*dc35e307SPatrick Williams# Get CLI11 dependency
64*dc35e307SPatrick Williamsif cpp.has_header('CLI/CLI.hpp')
65*dc35e307SPatrick Williams    CLI11_dep = declare_dependency()
66*dc35e307SPatrick Williamselse
67*dc35e307SPatrick Williams    CLI11_dep = dependency('CLI11')
68*dc35e307SPatrick Williamsendif
69*dc35e307SPatrick Williams
70*dc35e307SPatrick Williamsnlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
71*dc35e307SPatrick Williams
720bb89f8aSPatrick Williams# Generate sdbus++ files.
730bb89f8aSPatrick Williamsgenerated_sources = []
740bb89f8aSPatrick Williamsgenerated_others = []
750bb89f8aSPatrick Williamssubdir('gen')
760bb89f8aSPatrick Williamssubdir('gen/xyz')
770bb89f8aSPatrick Williams
78f06056bcSPatrick Williams# Generate callouts-gen.hpp.
79f06056bcSPatrick Williamscallouts_gen = custom_target('callouts-gen.hpp'.underscorify(),
80f06056bcSPatrick Williams    input: [
81f06056bcSPatrick Williams        'callouts/callouts.py',
82f06056bcSPatrick Williams        'callouts/callouts-gen.mako.hpp',
83f06056bcSPatrick Williams        get_option('callout_yaml'),
84f06056bcSPatrick Williams    ],
85f06056bcSPatrick Williams    output: 'callouts-gen.hpp',
86f06056bcSPatrick Williams    command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@', '-o', '@OUTPUT0@' ],
87f06056bcSPatrick Williams)
880bb89f8aSPatrick Williams# Generate elog-lookup.cpp
890bb89f8aSPatrick Williamselog_lookup_gen = custom_target('elog-lookup.cpp'.underscorify(),
900bb89f8aSPatrick Williams    input: files(
910bb89f8aSPatrick Williams        'tools/elog-gen.py',
920bb89f8aSPatrick Williams        'tools/phosphor-logging/templates/elog-lookup-template.mako.cpp',
930bb89f8aSPatrick Williams    ),
940bb89f8aSPatrick Williams    output: 'elog-lookup.cpp',
950bb89f8aSPatrick Williams    command: [
960bb89f8aSPatrick Williams        python_prog, '@INPUT0@',
970bb89f8aSPatrick Williams        '-t', '',
980bb89f8aSPatrick Williams        '-m', '@INPUT1@',
990bb89f8aSPatrick Williams        '-y', yamldir,
10047c77342STim Lee        '-u', meson.current_source_dir() / 'tools/',
1010bb89f8aSPatrick Williams        '-o', '@OUTPUT0@',
1020bb89f8aSPatrick Williams    ],
1030bb89f8aSPatrick Williams)
1040bb89f8aSPatrick Williams# Generate elog-process-metadata.cpp
1050bb89f8aSPatrick Williamselog_process_gen = custom_target('elog-process-metadata.cpp'.underscorify(),
1060bb89f8aSPatrick Williams    input: files(
1070bb89f8aSPatrick Williams        'tools/elog-gen.py',
1080bb89f8aSPatrick Williams        'tools/phosphor-logging/templates/elog-process-metadata.mako.cpp',
1090bb89f8aSPatrick Williams    ),
1100bb89f8aSPatrick Williams    output: 'elog-process-metadata.cpp',
1110bb89f8aSPatrick Williams    command: [
1120bb89f8aSPatrick Williams        python_prog, '@INPUT0@',
1130bb89f8aSPatrick Williams        '-t', '',
1140bb89f8aSPatrick Williams        '-m', '@INPUT1@',
1150bb89f8aSPatrick Williams        '-y', yamldir,
11647c77342STim Lee        '-u', meson.current_source_dir() / 'tools/',
1170bb89f8aSPatrick Williams        '-o', '@OUTPUT0@',
1180bb89f8aSPatrick Williams    ],
1190bb89f8aSPatrick Williams)
120f06056bcSPatrick Williams
121d9f0d646SPatrick Williamslog_manager_ext_sources = []
122d9f0d646SPatrick Williamslog_manager_ext_deps = []
1238fd187e4SWilliam A. Kennington IIIlog_manager_ext_args = []
124d9f0d646SPatrick Williams
125d9f0d646SPatrick Williamssubdir('extensions')
126b2b27085SPatrick Williamssubdir('phosphor-rsyslog-config')
127f06056bcSPatrick Williams
1280bb89f8aSPatrick Williams# Generate daemon.
129a517197dSPatrick Williamslog_manager_sources = [
1300bb89f8aSPatrick Williams    generated_sources,
131e0538848SWilliam A. Kennington III    callouts_gen,
1320bb89f8aSPatrick Williams    elog_lookup_gen,
1330bb89f8aSPatrick Williams    elog_process_gen,
134a517197dSPatrick Williams    files(
1350bb89f8aSPatrick Williams        'elog_entry.cpp',
1360bb89f8aSPatrick Williams        'elog_meta.cpp',
1370bb89f8aSPatrick Williams        'elog_serialize.cpp',
1380bb89f8aSPatrick Williams        'extensions.cpp',
1390bb89f8aSPatrick Williams        'log_manager.cpp',
140fa2d962bSPatrick Williams        'paths.cpp',
1410bb89f8aSPatrick Williams        'util.cpp',
142a517197dSPatrick Williams    )
143a517197dSPatrick Williams]
144d9f0d646SPatrick Williamslog_manager_deps = [
145d9f0d646SPatrick Williams    cereal_dep,
146e0538848SWilliam A. Kennington III    conf_h_dep,
147d9f0d646SPatrick Williams    pdi_dep,
148e0538848SWilliam A. Kennington III    phosphor_logging_dep,
149d9f0d646SPatrick Williams    sdbusplus_dep,
150d9f0d646SPatrick Williams    sdeventplus_dep,
151d9f0d646SPatrick Williams]
152a517197dSPatrick Williamsexecutable('phosphor-log-manager',
153a517197dSPatrick Williams    log_manager_sources,
154d9f0d646SPatrick Williams    log_manager_ext_sources,
155a517197dSPatrick Williams    'log_manager_main.cpp',
1560bb89f8aSPatrick Williams    include_directories: include_directories('gen'),
1578fd187e4SWilliam A. Kennington III    cpp_args: log_manager_ext_args,
1580bb89f8aSPatrick Williams    dependencies: [
159d9f0d646SPatrick Williams        log_manager_deps,
160d9f0d646SPatrick Williams        log_manager_ext_deps,
1610bb89f8aSPatrick Williams    ],
1620bb89f8aSPatrick Williams    install: true,
1630bb89f8aSPatrick Williams)
164*dc35e307SPatrick Williams
165*dc35e307SPatrick Williamsexecutable('log-create',
166*dc35e307SPatrick Williams    'log_create_main.cpp',
167*dc35e307SPatrick Williams    dependencies: [
168*dc35e307SPatrick Williams        CLI11_dep,
169*dc35e307SPatrick Williams        nlohmann_json_dep,
170*dc35e307SPatrick Williams        pdi_dep,
171*dc35e307SPatrick Williams        phosphor_logging_dep,
172*dc35e307SPatrick Williams        sdbusplus_dep,
173*dc35e307SPatrick Williams    ],
174*dc35e307SPatrick Williams    install: true,
175*dc35e307SPatrick Williams)
176*dc35e307SPatrick Williams
177ddd4fac0SPatrick Williams# Generate test executables which run in obmc env (qemu, real hardware).
178ddd4fac0SPatrick Williamsexecutable('logging-test',
179ddd4fac0SPatrick Williams    'logging_test.cpp',
180ddd4fac0SPatrick Williams    dependencies: [
181ddd4fac0SPatrick Williams        pdi_dep,
182e0538848SWilliam A. Kennington III        phosphor_logging_dep,
183ddd4fac0SPatrick Williams        sdbusplus_dep,
184ddd4fac0SPatrick Williams    ],
185ddd4fac0SPatrick Williams    install: true,
186ddd4fac0SPatrick Williams)
187ddd4fac0SPatrick Williamsexecutable('callout-test',
188ddd4fac0SPatrick Williams    'callouts/callout_test.cpp',
189ddd4fac0SPatrick Williams    dependencies: [
190e0538848SWilliam A. Kennington III        conf_h_dep,
191ddd4fac0SPatrick Williams        pdi_dep,
192e0538848SWilliam A. Kennington III        phosphor_logging_dep,
193ddd4fac0SPatrick Williams        sdbusplus_dep,
194ddd4fac0SPatrick Williams        sdeventplus_dep,
195ddd4fac0SPatrick Williams    ],
196ddd4fac0SPatrick Williams    install: true,
197ddd4fac0SPatrick Williams)
198a517197dSPatrick Williams
199271408b5SAnton D. Kachalovsubdir('dist')
200271408b5SAnton D. Kachalov
201a517197dSPatrick Williamsif not get_option('tests').disabled()
202a517197dSPatrick Williams    subdir('test')
203a517197dSPatrick Williamsendif
204