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