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 687f516a02SAndrew 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 863dc7bc88SAndrew Jeffery valijson_dep = dependency('valijson', include_type: 'system') 875191bae9SZane Shelleyendif 885191bae9SZane Shelley 89c252894dSZane Shelley#------------------------------------------------------------------------------- 90d9573f48SZane Shelley# Build the local static libraries 91c252894dSZane Shelley#------------------------------------------------------------------------------- 92c252894dSZane Shelley 930205f3b3SBen Tynersubdir('analyzer') 94ef320154SBen Tynersubdir('attn') 95f80482a5SZane Shelleysubdir('util') 96248cbf83SZane Shelley 97c252894dSZane Shelleyhwdiags_libs = [ 98c252894dSZane Shelley analyzer_lib, 99c252894dSZane Shelley attn_lib, 100c252894dSZane Shelley util_lib, 101c252894dSZane Shelley] 102c252894dSZane Shelley 103c252894dSZane Shelley#------------------------------------------------------------------------------- 104c252894dSZane Shelley# Build the executable 105c252894dSZane Shelley#------------------------------------------------------------------------------- 1068c2f8b24SBen Tyner 107d3cda742SBen Tynerno_listener_mode = get_option('nlmode') 108d3cda742SBen Tyner 109d3cda742SBen Tynerif not no_listener_mode.disabled() 110832526dfSBen Tyner executable('openpower-hw-diags', 111475237a4SZane Shelley sources : [ 'main_nl.cpp', 'cli.cpp', buildinfo, plugins_src ], 112*9de0f649SAndrew Jeffery dependencies : [ libhei_dep, nlohmann_json_dep, phosphor_logging_dep ], 113c252894dSZane Shelley link_with : hwdiags_libs, 114d3cda742SBen Tyner install : true) 115d3cda742SBen Tynerelse 116832526dfSBen Tyner executable('openpower-hw-diags', 117475237a4SZane Shelley sources : [ 'main.cpp', 'cli.cpp', 'listener.cpp', buildinfo, 118475237a4SZane Shelley plugins_src ], 119*9de0f649SAndrew Jeffery dependencies : [lrt, pthread, libhei_dep, nlohmann_json_dep, phosphor_logging_dep ], 120c252894dSZane Shelley link_with : hwdiags_libs, 1210205f3b3SBen Tyner install : true) 122d3cda742SBen Tynerendif 1230205f3b3SBen Tyner 124c252894dSZane Shelley#------------------------------------------------------------------------------- 125c252894dSZane Shelley# Test, if configured 126c252894dSZane Shelley#------------------------------------------------------------------------------- 127c252894dSZane Shelley 128248cbf83SZane Shelleybuild_tests = get_option('tests') 129248cbf83SZane Shelley 130248cbf83SZane Shelleyif not build_tests.disabled() 1315dbebde0Saustinfcui 1325dbebde0Saustinfcui # IMPORTANT NOTE: 1335dbebde0Saustinfcui # We cannot link the test executables to `util_lib` because: 1345dbebde0Saustinfcui # - It is built without `-DTEST_TRACE` and any of the util functions that 1355dbebde0Saustinfcui # use `trace.hpp` will throw a linker error because we don't have access 1365dbebde0Saustinfcui # to phosphor-logging in test ... yet. This issue will go away once we 1375dbebde0Saustinfcui # have converted all of our trace to use the `lg2` interfaces. 1385dbebde0Saustinfcui # - Some functions related to pdbg and dbus simply cannot be built in the 1395dbebde0Saustinfcui # test environment. Instead, there are alternate implementation of those 1405dbebde0Saustinfcui # functions to simulate them for testing (see `test/*-sim-only.cpp`). 1415dbebde0Saustinfcui # Instead we will build a `test_util_lib` that will contain the `util` files 1425dbebde0Saustinfcui # that we need in test along with simulated versions of some util functions. 1435dbebde0Saustinfcui 1445dbebde0Saustinfcui # IMPORTANT NOTE: 1455dbebde0Saustinfcui # When running GCOV reports, the Jenkins CI script explicitly ignores any 1465dbebde0Saustinfcui # libraries and executables built in the `test/` directory. Therefore, this 1475dbebde0Saustinfcui # `test_util_lib` library must be built here instead in order to get any GCOV 1485dbebde0Saustinfcui # credit for the code. 1495dbebde0Saustinfcui 1505dbebde0Saustinfcui test_args = [ 1515dbebde0Saustinfcui '-DTEST_TRACE', 1525dbebde0Saustinfcui package_args, 1535dbebde0Saustinfcui ] 1545dbebde0Saustinfcui 1555dbebde0Saustinfcui test_util_srcs = [ 1565dbebde0Saustinfcui files( 1575dbebde0Saustinfcui 'util/data_file.cpp', 1585dbebde0Saustinfcui 'util/ffdc_file.cpp', 1595dbebde0Saustinfcui 'util/pdbg.cpp', 1605dbebde0Saustinfcui 'util/temporary_file.cpp', 1615dbebde0Saustinfcui 'test/dbus-sim-only.cpp', 1625dbebde0Saustinfcui 'test/pdbg-sim-only.cpp', 1635dbebde0Saustinfcui ), 1645dbebde0Saustinfcui ] 1655dbebde0Saustinfcui 1665dbebde0Saustinfcui test_util_deps = [ 1675dbebde0Saustinfcui libhei_dep, 1685dbebde0Saustinfcui libpdbg_dep, 169*9de0f649SAndrew Jeffery nlohmann_json_dep, 1705dbebde0Saustinfcui phosphor_logging_dep, 171*9de0f649SAndrew Jeffery valijson_dep, 1725dbebde0Saustinfcui ] 1735dbebde0Saustinfcui 1745dbebde0Saustinfcui test_util_lib = static_library('test_util_lib', 1755dbebde0Saustinfcui sources : test_util_srcs, 1765dbebde0Saustinfcui include_directories : incdir, 1775dbebde0Saustinfcui dependencies : test_util_deps, 1785dbebde0Saustinfcui cpp_args : test_args, 1795dbebde0Saustinfcui install : true, 1805dbebde0Saustinfcui ) 1815dbebde0Saustinfcui 1825dbebde0Saustinfcui test_libs = [ 1835dbebde0Saustinfcui analyzer_lib, 1845dbebde0Saustinfcui attn_lib, 1855dbebde0Saustinfcui test_util_lib, 1865dbebde0Saustinfcui ] 1875dbebde0Saustinfcui 188248cbf83SZane Shelley subdir('test') 189248cbf83SZane Shelleyendif 190