Zane Shelley | f480b73 | 2020-06-11 10:05:16 -0500 | [diff] [blame] | 1 | # See README.md for details. |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame] | 2 | project( |
| 3 | 'openpower-hw-diags', |
| 4 | 'cpp', |
| 5 | version: '0.1', |
| 6 | meson_version: '>=1.1.1', |
| 7 | default_options: ['warning_level=3', 'werror=true', 'cpp_std=c++23'], |
| 8 | ) |
Zane Shelley | 248cbf8 | 2019-05-03 17:07:18 -0500 | [diff] [blame] | 9 | |
Zane Shelley | d2854b7 | 2021-08-04 22:23:20 -0500 | [diff] [blame] | 10 | # Package directory root, which will contain required data files. |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame] | 11 | package_dir = join_paths( |
| 12 | get_option('prefix'), |
| 13 | get_option('datadir'), |
| 14 | meson.project_name(), |
| 15 | ) |
Zane Shelley | d2854b7 | 2021-08-04 22:23:20 -0500 | [diff] [blame] | 16 | |
| 17 | # Compiler option so that source knows the package directory. |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame] | 18 | package_args = ['-DPACKAGE_DIR="' + package_dir + '/"'] |
Zane Shelley | d2854b7 | 2021-08-04 22:23:20 -0500 | [diff] [blame] | 19 | |
Zane Shelley | d9573f4 | 2020-12-02 15:52:06 -0600 | [diff] [blame] | 20 | #------------------------------------------------------------------------------- |
Ben Tyner | eea4542 | 2021-04-15 10:54:14 -0500 | [diff] [blame] | 21 | # Versioning |
| 22 | #------------------------------------------------------------------------------- |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame] | 23 | buildinfo = vcs_tag( |
| 24 | command: ['git', 'describe', '--always', '--long'], |
| 25 | input: 'buildinfo.hpp.in', |
| 26 | output: 'buildinfo.hpp', |
| 27 | replace_string: '@BUILDINFO@', |
| 28 | fallback: '0', |
| 29 | ) |
Ben Tyner | eea4542 | 2021-04-15 10:54:14 -0500 | [diff] [blame] | 30 | |
| 31 | #------------------------------------------------------------------------------- |
Zane Shelley | d9573f4 | 2020-12-02 15:52:06 -0600 | [diff] [blame] | 32 | # Compiler |
| 33 | #------------------------------------------------------------------------------- |
| 34 | |
Zane Shelley | f80482a | 2020-12-02 15:13:13 -0600 | [diff] [blame] | 35 | cmplr = meson.get_compiler('cpp') |
| 36 | |
Zane Shelley | d9573f4 | 2020-12-02 15:52:06 -0600 | [diff] [blame] | 37 | #------------------------------------------------------------------------------- |
Zane Shelley | 3a85108 | 2021-03-23 16:45:28 -0500 | [diff] [blame] | 38 | # Config file |
| 39 | #------------------------------------------------------------------------------- |
| 40 | |
| 41 | conf = configuration_data() |
| 42 | |
Dhruvaraj Subhashchandran | 0c1487c | 2024-06-01 11:07:26 -0500 | [diff] [blame] | 43 | # OpenPOWER dump object path override |
| 44 | conf.set_quoted('OP_DUMP_OBJ_PATH', get_option('op_dump_obj_path')) |
| 45 | |
Patrick Williams | 7619ab7 | 2023-11-29 06:44:58 -0600 | [diff] [blame] | 46 | conf.set('CONFIG_PHAL_API', get_option('phal').allowed()) |
Zane Shelley | 3a85108 | 2021-03-23 16:45:28 -0500 | [diff] [blame] | 47 | |
Pavithra Barithaya | 316acda | 2025-01-20 14:57:12 +0530 | [diff] [blame] | 48 | if(get_option('transport-implementation')) == 'mctp-demux' |
| 49 | add_project_arguments('-DPLDM_TRANSPORT_WITH_MCTP_DEMUX', language : 'cpp') |
| 50 | else |
| 51 | add_project_arguments('-DPLDM_TRANSPORT_WITH_AF_MCTP', language: 'cpp') |
| 52 | endif |
| 53 | |
Pavithra Barithaya | 9b1a0b6 | 2024-10-14 19:16:11 +0530 | [diff] [blame] | 54 | if cmplr.has_header('poll.h') |
| 55 | add_project_arguments('-DPLDM_HAS_POLL=1', language: 'cpp') |
| 56 | endif |
| 57 | |
Zane Shelley | 3a85108 | 2021-03-23 16:45:28 -0500 | [diff] [blame] | 58 | configure_file(input: 'config.h.in', output: 'config.h', configuration: conf) |
| 59 | |
| 60 | #------------------------------------------------------------------------------- |
Zane Shelley | d9573f4 | 2020-12-02 15:52:06 -0600 | [diff] [blame] | 61 | # Include directories |
| 62 | #------------------------------------------------------------------------------- |
| 63 | |
| 64 | # Only using the base directory. All header includes should provide the full |
| 65 | # path from the base directory. |
| 66 | incdir = include_directories('.') |
| 67 | |
| 68 | #------------------------------------------------------------------------------- |
| 69 | # External library dependencies |
| 70 | #------------------------------------------------------------------------------- |
| 71 | |
| 72 | # Look if the libhei library has already been built and installed. If not, |
| 73 | # default to the subproject. |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame] | 74 | libhei_dep = dependency('hei', fallback: ['libhei', 'libhei_dep']) |
Ben Tyner | 92e39fd | 2020-02-05 18:11:02 -0600 | [diff] [blame] | 75 | |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame] | 76 | phosphor_logging_dep = dependency( |
| 77 | 'phosphor-logging', |
| 78 | fallback: ['phosphor-logging', 'phosphor_logging_dep'], |
| 79 | ) |
Zane Shelley | 30984d1 | 2021-12-22 17:17:54 -0600 | [diff] [blame] | 80 | |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame] | 81 | sdbusplus_dep = dependency('sdbusplus', version: '>=1.0') |
Zane Shelley | 61465db | 2020-10-30 14:53:11 -0500 | [diff] [blame] | 82 | dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') |
| 83 | |
Andrew Jeffery | 7f516a0 | 2024-06-27 19:42:19 +0930 | [diff] [blame] | 84 | libpdbg_dep = dependency('pdbg') |
Zane Shelley | f80482a | 2020-12-02 15:13:13 -0600 | [diff] [blame] | 85 | |
Patrick Williams | 7619ab7 | 2023-11-29 06:44:58 -0600 | [diff] [blame] | 86 | if get_option('phal').allowed() |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame] | 87 | libphal_dep = cmplr.find_library('phal') |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 88 | endif |
| 89 | |
Ben Tyner | bb90afc | 2022-12-14 20:50:33 -0600 | [diff] [blame] | 90 | libpldm_dep = dependency('libpldm') |
| 91 | |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame] | 92 | pthread = declare_dependency(link_args: '-pthread') |
| 93 | lrt = declare_dependency(link_args: '-lrt') |
Zane Shelley | c252894 | 2020-12-02 15:42:42 -0600 | [diff] [blame] | 94 | |
Zane Shelley | 5191bae | 2021-08-04 22:48:28 -0500 | [diff] [blame] | 95 | # JSON parser |
Patrick Williams | 54e71c0 | 2023-12-07 12:00:20 -0600 | [diff] [blame] | 96 | nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') |
Zane Shelley | 5191bae | 2021-08-04 22:48:28 -0500 | [diff] [blame] | 97 | |
| 98 | # JSON validator |
| 99 | if cmplr.has_header('valijson/validator.hpp') |
| 100 | valijson_dep = declare_dependency() |
| 101 | else |
Andrew Jeffery | 3dc7bc8 | 2024-06-27 19:52:38 +0930 | [diff] [blame] | 102 | valijson_dep = dependency('valijson', include_type: 'system') |
Zane Shelley | 5191bae | 2021-08-04 22:48:28 -0500 | [diff] [blame] | 103 | endif |
| 104 | |
Zane Shelley | c252894 | 2020-12-02 15:42:42 -0600 | [diff] [blame] | 105 | #------------------------------------------------------------------------------- |
Zane Shelley | d9573f4 | 2020-12-02 15:52:06 -0600 | [diff] [blame] | 106 | # Build the local static libraries |
Zane Shelley | c252894 | 2020-12-02 15:42:42 -0600 | [diff] [blame] | 107 | #------------------------------------------------------------------------------- |
| 108 | |
Ben Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 109 | subdir('analyzer') |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 110 | subdir('attn') |
Zane Shelley | f80482a | 2020-12-02 15:13:13 -0600 | [diff] [blame] | 111 | subdir('util') |
Zane Shelley | 248cbf8 | 2019-05-03 17:07:18 -0500 | [diff] [blame] | 112 | |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame] | 113 | hwdiags_libs = [analyzer_lib, attn_lib, util_lib] |
Zane Shelley | c252894 | 2020-12-02 15:42:42 -0600 | [diff] [blame] | 114 | |
| 115 | #------------------------------------------------------------------------------- |
| 116 | # Build the executable |
| 117 | #------------------------------------------------------------------------------- |
Ben Tyner | 8c2f8b2 | 2020-03-27 10:39:31 -0500 | [diff] [blame] | 118 | |
Ben Tyner | d3cda74 | 2020-05-04 08:00:28 -0500 | [diff] [blame] | 119 | no_listener_mode = get_option('nlmode') |
| 120 | |
Patrick Williams | 588ca2b | 2025-01-30 17:48:11 -0500 | [diff] [blame] | 121 | if no_listener_mode.allowed() |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame] | 122 | executable( |
| 123 | 'openpower-hw-diags', |
| 124 | sources: ['main_nl.cpp', 'cli.cpp', buildinfo, plugins_src], |
| 125 | dependencies: [libhei_dep, nlohmann_json_dep, phosphor_logging_dep], |
| 126 | link_with: hwdiags_libs, |
| 127 | install: true, |
| 128 | ) |
Ben Tyner | d3cda74 | 2020-05-04 08:00:28 -0500 | [diff] [blame] | 129 | else |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame] | 130 | executable( |
| 131 | 'openpower-hw-diags', |
| 132 | sources: ['main.cpp', 'cli.cpp', 'listener.cpp', buildinfo, plugins_src], |
| 133 | dependencies: [ |
| 134 | lrt, |
| 135 | pthread, |
| 136 | libhei_dep, |
| 137 | nlohmann_json_dep, |
| 138 | phosphor_logging_dep, |
| 139 | ], |
| 140 | link_with: hwdiags_libs, |
| 141 | install: true, |
| 142 | ) |
Ben Tyner | d3cda74 | 2020-05-04 08:00:28 -0500 | [diff] [blame] | 143 | endif |
Ben Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 144 | |
Zane Shelley | c252894 | 2020-12-02 15:42:42 -0600 | [diff] [blame] | 145 | #------------------------------------------------------------------------------- |
| 146 | # Test, if configured |
| 147 | #------------------------------------------------------------------------------- |
| 148 | |
Zane Shelley | 248cbf8 | 2019-05-03 17:07:18 -0500 | [diff] [blame] | 149 | build_tests = get_option('tests') |
| 150 | |
Patrick Williams | 588ca2b | 2025-01-30 17:48:11 -0500 | [diff] [blame] | 151 | if build_tests.allowed() |
austinfcui | 5dbebde | 2022-04-12 16:30:38 -0500 | [diff] [blame] | 152 | |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame] | 153 | # IMPORTANT NOTE: |
| 154 | # We cannot link the test executables to `util_lib` because: |
| 155 | # - It is built without `-DTEST_TRACE` and any of the util functions that |
| 156 | # use `trace.hpp` will throw a linker error because we don't have access |
| 157 | # to phosphor-logging in test ... yet. This issue will go away once we |
| 158 | # have converted all of our trace to use the `lg2` interfaces. |
| 159 | # - Some functions related to pdbg and dbus simply cannot be built in the |
| 160 | # test environment. Instead, there are alternate implementation of those |
| 161 | # functions to simulate them for testing (see `test/*-sim-only.cpp`). |
| 162 | # Instead we will build a `test_util_lib` that will contain the `util` files |
| 163 | # that we need in test along with simulated versions of some util functions. |
austinfcui | 5dbebde | 2022-04-12 16:30:38 -0500 | [diff] [blame] | 164 | |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame] | 165 | # IMPORTANT NOTE: |
| 166 | # When running GCOV reports, the Jenkins CI script explicitly ignores any |
| 167 | # libraries and executables built in the `test/` directory. Therefore, this |
| 168 | # `test_util_lib` library must be built here instead in order to get any GCOV |
| 169 | # credit for the code. |
austinfcui | 5dbebde | 2022-04-12 16:30:38 -0500 | [diff] [blame] | 170 | |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame] | 171 | test_args = ['-DTEST_TRACE', package_args] |
austinfcui | 5dbebde | 2022-04-12 16:30:38 -0500 | [diff] [blame] | 172 | |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame] | 173 | test_util_srcs = [ |
| 174 | files( |
| 175 | 'test/dbus-sim-only.cpp', |
| 176 | 'test/pdbg-sim-only.cpp', |
| 177 | 'util/data_file.cpp', |
| 178 | 'util/ffdc_file.cpp', |
| 179 | 'util/pdbg.cpp', |
| 180 | 'util/temporary_file.cpp', |
| 181 | ), |
| 182 | ] |
austinfcui | 5dbebde | 2022-04-12 16:30:38 -0500 | [diff] [blame] | 183 | |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame] | 184 | test_util_deps = [ |
| 185 | libhei_dep, |
| 186 | libpdbg_dep, |
| 187 | nlohmann_json_dep, |
| 188 | phosphor_logging_dep, |
| 189 | valijson_dep, |
| 190 | ] |
austinfcui | 5dbebde | 2022-04-12 16:30:38 -0500 | [diff] [blame] | 191 | |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame] | 192 | test_util_lib = static_library( |
| 193 | 'test_util_lib', |
| 194 | sources: test_util_srcs, |
| 195 | include_directories: incdir, |
| 196 | dependencies: test_util_deps, |
| 197 | cpp_args: test_args, |
| 198 | install: true, |
| 199 | ) |
austinfcui | 5dbebde | 2022-04-12 16:30:38 -0500 | [diff] [blame] | 200 | |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame] | 201 | test_libs = [analyzer_lib, attn_lib, test_util_lib] |
austinfcui | 5dbebde | 2022-04-12 16:30:38 -0500 | [diff] [blame] | 202 | |
Patrick Williams | c322c32 | 2025-02-01 08:38:07 -0500 | [diff] [blame] | 203 | subdir('test') |
Zane Shelley | 248cbf8 | 2019-05-03 17:07:18 -0500 | [diff] [blame] | 204 | endif |