blob: a1040b16fe8e14f67c0e6f3b09b570c48b58f59f [file] [log] [blame]
Zane Shelleyf480b732020-06-11 10:05:16 -05001# See README.md for details.
Zane Shelley248cbf82019-05-03 17:07:18 -05002project('openpower-hw-diags', 'cpp',
Patrick Williams7c80e522023-07-12 11:16:00 -05003 version: '0.1', meson_version: '>=1.1.1',
Zane Shelley248cbf82019-05-03 17:07:18 -05004 default_options: [
5 'warning_level=3',
6 'werror=true',
Patrick Williams7c80e522023-07-12 11:16:00 -05007 'cpp_std=c++23',
Zane Shelley248cbf82019-05-03 17:07:18 -05008 ])
9
Zane Shelleyd2854b72021-08-04 22:23:20 -050010# Package directory root, which will contain required data files.
11package_dir = join_paths( get_option('prefix'),
12 get_option('datadir'),
13 meson.project_name() )
14
15# Compiler option so that source knows the package directory.
16package_args = [ '-DPACKAGE_DIR="' + package_dir + '/"' ]
17
Zane Shelleyd9573f42020-12-02 15:52:06 -060018#-------------------------------------------------------------------------------
Ben Tynereea45422021-04-15 10:54:14 -050019# Versioning
20#-------------------------------------------------------------------------------
21buildinfo = vcs_tag(command: ['git', 'describe', '--always', '--long'],
22 input: 'buildinfo.hpp.in',
23 output: 'buildinfo.hpp',
24 replace_string:'@BUILDINFO@',
25 fallback: '0')
26
27#-------------------------------------------------------------------------------
Zane Shelleyd9573f42020-12-02 15:52:06 -060028# Compiler
29#-------------------------------------------------------------------------------
30
Zane Shelleyf80482a2020-12-02 15:13:13 -060031cmplr = meson.get_compiler('cpp')
32
Zane Shelleyd9573f42020-12-02 15:52:06 -060033#-------------------------------------------------------------------------------
Zane Shelley3a851082021-03-23 16:45:28 -050034# Config file
35#-------------------------------------------------------------------------------
36
37conf = configuration_data()
38
Dhruvaraj Subhashchandran0c1487c2024-06-01 11:07:26 -050039# OpenPOWER dump object path override
40conf.set_quoted('OP_DUMP_OBJ_PATH', get_option('op_dump_obj_path'))
41
Patrick Williams7619ab72023-11-29 06:44:58 -060042conf.set('CONFIG_PHAL_API', get_option('phal').allowed())
Zane Shelley3a851082021-03-23 16:45:28 -050043
44configure_file(input: 'config.h.in', output: 'config.h', configuration: conf)
45
46#-------------------------------------------------------------------------------
Zane Shelleyd9573f42020-12-02 15:52:06 -060047# Include directories
48#-------------------------------------------------------------------------------
49
50# Only using the base directory. All header includes should provide the full
51# path from the base directory.
52incdir = include_directories('.')
53
54#-------------------------------------------------------------------------------
55# External library dependencies
56#-------------------------------------------------------------------------------
57
58# Look if the libhei library has already been built and installed. If not,
59# default to the subproject.
Zane Shelleyf480b732020-06-11 10:05:16 -050060libhei_dep = dependency('hei', fallback : ['libhei', 'libhei_dep'])
Ben Tyner92e39fd2020-02-05 18:11:02 -060061
Zane Shelley30984d12021-12-22 17:17:54 -060062phosphor_logging_dep = dependency('phosphor-logging',
63 fallback: ['phosphor-logging', 'phosphor_logging_dep'])
64
Zane Shelley61465db2020-10-30 14:53:11 -050065sdbusplus_dep = dependency('sdbusplus', version : '>=1.0')
66dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
67
Andrew Jeffery7f516a02024-06-27 19:42:19 +093068libpdbg_dep = dependency('pdbg')
Zane Shelleyf80482a2020-12-02 15:13:13 -060069
Patrick Williams7619ab72023-11-29 06:44:58 -060070if get_option('phal').allowed()
Ben Tynerb9715172021-09-29 08:46:19 -050071 libphal_dep = cmplr.find_library('phal')
72endif
73
Ben Tynerbb90afc2022-12-14 20:50:33 -060074libpldm_dep = dependency('libpldm')
75
Zane Shelleyc2528942020-12-02 15:42:42 -060076pthread = declare_dependency(link_args : '-pthread')
77lrt = declare_dependency(link_args : '-lrt')
78
Zane Shelley5191bae2021-08-04 22:48:28 -050079# JSON parser
Patrick Williams54e71c02023-12-07 12:00:20 -060080nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Zane Shelley5191bae2021-08-04 22:48:28 -050081
82# JSON validator
83if cmplr.has_header('valijson/validator.hpp')
84 valijson_dep = declare_dependency()
85else
Andrew Jeffery3dc7bc82024-06-27 19:52:38 +093086 valijson_dep = dependency('valijson', include_type: 'system')
Zane Shelley5191bae2021-08-04 22:48:28 -050087endif
88
Zane Shelleyc2528942020-12-02 15:42:42 -060089#-------------------------------------------------------------------------------
Zane Shelleyd9573f42020-12-02 15:52:06 -060090# Build the local static libraries
Zane Shelleyc2528942020-12-02 15:42:42 -060091#-------------------------------------------------------------------------------
92
Ben Tyner0205f3b2020-02-24 10:24:47 -060093subdir('analyzer')
Ben Tyneref320152020-01-09 10:31:23 -060094subdir('attn')
Zane Shelleyf80482a2020-12-02 15:13:13 -060095subdir('util')
Zane Shelley248cbf82019-05-03 17:07:18 -050096
Zane Shelleyc2528942020-12-02 15:42:42 -060097hwdiags_libs = [
98 analyzer_lib,
99 attn_lib,
100 util_lib,
101]
102
103#-------------------------------------------------------------------------------
104# Build the executable
105#-------------------------------------------------------------------------------
Ben Tyner8c2f8b22020-03-27 10:39:31 -0500106
Ben Tynerd3cda742020-05-04 08:00:28 -0500107no_listener_mode = get_option('nlmode')
108
109if not no_listener_mode.disabled()
Ben Tyner832526d2021-05-05 13:34:28 -0500110 executable('openpower-hw-diags',
Zane Shelley475237a2022-02-03 11:04:54 -0600111 sources : [ 'main_nl.cpp', 'cli.cpp', buildinfo, plugins_src ],
Andrew Jeffery9de0f642024-06-27 20:07:09 +0930112 dependencies : [ libhei_dep, nlohmann_json_dep, phosphor_logging_dep ],
Zane Shelleyc2528942020-12-02 15:42:42 -0600113 link_with : hwdiags_libs,
Ben Tynerd3cda742020-05-04 08:00:28 -0500114 install : true)
115else
Ben Tyner832526d2021-05-05 13:34:28 -0500116 executable('openpower-hw-diags',
Zane Shelley475237a2022-02-03 11:04:54 -0600117 sources : [ 'main.cpp', 'cli.cpp', 'listener.cpp', buildinfo,
118 plugins_src ],
Andrew Jeffery9de0f642024-06-27 20:07:09 +0930119 dependencies : [lrt, pthread, libhei_dep, nlohmann_json_dep, phosphor_logging_dep ],
Zane Shelleyc2528942020-12-02 15:42:42 -0600120 link_with : hwdiags_libs,
Ben Tynerd3cda742020-05-04 08:00:28 -0500121 install : true)
122endif
Ben Tyner0205f3b2020-02-24 10:24:47 -0600123
Zane Shelleyc2528942020-12-02 15:42:42 -0600124#-------------------------------------------------------------------------------
125# Test, if configured
126#-------------------------------------------------------------------------------
127
Zane Shelley248cbf82019-05-03 17:07:18 -0500128build_tests = get_option('tests')
129
130if not build_tests.disabled()
austinfcui5dbebde2022-04-12 16:30:38 -0500131
132 # IMPORTANT NOTE:
133 # We cannot link the test executables to `util_lib` because:
134 # - It is built without `-DTEST_TRACE` and any of the util functions that
135 # use `trace.hpp` will throw a linker error because we don't have access
136 # to phosphor-logging in test ... yet. This issue will go away once we
137 # have converted all of our trace to use the `lg2` interfaces.
138 # - Some functions related to pdbg and dbus simply cannot be built in the
139 # test environment. Instead, there are alternate implementation of those
140 # functions to simulate them for testing (see `test/*-sim-only.cpp`).
141 # Instead we will build a `test_util_lib` that will contain the `util` files
142 # that we need in test along with simulated versions of some util functions.
143
144 # IMPORTANT NOTE:
145 # When running GCOV reports, the Jenkins CI script explicitly ignores any
146 # libraries and executables built in the `test/` directory. Therefore, this
147 # `test_util_lib` library must be built here instead in order to get any GCOV
148 # credit for the code.
149
150 test_args = [
151 '-DTEST_TRACE',
152 package_args,
153 ]
154
155 test_util_srcs = [
156 files(
157 'util/data_file.cpp',
158 'util/ffdc_file.cpp',
159 'util/pdbg.cpp',
160 'util/temporary_file.cpp',
161 'test/dbus-sim-only.cpp',
162 'test/pdbg-sim-only.cpp',
163 ),
164 ]
165
166 test_util_deps = [
167 libhei_dep,
168 libpdbg_dep,
Andrew Jeffery9de0f642024-06-27 20:07:09 +0930169 nlohmann_json_dep,
austinfcui5dbebde2022-04-12 16:30:38 -0500170 phosphor_logging_dep,
Andrew Jeffery9de0f642024-06-27 20:07:09 +0930171 valijson_dep,
austinfcui5dbebde2022-04-12 16:30:38 -0500172 ]
173
174 test_util_lib = static_library('test_util_lib',
175 sources : test_util_srcs,
176 include_directories : incdir,
177 dependencies : test_util_deps,
178 cpp_args : test_args,
179 install : true,
180 )
181
182 test_libs = [
183 analyzer_lib,
184 attn_lib,
185 test_util_lib,
186 ]
187
Zane Shelley248cbf82019-05-03 17:07:18 -0500188 subdir('test')
189endif