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', |
Zane Shelley | 2923775 | 2021-12-22 11:00:30 -0600 | [diff] [blame] | 3 | version: '0.1', meson_version: '>=0.57.0', |
Zane Shelley | 248cbf8 | 2019-05-03 17:07:18 -0500 | [diff] [blame] | 4 | default_options: [ |
| 5 | 'warning_level=3', |
| 6 | 'werror=true', |
Zane Shelley | 2923775 | 2021-12-22 11:00:30 -0600 | [diff] [blame] | 7 | 'cpp_std=c++20', |
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 | |
| 39 | conf.set('CONFIG_PHAL_API', get_option('phal').enabled()) |
| 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 | 61465db | 2020-10-30 14:53:11 -0500 | [diff] [blame] | 59 | sdbusplus_dep = dependency('sdbusplus', version : '>=1.0') |
| 60 | dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') |
| 61 | |
Zane Shelley | f80482a | 2020-12-02 15:13:13 -0600 | [diff] [blame] | 62 | libpdbg_dep = cmplr.find_library('pdbg') |
| 63 | |
Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 64 | fmt_dep = dependency('fmt') |
| 65 | |
Ben Tyner | b971517 | 2021-09-29 08:46:19 -0500 | [diff] [blame] | 66 | if get_option('phal').enabled() |
| 67 | libphal_dep = cmplr.find_library('phal') |
| 68 | endif |
| 69 | |
Ben Tyner | 46b5e2b | 2022-02-16 13:11:23 -0600 | [diff] [blame] | 70 | # See if phosphor-logging is available, if not use test case logging code. |
Ben Tyner | 1368308 | 2020-06-25 12:49:47 -0500 | [diff] [blame] | 71 | h = 'phosphor-logging/log.hpp' |
Ben Tyner | 1368308 | 2020-06-25 12:49:47 -0500 | [diff] [blame] | 72 | if cmplr.compiles('#include <@0@>'.format(h), name : '#include <@0@>'.format(h)) |
| 73 | test_arg = [] |
Ben Tyner | 1368308 | 2020-06-25 12:49:47 -0500 | [diff] [blame] | 74 | else |
| 75 | test_arg = [ |
| 76 | '-DTEST_TRACE', |
| 77 | ] |
Ben Tyner | 1368308 | 2020-06-25 12:49:47 -0500 | [diff] [blame] | 78 | endif |
| 79 | |
Zane Shelley | c252894 | 2020-12-02 15:42:42 -0600 | [diff] [blame] | 80 | pthread = declare_dependency(link_args : '-pthread') |
| 81 | lrt = declare_dependency(link_args : '-lrt') |
| 82 | |
Zane Shelley | 5191bae | 2021-08-04 22:48:28 -0500 | [diff] [blame] | 83 | # JSON parser |
| 84 | if cmplr.has_header('nlohmann/json.hpp') |
| 85 | nlohmann_json_dep = declare_dependency() |
| 86 | else |
| 87 | subproject('nlohmann', required: false) |
| 88 | nlohmann_json_dep = declare_dependency( |
| 89 | include_directories: [ |
| 90 | 'subprojects/nlohmann/single_include', |
| 91 | 'subprojects/nlohmann/single_include/nlohmann', |
| 92 | ] |
| 93 | ) |
| 94 | nlohmann_json_dep = nlohmann_json_dep.as_system('system') |
| 95 | endif |
| 96 | |
| 97 | # JSON validator |
| 98 | if cmplr.has_header('valijson/validator.hpp') |
| 99 | valijson_dep = declare_dependency() |
| 100 | else |
| 101 | subproject('valijson', required: false) |
| 102 | valijson_dep = declare_dependency( |
| 103 | include_directories: 'subprojects/valijson/include' |
| 104 | ) |
| 105 | valijson_dep = valijson_dep.as_system('system') |
| 106 | endif |
| 107 | |
Zane Shelley | c252894 | 2020-12-02 15:42:42 -0600 | [diff] [blame] | 108 | #------------------------------------------------------------------------------- |
Zane Shelley | d9573f4 | 2020-12-02 15:52:06 -0600 | [diff] [blame] | 109 | # Build the local static libraries |
Zane Shelley | c252894 | 2020-12-02 15:42:42 -0600 | [diff] [blame] | 110 | #------------------------------------------------------------------------------- |
| 111 | |
Ben Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 112 | subdir('analyzer') |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 113 | subdir('attn') |
Zane Shelley | f80482a | 2020-12-02 15:13:13 -0600 | [diff] [blame] | 114 | subdir('util') |
Zane Shelley | 248cbf8 | 2019-05-03 17:07:18 -0500 | [diff] [blame] | 115 | |
Zane Shelley | c252894 | 2020-12-02 15:42:42 -0600 | [diff] [blame] | 116 | hwdiags_libs = [ |
| 117 | analyzer_lib, |
| 118 | attn_lib, |
| 119 | util_lib, |
| 120 | ] |
| 121 | |
| 122 | #------------------------------------------------------------------------------- |
| 123 | # Build the executable |
| 124 | #------------------------------------------------------------------------------- |
Ben Tyner | 8c2f8b2 | 2020-03-27 10:39:31 -0500 | [diff] [blame] | 125 | |
Ben Tyner | d3cda74 | 2020-05-04 08:00:28 -0500 | [diff] [blame] | 126 | no_listener_mode = get_option('nlmode') |
| 127 | |
| 128 | if not no_listener_mode.disabled() |
Ben Tyner | 832526d | 2021-05-05 13:34:28 -0500 | [diff] [blame] | 129 | executable('openpower-hw-diags', |
Zane Shelley | 475237a | 2022-02-03 11:04:54 -0600 | [diff] [blame] | 130 | sources : [ 'main_nl.cpp', 'cli.cpp', buildinfo, plugins_src ], |
| 131 | dependencies : [ libhei_dep ], |
Zane Shelley | c252894 | 2020-12-02 15:42:42 -0600 | [diff] [blame] | 132 | link_with : hwdiags_libs, |
Ben Tyner | d3cda74 | 2020-05-04 08:00:28 -0500 | [diff] [blame] | 133 | install : true) |
| 134 | else |
Ben Tyner | 832526d | 2021-05-05 13:34:28 -0500 | [diff] [blame] | 135 | executable('openpower-hw-diags', |
Zane Shelley | 475237a | 2022-02-03 11:04:54 -0600 | [diff] [blame] | 136 | sources : [ 'main.cpp', 'cli.cpp', 'listener.cpp', buildinfo, |
| 137 | plugins_src ], |
| 138 | dependencies : [lrt, pthread, libhei_dep], |
Zane Shelley | c252894 | 2020-12-02 15:42:42 -0600 | [diff] [blame] | 139 | link_with : hwdiags_libs, |
Ben Tyner | 1368308 | 2020-06-25 12:49:47 -0500 | [diff] [blame] | 140 | cpp_args : test_arg, |
Ben Tyner | d3cda74 | 2020-05-04 08:00:28 -0500 | [diff] [blame] | 141 | install : true) |
| 142 | endif |
Ben Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 143 | |
Zane Shelley | c252894 | 2020-12-02 15:42:42 -0600 | [diff] [blame] | 144 | #------------------------------------------------------------------------------- |
| 145 | # Test, if configured |
| 146 | #------------------------------------------------------------------------------- |
| 147 | |
Zane Shelley | 248cbf8 | 2019-05-03 17:07:18 -0500 | [diff] [blame] | 148 | build_tests = get_option('tests') |
| 149 | |
| 150 | if not build_tests.disabled() |
| 151 | subdir('test') |
| 152 | endif |