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', |
| 3 | version: '0.1', meson_version: '>=0.49.0', |
| 4 | default_options: [ |
| 5 | 'warning_level=3', |
| 6 | 'werror=true', |
Ben Tyner | 92e39fd | 2020-02-05 18:11:02 -0600 | [diff] [blame] | 7 | 'cpp_std=c++17', |
Zane Shelley | 248cbf8 | 2019-05-03 17:07:18 -0500 | [diff] [blame] | 8 | ]) |
| 9 | |
Zane Shelley | d9573f4 | 2020-12-02 15:52:06 -0600 | [diff] [blame] | 10 | #------------------------------------------------------------------------------- |
Ben Tyner | eea4542 | 2021-04-15 10:54:14 -0500 | [diff] [blame] | 11 | # Versioning |
| 12 | #------------------------------------------------------------------------------- |
| 13 | buildinfo = vcs_tag(command: ['git', 'describe', '--always', '--long'], |
| 14 | input: 'buildinfo.hpp.in', |
| 15 | output: 'buildinfo.hpp', |
| 16 | replace_string:'@BUILDINFO@', |
| 17 | fallback: '0') |
| 18 | |
| 19 | #------------------------------------------------------------------------------- |
Zane Shelley | d9573f4 | 2020-12-02 15:52:06 -0600 | [diff] [blame] | 20 | # Compiler |
| 21 | #------------------------------------------------------------------------------- |
| 22 | |
Zane Shelley | f80482a | 2020-12-02 15:13:13 -0600 | [diff] [blame] | 23 | cmplr = meson.get_compiler('cpp') |
| 24 | |
Zane Shelley | d9573f4 | 2020-12-02 15:52:06 -0600 | [diff] [blame] | 25 | #------------------------------------------------------------------------------- |
Zane Shelley | 3a85108 | 2021-03-23 16:45:28 -0500 | [diff] [blame] | 26 | # Config file |
| 27 | #------------------------------------------------------------------------------- |
| 28 | |
| 29 | conf = configuration_data() |
| 30 | |
| 31 | conf.set('CONFIG_PHAL_API', get_option('phal').enabled()) |
| 32 | |
| 33 | configure_file(input: 'config.h.in', output: 'config.h', configuration: conf) |
| 34 | |
| 35 | #------------------------------------------------------------------------------- |
Zane Shelley | d9573f4 | 2020-12-02 15:52:06 -0600 | [diff] [blame] | 36 | # Include directories |
| 37 | #------------------------------------------------------------------------------- |
| 38 | |
| 39 | # Only using the base directory. All header includes should provide the full |
| 40 | # path from the base directory. |
| 41 | incdir = include_directories('.') |
| 42 | |
| 43 | #------------------------------------------------------------------------------- |
| 44 | # External library dependencies |
| 45 | #------------------------------------------------------------------------------- |
| 46 | |
| 47 | # Look if the libhei library has already been built and installed. If not, |
| 48 | # default to the subproject. |
Zane Shelley | f480b73 | 2020-06-11 10:05:16 -0500 | [diff] [blame] | 49 | libhei_dep = dependency('hei', fallback : ['libhei', 'libhei_dep']) |
Ben Tyner | 92e39fd | 2020-02-05 18:11:02 -0600 | [diff] [blame] | 50 | |
Zane Shelley | 61465db | 2020-10-30 14:53:11 -0500 | [diff] [blame] | 51 | sdbusplus_dep = dependency('sdbusplus', version : '>=1.0') |
| 52 | dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') |
| 53 | |
Zane Shelley | f80482a | 2020-12-02 15:13:13 -0600 | [diff] [blame] | 54 | libpdbg_dep = cmplr.find_library('pdbg') |
| 55 | |
Ben Tyner | 1368308 | 2020-06-25 12:49:47 -0500 | [diff] [blame] | 56 | # See if phosphor-logging is available, if not use test case logging code. This |
| 57 | # allows for local builds outside of CI test sandbox. |
| 58 | h = 'phosphor-logging/log.hpp' |
Ben Tyner | 1368308 | 2020-06-25 12:49:47 -0500 | [diff] [blame] | 59 | if cmplr.compiles('#include <@0@>'.format(h), name : '#include <@0@>'.format(h)) |
| 60 | test_arg = [] |
| 61 | phosphor_logging = true |
| 62 | else |
| 63 | test_arg = [ |
| 64 | '-DTEST_TRACE', |
| 65 | ] |
| 66 | phosphor_logging = false |
| 67 | endif |
| 68 | |
Zane Shelley | c252894 | 2020-12-02 15:42:42 -0600 | [diff] [blame] | 69 | pthread = declare_dependency(link_args : '-pthread') |
| 70 | lrt = declare_dependency(link_args : '-lrt') |
| 71 | |
| 72 | #------------------------------------------------------------------------------- |
Zane Shelley | d9573f4 | 2020-12-02 15:52:06 -0600 | [diff] [blame] | 73 | # Build the local static libraries |
Zane Shelley | c252894 | 2020-12-02 15:42:42 -0600 | [diff] [blame] | 74 | #------------------------------------------------------------------------------- |
| 75 | |
Ben Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 76 | subdir('analyzer') |
Ben Tyner | ef32015 | 2020-01-09 10:31:23 -0600 | [diff] [blame] | 77 | subdir('attn') |
Zane Shelley | f80482a | 2020-12-02 15:13:13 -0600 | [diff] [blame] | 78 | subdir('util') |
Zane Shelley | 248cbf8 | 2019-05-03 17:07:18 -0500 | [diff] [blame] | 79 | |
Zane Shelley | c252894 | 2020-12-02 15:42:42 -0600 | [diff] [blame] | 80 | hwdiags_libs = [ |
| 81 | analyzer_lib, |
| 82 | attn_lib, |
| 83 | util_lib, |
| 84 | ] |
| 85 | |
| 86 | #------------------------------------------------------------------------------- |
| 87 | # Build the executable |
| 88 | #------------------------------------------------------------------------------- |
Ben Tyner | 8c2f8b2 | 2020-03-27 10:39:31 -0500 | [diff] [blame] | 89 | |
Ben Tyner | d3cda74 | 2020-05-04 08:00:28 -0500 | [diff] [blame] | 90 | no_listener_mode = get_option('nlmode') |
| 91 | |
| 92 | if not no_listener_mode.disabled() |
Ben Tyner | 832526d | 2021-05-05 13:34:28 -0500 | [diff] [blame] | 93 | executable('openpower-hw-diags', |
| 94 | sources : [ 'main_nl.cpp', 'cli.cpp', buildinfo ], |
Zane Shelley | c252894 | 2020-12-02 15:42:42 -0600 | [diff] [blame] | 95 | link_with : hwdiags_libs, |
Ben Tyner | d3cda74 | 2020-05-04 08:00:28 -0500 | [diff] [blame] | 96 | install : true) |
| 97 | else |
Ben Tyner | 832526d | 2021-05-05 13:34:28 -0500 | [diff] [blame] | 98 | executable('openpower-hw-diags', |
| 99 | sources : [ 'main.cpp', 'cli.cpp', 'listener.cpp', buildinfo ], |
Ben Tyner | d3cda74 | 2020-05-04 08:00:28 -0500 | [diff] [blame] | 100 | dependencies : [lrt, pthread], |
Zane Shelley | c252894 | 2020-12-02 15:42:42 -0600 | [diff] [blame] | 101 | link_with : hwdiags_libs, |
Ben Tyner | 1368308 | 2020-06-25 12:49:47 -0500 | [diff] [blame] | 102 | cpp_args : test_arg, |
Ben Tyner | d3cda74 | 2020-05-04 08:00:28 -0500 | [diff] [blame] | 103 | install : true) |
| 104 | endif |
Ben Tyner | 0205f3b | 2020-02-24 10:24:47 -0600 | [diff] [blame] | 105 | |
Zane Shelley | c252894 | 2020-12-02 15:42:42 -0600 | [diff] [blame] | 106 | #------------------------------------------------------------------------------- |
| 107 | # Test, if configured |
| 108 | #------------------------------------------------------------------------------- |
| 109 | |
Zane Shelley | 248cbf8 | 2019-05-03 17:07:18 -0500 | [diff] [blame] | 110 | build_tests = get_option('tests') |
| 111 | |
| 112 | if not build_tests.disabled() |
| 113 | subdir('test') |
| 114 | endif |