xref: /openbmc/phosphor-logging/meson.build (revision 0bb89f8a)
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    ],
9    version: '1.0.0',
10)
11
12python_prog = find_program('python3')
13
14# Get sdbusplus dependency.
15sdbusplus_dep = dependency('sdbusplus', required: false)
16if sdbusplus_dep.found()
17    sdbusplusplus_prog = find_program('sdbus++')
18    sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson')
19else
20    sdbusplus_proj = subproject('sdbusplus', required: true)
21    sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep')
22    sdbusplusplus_prog = sdbusplus_proj.get_variable('sdbusplusplus_prog')
23    sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable(
24        'sdbuspp_gen_meson_prog'
25    )
26endif
27
28# Get PDI and sdeventplus dependency.
29pdi_dep = dependency(
30    'phosphor-dbus-interfaces',
31    fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep'],
32)
33sdeventplus_dep = dependency(
34    'sdeventplus',
35    fallback: ['sdeventplus', 'sdeventplus_dep' ],
36)
37
38# Get Cereal dependency.
39cereal_dep = dependency('cereal', required: false)
40if not cereal_dep.found()
41    subproject('cereal', required: false)
42    cereal_dep = declare_dependency(
43        include_directories: [ 'subprojects/cereal/include' ],
44    )
45endif
46
47# Find the installed YAML directory, either from a configure option or
48# by pulling it from the PDI dependency.
49yamldir = get_option('yamldir')
50if yamldir == ''
51    yamldir = pdi_dep.get_variable(pkgconfig: 'yamldir', internal: 'yamldir')
52endif
53
54# Create config.h with constants that use to come from autoconf.
55conf_data = configuration_data()
56conf_data.set('error_cap', get_option('error_cap'))
57conf_data.set('error_info_cap', get_option('error_info_cap'))
58configure_file(
59    input: 'config.h.meson',
60    output: 'config.h',
61    configuration: conf_data,
62)
63
64# Generate sdbus++ files.
65generated_sources = []
66generated_others = []
67subdir('gen')
68subdir('gen/xyz')
69
70# Generate callouts-gen.hpp.
71callouts_gen = custom_target('callouts-gen.hpp'.underscorify(),
72    input: [
73        'callouts/callouts.py',
74        'callouts/callouts-gen.mako.hpp',
75        get_option('callout_yaml'),
76    ],
77    output: 'callouts-gen.hpp',
78    command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@', '-o', '@OUTPUT0@' ],
79)
80# Generate elog-lookup.cpp
81elog_lookup_gen = custom_target('elog-lookup.cpp'.underscorify(),
82    input: files(
83        'tools/elog-gen.py',
84        'tools/phosphor-logging/templates/elog-lookup-template.mako.cpp',
85    ),
86    output: 'elog-lookup.cpp',
87    command: [
88        python_prog, '@INPUT0@',
89        '-t', '',
90        '-m', '@INPUT1@',
91        '-y', yamldir,
92        '-u', meson.current_source_dir() / '../tools/',
93        '-o', '@OUTPUT0@',
94    ],
95)
96# Generate elog-process-metadata.cpp
97elog_process_gen = custom_target('elog-process-metadata.cpp'.underscorify(),
98    input: files(
99        'tools/elog-gen.py',
100        'tools/phosphor-logging/templates/elog-process-metadata.mako.cpp',
101    ),
102    output: 'elog-process-metadata.cpp',
103    command: [
104        python_prog, '@INPUT0@',
105        '-t', '',
106        '-m', '@INPUT1@',
107        '-y', yamldir,
108        '-u', meson.current_source_dir() / '../tools/',
109        '-o', '@OUTPUT0@',
110    ],
111)
112
113subdir('phosphor-logging')
114
115# Build libphosphor-logging.
116libphosphor_logging = library(
117    'phosphor_logging',
118    files(
119        'elog.cpp',
120        'elog_meta.cpp',
121        'sdjournal.cpp',
122    ),
123    callouts_gen,
124    elog_errors_gen,
125    dependencies: [ sdbusplus_dep, pdi_dep, sdeventplus_dep ],
126    version: meson.project_version(),
127    install: true,
128)
129
130import('pkgconfig').generate(
131    libphosphor_logging,
132    name: meson.project_name(),
133    version: meson.project_version(),
134    requires: [
135        'libsystemd',
136        'phosphor-dbus-interfaces',
137        'sdbusplus',
138    ],
139    description: 'Phosphor logging utilities',
140)
141
142# Create dependency for use as subproject.
143phosphor_logging_dep = declare_dependency(
144    include_directories: include_directories('.'),
145    link_with: libphosphor_logging,
146    sources: [ callouts_gen, elog_errors_gen ],
147    dependencies: [ sdbusplus_dep, pdi_dep, sdeventplus_dep],
148)
149
150# Generate daemon.
151executable('phosphor-log-manager',
152    generated_sources,
153    elog_lookup_gen,
154    elog_process_gen,
155    'elog_entry.cpp',
156    'elog_meta.cpp',
157    'elog_serialize.cpp',
158    'extensions.cpp',
159    'log_manager.cpp',
160    'log_manager_main.cpp',
161    'sdjournal.cpp',
162    'util.cpp',
163    include_directories: include_directories('gen'),
164    link_with: libphosphor_logging,
165    dependencies: [
166        cereal_dep,
167        pdi_dep,
168        sdbusplus_dep,
169        sdeventplus_dep
170    ],
171    install: true,
172)
173