1f480b739SZane Shelley# See README.md for details. 2248cbf83SZane Shelleyproject('openpower-hw-diags', 'cpp', 37c80e52bSPatrick Williams version: '0.1', meson_version: '>=1.1.1', 4248cbf83SZane Shelley default_options: [ 5248cbf83SZane Shelley 'warning_level=3', 6248cbf83SZane Shelley 'werror=true', 77c80e52bSPatrick Williams 'cpp_std=c++23', 8248cbf83SZane Shelley ]) 9248cbf83SZane Shelley 10d2854b75SZane Shelley# Package directory root, which will contain required data files. 11d2854b75SZane Shelleypackage_dir = join_paths( get_option('prefix'), 12d2854b75SZane Shelley get_option('datadir'), 13d2854b75SZane Shelley meson.project_name() ) 14d2854b75SZane Shelley 15d2854b75SZane Shelley# Compiler option so that source knows the package directory. 16d2854b75SZane Shelleypackage_args = [ '-DPACKAGE_DIR="' + package_dir + '/"' ] 17d2854b75SZane Shelley 18d9573f48SZane Shelley#------------------------------------------------------------------------------- 19eea45427SBen Tyner# Versioning 20eea45427SBen Tyner#------------------------------------------------------------------------------- 21eea45427SBen Tynerbuildinfo = vcs_tag(command: ['git', 'describe', '--always', '--long'], 22eea45427SBen Tyner input: 'buildinfo.hpp.in', 23eea45427SBen Tyner output: 'buildinfo.hpp', 24eea45427SBen Tyner replace_string:'@BUILDINFO@', 25eea45427SBen Tyner fallback: '0') 26eea45427SBen Tyner 27eea45427SBen Tyner#------------------------------------------------------------------------------- 28d9573f48SZane Shelley# Compiler 29d9573f48SZane Shelley#------------------------------------------------------------------------------- 30d9573f48SZane Shelley 31f80482a5SZane Shelleycmplr = meson.get_compiler('cpp') 32f80482a5SZane Shelley 33d9573f48SZane Shelley#------------------------------------------------------------------------------- 343a85108fSZane Shelley# Config file 353a85108fSZane Shelley#------------------------------------------------------------------------------- 363a85108fSZane Shelley 373a85108fSZane Shelleyconf = configuration_data() 383a85108fSZane Shelley 390c1487cbSDhruvaraj Subhashchandran# OpenPOWER dump object path override 400c1487cbSDhruvaraj Subhashchandranconf.set_quoted('OP_DUMP_OBJ_PATH', get_option('op_dump_obj_path')) 410c1487cbSDhruvaraj Subhashchandran 427619ab78SPatrick Williamsconf.set('CONFIG_PHAL_API', get_option('phal').allowed()) 433a85108fSZane Shelley 443a85108fSZane Shelleyconfigure_file(input: 'config.h.in', output: 'config.h', configuration: conf) 453a85108fSZane Shelley 463a85108fSZane Shelley#------------------------------------------------------------------------------- 47d9573f48SZane Shelley# Include directories 48d9573f48SZane Shelley#------------------------------------------------------------------------------- 49d9573f48SZane Shelley 50d9573f48SZane Shelley# Only using the base directory. All header includes should provide the full 51d9573f48SZane Shelley# path from the base directory. 52d9573f48SZane Shelleyincdir = include_directories('.') 53d9573f48SZane Shelley 54d9573f48SZane Shelley#------------------------------------------------------------------------------- 55d9573f48SZane Shelley# External library dependencies 56d9573f48SZane Shelley#------------------------------------------------------------------------------- 57d9573f48SZane Shelley 58d9573f48SZane Shelley# Look if the libhei library has already been built and installed. If not, 59d9573f48SZane Shelley# default to the subproject. 60f480b739SZane Shelleylibhei_dep = dependency('hei', fallback : ['libhei', 'libhei_dep']) 6192e39fd9SBen Tyner 6230984d15SZane Shelleyphosphor_logging_dep = dependency('phosphor-logging', 6330984d15SZane Shelley fallback: ['phosphor-logging', 'phosphor_logging_dep']) 6430984d15SZane Shelley 6561465db5SZane Shelleysdbusplus_dep = dependency('sdbusplus', version : '>=1.0') 6661465db5SZane Shelleydbus_interfaces_dep = dependency('phosphor-dbus-interfaces') 6761465db5SZane Shelley 68*7f516a02SAndrew Jefferylibpdbg_dep = dependency('pdbg') 69f80482a5SZane Shelley 707619ab78SPatrick Williamsif get_option('phal').allowed() 71b9715179SBen Tyner libphal_dep = cmplr.find_library('phal') 72b9715179SBen Tynerendif 73b9715179SBen Tyner 74bb90afc7SBen Tynerlibpldm_dep = dependency('libpldm') 75bb90afc7SBen Tyner 76c252894dSZane Shelleypthread = declare_dependency(link_args : '-pthread') 77c252894dSZane Shelleylrt = declare_dependency(link_args : '-lrt') 78c252894dSZane Shelley 795191bae9SZane Shelley# JSON parser 8054e71c06SPatrick Williamsnlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') 815191bae9SZane Shelley 825191bae9SZane Shelley# JSON validator 835191bae9SZane Shelleyif cmplr.has_header('valijson/validator.hpp') 845191bae9SZane Shelley valijson_dep = declare_dependency() 855191bae9SZane Shelleyelse 865191bae9SZane Shelley subproject('valijson', required: false) 875191bae9SZane Shelley valijson_dep = declare_dependency( 885191bae9SZane Shelley include_directories: 'subprojects/valijson/include' 895191bae9SZane Shelley ) 905191bae9SZane Shelley valijson_dep = valijson_dep.as_system('system') 915191bae9SZane Shelleyendif 925191bae9SZane Shelley 93c252894dSZane Shelley#------------------------------------------------------------------------------- 94d9573f48SZane Shelley# Build the local static libraries 95c252894dSZane Shelley#------------------------------------------------------------------------------- 96c252894dSZane Shelley 970205f3b3SBen Tynersubdir('analyzer') 98ef320154SBen Tynersubdir('attn') 99f80482a5SZane Shelleysubdir('util') 100248cbf83SZane Shelley 101c252894dSZane Shelleyhwdiags_libs = [ 102c252894dSZane Shelley analyzer_lib, 103c252894dSZane Shelley attn_lib, 104c252894dSZane Shelley util_lib, 105c252894dSZane Shelley] 106c252894dSZane Shelley 107c252894dSZane Shelley#------------------------------------------------------------------------------- 108c252894dSZane Shelley# Build the executable 109c252894dSZane Shelley#------------------------------------------------------------------------------- 1108c2f8b24SBen Tyner 111d3cda742SBen Tynerno_listener_mode = get_option('nlmode') 112d3cda742SBen Tyner 113d3cda742SBen Tynerif not no_listener_mode.disabled() 114832526dfSBen Tyner executable('openpower-hw-diags', 115475237a4SZane Shelley sources : [ 'main_nl.cpp', 'cli.cpp', buildinfo, plugins_src ], 116475237a4SZane Shelley dependencies : [ libhei_dep ], 117c252894dSZane Shelley link_with : hwdiags_libs, 118d3cda742SBen Tyner install : true) 119d3cda742SBen Tynerelse 120832526dfSBen Tyner executable('openpower-hw-diags', 121475237a4SZane Shelley sources : [ 'main.cpp', 'cli.cpp', 'listener.cpp', buildinfo, 122475237a4SZane Shelley plugins_src ], 123475237a4SZane Shelley dependencies : [lrt, pthread, libhei_dep], 124c252894dSZane Shelley link_with : hwdiags_libs, 1250205f3b3SBen Tyner install : true) 126d3cda742SBen Tynerendif 1270205f3b3SBen Tyner 128c252894dSZane Shelley#------------------------------------------------------------------------------- 129c252894dSZane Shelley# Test, if configured 130c252894dSZane Shelley#------------------------------------------------------------------------------- 131c252894dSZane Shelley 132248cbf83SZane Shelleybuild_tests = get_option('tests') 133248cbf83SZane Shelley 134248cbf83SZane Shelleyif not build_tests.disabled() 1355dbebde0Saustinfcui 1365dbebde0Saustinfcui # IMPORTANT NOTE: 1375dbebde0Saustinfcui # We cannot link the test executables to `util_lib` because: 1385dbebde0Saustinfcui # - It is built without `-DTEST_TRACE` and any of the util functions that 1395dbebde0Saustinfcui # use `trace.hpp` will throw a linker error because we don't have access 1405dbebde0Saustinfcui # to phosphor-logging in test ... yet. This issue will go away once we 1415dbebde0Saustinfcui # have converted all of our trace to use the `lg2` interfaces. 1425dbebde0Saustinfcui # - Some functions related to pdbg and dbus simply cannot be built in the 1435dbebde0Saustinfcui # test environment. Instead, there are alternate implementation of those 1445dbebde0Saustinfcui # functions to simulate them for testing (see `test/*-sim-only.cpp`). 1455dbebde0Saustinfcui # Instead we will build a `test_util_lib` that will contain the `util` files 1465dbebde0Saustinfcui # that we need in test along with simulated versions of some util functions. 1475dbebde0Saustinfcui 1485dbebde0Saustinfcui # IMPORTANT NOTE: 1495dbebde0Saustinfcui # When running GCOV reports, the Jenkins CI script explicitly ignores any 1505dbebde0Saustinfcui # libraries and executables built in the `test/` directory. Therefore, this 1515dbebde0Saustinfcui # `test_util_lib` library must be built here instead in order to get any GCOV 1525dbebde0Saustinfcui # credit for the code. 1535dbebde0Saustinfcui 1545dbebde0Saustinfcui test_args = [ 1555dbebde0Saustinfcui '-DTEST_TRACE', 1565dbebde0Saustinfcui package_args, 1575dbebde0Saustinfcui ] 1585dbebde0Saustinfcui 1595dbebde0Saustinfcui test_util_srcs = [ 1605dbebde0Saustinfcui files( 1615dbebde0Saustinfcui 'util/data_file.cpp', 1625dbebde0Saustinfcui 'util/ffdc_file.cpp', 1635dbebde0Saustinfcui 'util/pdbg.cpp', 1645dbebde0Saustinfcui 'util/temporary_file.cpp', 1655dbebde0Saustinfcui 'test/dbus-sim-only.cpp', 1665dbebde0Saustinfcui 'test/pdbg-sim-only.cpp', 1675dbebde0Saustinfcui ), 1685dbebde0Saustinfcui ] 1695dbebde0Saustinfcui 1705dbebde0Saustinfcui test_util_deps = [ 1715dbebde0Saustinfcui libhei_dep, 1725dbebde0Saustinfcui libpdbg_dep, 1735dbebde0Saustinfcui phosphor_logging_dep, 1745dbebde0Saustinfcui ] 1755dbebde0Saustinfcui 1765dbebde0Saustinfcui test_util_lib = static_library('test_util_lib', 1775dbebde0Saustinfcui sources : test_util_srcs, 1785dbebde0Saustinfcui include_directories : incdir, 1795dbebde0Saustinfcui dependencies : test_util_deps, 1805dbebde0Saustinfcui cpp_args : test_args, 1815dbebde0Saustinfcui install : true, 1825dbebde0Saustinfcui ) 1835dbebde0Saustinfcui 1845dbebde0Saustinfcui test_libs = [ 1855dbebde0Saustinfcui analyzer_lib, 1865dbebde0Saustinfcui attn_lib, 1875dbebde0Saustinfcui test_util_lib, 1885dbebde0Saustinfcui ] 1895dbebde0Saustinfcui 190248cbf83SZane Shelley subdir('test') 191248cbf83SZane Shelleyendif 192