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    'journal.cpp',
66    'json_utils.cpp',
67    'log_id.cpp',
68    'mru.cpp',
69    'mtms.cpp',
70    'pce_identity.cpp',
71    'pel.cpp',
72    'pel_rules.cpp',
73    'pel_values.cpp',
74    'private_header.cpp',
75    'registry.cpp',
76    'section_factory.cpp',
77    'service_indicators.cpp',
78    'severity.cpp',
79    'user_header.cpp',
80    'temporary_file.cpp',
81    extra_sources,
82)
83
84libpel_deps = [
85    conf_h_dep,
86    libpldm_dep,
87    nlohmann_json,
88    sdbusplus_dep,
89    sdeventplus_dep,
90    pdi_dep,
91    phosphor_logging_dep,
92    extra_dependencies,
93]
94
95libpel_lib = static_library(
96    'pel',
97    libpel_sources,
98    'paths.cpp', # paths is separate because it is overridden during test.
99    include_directories: include_directories('../..', '../../gen'),
100    cpp_args: extra_args,
101    dependencies: [
102        libpel_deps,
103    ]
104)
105
106libpel_dep = declare_dependency(
107    include_directories: include_directories('.'),
108    link_with: libpel_lib,
109    dependencies: [
110        libpldm_dep,
111        nlohmann_json,
112        sdbusplus_dep,
113        sdeventplus_dep,
114        pdi_dep,
115        phosphor_logging_dep,
116    ]
117)
118
119log_manager_ext_deps += [
120    libpel_dep,
121    libpldm_dep,
122    nlohmann_json,
123]
124
125log_manager_ext_sources += files(
126    'entry_points.cpp',
127    'extended_user_data.cpp',
128    'host_notifier.cpp',
129    'manager.cpp',
130    'pel_entry.cpp',
131    'pldm_interface.cpp',
132    'repository.cpp',
133    'src.cpp',
134    'user_data.cpp',
135)
136
137install_data(
138    'registry/message_registry.json',
139    'registry/O_component_ids.json',
140    'registry/B_component_ids.json',
141    install_dir: get_option('datadir') / 'phosphor-logging/pels',
142)
143
144peltool_sources = files(
145    'extended_user_data.cpp',
146    'src.cpp',
147    'user_data.cpp',
148    'user_data_json.cpp',
149)
150
151peltool_deps = [
152    CLI11_dep,
153    conf_h_dep,
154    python_dep,
155]
156
157executable(
158    'peltool',
159    'tools/peltool.cpp',
160    peltool_sources,
161    cpp_args: [ '-DPELTOOL' ],
162    link_args: [ '-lpython' + python_ver ],
163    include_directories: include_directories('../..'),
164    dependencies: [
165        peltool_deps,
166        libpel_dep,
167    ],
168    install: true,
169)
170