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