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