1# See README.md for details. 2project('openpower-hw-diags', 'cpp', 3 version: '0.1', meson_version: '>=0.49.0', 4 default_options: [ 5 'warning_level=3', 6 'werror=true', 7 'cpp_std=c++17', 8 ]) 9 10#------------------------------------------------------------------------------- 11# Compiler 12#------------------------------------------------------------------------------- 13 14cmplr = meson.get_compiler('cpp') 15 16#------------------------------------------------------------------------------- 17# Config file 18#------------------------------------------------------------------------------- 19 20conf = configuration_data() 21 22conf.set('CONFIG_PHAL_API', get_option('phal').enabled()) 23 24configure_file(input: 'config.h.in', output: 'config.h', configuration: conf) 25 26#------------------------------------------------------------------------------- 27# Include directories 28#------------------------------------------------------------------------------- 29 30# Only using the base directory. All header includes should provide the full 31# path from the base directory. 32incdir = include_directories('.') 33 34#------------------------------------------------------------------------------- 35# External library dependencies 36#------------------------------------------------------------------------------- 37 38# Look if the libhei library has already been built and installed. If not, 39# default to the subproject. 40libhei_dep = dependency('hei', fallback : ['libhei', 'libhei_dep']) 41 42sdbusplus_dep = dependency('sdbusplus', version : '>=1.0') 43dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') 44 45libpdbg_dep = cmplr.find_library('pdbg') 46 47# See if phosphor-logging is available, if not use test case logging code. This 48# allows for local builds outside of CI test sandbox. 49h = 'phosphor-logging/log.hpp' 50if cmplr.compiles('#include <@0@>'.format(h), name : '#include <@0@>'.format(h)) 51 test_arg = [] 52 phosphor_logging = true 53else 54 test_arg = [ 55 '-DTEST_TRACE', 56 ] 57 phosphor_logging = false 58endif 59 60pthread = declare_dependency(link_args : '-pthread') 61lrt = declare_dependency(link_args : '-lrt') 62 63#------------------------------------------------------------------------------- 64# Build the local static libraries 65#------------------------------------------------------------------------------- 66 67subdir('analyzer') 68subdir('attn') 69subdir('util') 70 71hwdiags_libs = [ 72 analyzer_lib, 73 attn_lib, 74 util_lib, 75] 76 77#------------------------------------------------------------------------------- 78# Build the executable 79#------------------------------------------------------------------------------- 80 81no_listener_mode = get_option('nlmode') 82 83if not no_listener_mode.disabled() 84 executable('openpower-hw-diags', 'main_nl.cpp', 'cli.cpp', 85 link_with : hwdiags_libs, 86 install : true) 87else 88 executable('openpower-hw-diags', 'main.cpp', 'cli.cpp', 'listener.cpp', 89 dependencies : [lrt, pthread], 90 link_with : hwdiags_libs, 91 cpp_args : test_arg, 92 install : true) 93endif 94 95#------------------------------------------------------------------------------- 96# Test, if configured 97#------------------------------------------------------------------------------- 98 99build_tests = get_option('tests') 100 101if not build_tests.disabled() 102 subdir('test') 103endif 104