1libpldm_dep = dependency(
2    'libpldm',
3    fallback: ['pldm', 'libpldm_dep'],
4    default_options: ['libpldm-only=enabled', 'oem-ibm=enabled'],
5)
6
7if cpp.has_header('nlohmann/json.hpp')
8    nlohmann_json = declare_dependency()
9else
10    subproject('nlohmann-json')
11    nlohmann_json = declare_dependency(
12        include_directories: include_directories(
13            '../../subprojects/nlohmann-json/single_include',
14            '../../subprojects/nlohmann-json/single_include/nlohmann',
15        )
16    )
17endif
18
19python_inst = import('python').find_installation('python3')
20python_ver = python_inst.language_version()
21python_dep = python_inst.dependency()
22
23if cpp.has_header('CLI/CLI.hpp')
24    CLI11_dep = declare_dependency()
25else
26    CLI11_dep = dependency(
27        'CLI11',
28        fallback: [ 'CLI11', 'CLI11_dep' ],
29    )
30endif
31
32extra_sources = []
33extra_dependencies = []
34extra_args = []
35
36build_phal = get_option('phal').enabled()
37
38if build_phal
39    extra_sources += [
40        'sbe_ffdc_handler.cpp',
41        'fapi_data_process.cpp',
42        'phal_service_actions.cpp',
43    ]
44    extra_dependencies += [
45        dependency('libdt-api'),
46        cpp.find_library('pdbg'),
47        cpp.find_library('ekb'),
48        cpp.find_library('phal'),
49    ]
50    extra_args += [
51        '-DPEL_ENABLE_PHAL',
52    ]
53    log_manager_ext_args += [
54        '-DPEL_ENABLE_PHAL',
55    ]
56endif
57
58libpel_sources = files(
59    'ascii_string.cpp',
60    'bcd_time.cpp',
61    'callout.cpp',
62    'callouts.cpp',
63    'data_interface.cpp',
64    'device_callouts.cpp',
65    'extended_user_header.cpp',
66    'failing_mtms.cpp',
67    'fru_identity.cpp',
68    'generic.cpp',
69    'json_utils.cpp',
70    'log_id.cpp',
71    'mru.cpp',
72    'mtms.cpp',
73    'pce_identity.cpp',
74    'pel.cpp',
75    'pel_rules.cpp',
76    'pel_values.cpp',
77    'private_header.cpp',
78    'registry.cpp',
79    'section_factory.cpp',
80    'service_indicators.cpp',
81    'severity.cpp',
82    'user_header.cpp',
83    'temporary_file.cpp',
84    extra_sources,
85)
86
87libpel_deps = [
88    conf_h_dep,
89    libpldm_dep,
90    nlohmann_json,
91    sdbusplus_dep,
92    sdeventplus_dep,
93    pdi_dep,
94    phosphor_logging_dep,
95    extra_dependencies,
96]
97
98libpel_lib = static_library(
99    'pel',
100    libpel_sources,
101    'paths.cpp', # paths is separate because it is overridden during test.
102    include_directories: include_directories('../..', '../../gen'),
103    cpp_args: extra_args,
104    dependencies: [
105        libpel_deps,
106    ]
107)
108
109libpel_dep = declare_dependency(
110    include_directories: include_directories('.'),
111    link_with: libpel_lib,
112    dependencies: [
113        libpldm_dep,
114        nlohmann_json,
115        sdbusplus_dep,
116        sdeventplus_dep,
117        pdi_dep,
118        phosphor_logging_dep,
119    ]
120)
121
122log_manager_ext_deps += [
123    libpel_dep,
124    libpldm_dep,
125    nlohmann_json,
126]
127
128log_manager_ext_sources += files(
129    'entry_points.cpp',
130    'extended_user_data.cpp',
131    'host_notifier.cpp',
132    'manager.cpp',
133    'pel_entry.cpp',
134    'pldm_interface.cpp',
135    'repository.cpp',
136    'src.cpp',
137    'user_data.cpp',
138)
139
140install_data(
141    'registry/message_registry.json',
142    install_dir: get_option('datadir') / 'phosphor-logging/pels',
143)
144
145peltool_sources = files(
146    'extended_user_data.cpp',
147    'src.cpp',
148    'user_data.cpp',
149    'user_data_json.cpp',
150)
151
152peltool_deps = [
153    CLI11_dep,
154    conf_h_dep,
155    python_dep,
156]
157
158executable(
159    'peltool',
160    'tools/peltool.cpp',
161    peltool_sources,
162    cpp_args: [ '-DPELTOOL' ],
163    link_args: [ '-lpython' + python_ver ],
164    include_directories: include_directories('../..'),
165    dependencies: [
166        peltool_deps,
167        libpel_dep,
168    ],
169    install: true,
170)
171