1f480b739SZane Shelley# See README.md for details. 2248cbf83SZane Shelleyproject('openpower-hw-diags', 'cpp', 32923775fSZane Shelley version: '0.1', meson_version: '>=0.57.0', 4248cbf83SZane Shelley default_options: [ 5248cbf83SZane Shelley 'warning_level=3', 6248cbf83SZane Shelley 'werror=true', 72923775fSZane Shelley 'cpp_std=c++20', 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 393a85108fSZane Shelleyconf.set('CONFIG_PHAL_API', get_option('phal').enabled()) 403a85108fSZane Shelley 413a85108fSZane Shelleyconfigure_file(input: 'config.h.in', output: 'config.h', configuration: conf) 423a85108fSZane Shelley 433a85108fSZane Shelley#------------------------------------------------------------------------------- 44d9573f48SZane Shelley# Include directories 45d9573f48SZane Shelley#------------------------------------------------------------------------------- 46d9573f48SZane Shelley 47d9573f48SZane Shelley# Only using the base directory. All header includes should provide the full 48d9573f48SZane Shelley# path from the base directory. 49d9573f48SZane Shelleyincdir = include_directories('.') 50d9573f48SZane Shelley 51d9573f48SZane Shelley#------------------------------------------------------------------------------- 52d9573f48SZane Shelley# External library dependencies 53d9573f48SZane Shelley#------------------------------------------------------------------------------- 54d9573f48SZane Shelley 55d9573f48SZane Shelley# Look if the libhei library has already been built and installed. If not, 56d9573f48SZane Shelley# default to the subproject. 57f480b739SZane Shelleylibhei_dep = dependency('hei', fallback : ['libhei', 'libhei_dep']) 5892e39fd9SBen Tyner 5930984d15SZane Shelleyphosphor_logging_dep = dependency('phosphor-logging', 6030984d15SZane Shelley fallback: ['phosphor-logging', 'phosphor_logging_dep']) 6130984d15SZane Shelley 6261465db5SZane Shelleysdbusplus_dep = dependency('sdbusplus', version : '>=1.0') 6361465db5SZane Shelleydbus_interfaces_dep = dependency('phosphor-dbus-interfaces') 6461465db5SZane Shelley 65f80482a5SZane Shelleylibpdbg_dep = cmplr.find_library('pdbg') 66f80482a5SZane Shelley 6755e7fec3SZane Shelleyfmt_dep = dependency('fmt') 6855e7fec3SZane Shelley 69b9715179SBen Tynerif get_option('phal').enabled() 70b9715179SBen Tyner libphal_dep = cmplr.find_library('phal') 71b9715179SBen Tynerendif 72b9715179SBen Tyner 73c252894dSZane Shelleypthread = declare_dependency(link_args : '-pthread') 74c252894dSZane Shelleylrt = declare_dependency(link_args : '-lrt') 75c252894dSZane Shelley 765191bae9SZane Shelley# JSON parser 775191bae9SZane Shelleyif cmplr.has_header('nlohmann/json.hpp') 785191bae9SZane Shelley nlohmann_json_dep = declare_dependency() 795191bae9SZane Shelleyelse 805191bae9SZane Shelley subproject('nlohmann', required: false) 815191bae9SZane Shelley nlohmann_json_dep = declare_dependency( 825191bae9SZane Shelley include_directories: [ 835191bae9SZane Shelley 'subprojects/nlohmann/single_include', 845191bae9SZane Shelley 'subprojects/nlohmann/single_include/nlohmann', 855191bae9SZane Shelley ] 865191bae9SZane Shelley ) 875191bae9SZane Shelley nlohmann_json_dep = nlohmann_json_dep.as_system('system') 885191bae9SZane Shelleyendif 895191bae9SZane Shelley 905191bae9SZane Shelley# JSON validator 915191bae9SZane Shelleyif cmplr.has_header('valijson/validator.hpp') 925191bae9SZane Shelley valijson_dep = declare_dependency() 935191bae9SZane Shelleyelse 945191bae9SZane Shelley subproject('valijson', required: false) 955191bae9SZane Shelley valijson_dep = declare_dependency( 965191bae9SZane Shelley include_directories: 'subprojects/valijson/include' 975191bae9SZane Shelley ) 985191bae9SZane Shelley valijson_dep = valijson_dep.as_system('system') 995191bae9SZane Shelleyendif 1005191bae9SZane Shelley 101c252894dSZane Shelley#------------------------------------------------------------------------------- 102d9573f48SZane Shelley# Build the local static libraries 103c252894dSZane Shelley#------------------------------------------------------------------------------- 104c252894dSZane Shelley 1050205f3b3SBen Tynersubdir('analyzer') 106ef320154SBen Tynersubdir('attn') 107f80482a5SZane Shelleysubdir('util') 108248cbf83SZane Shelley 109c252894dSZane Shelleyhwdiags_libs = [ 110c252894dSZane Shelley analyzer_lib, 111c252894dSZane Shelley attn_lib, 112c252894dSZane Shelley util_lib, 113c252894dSZane Shelley] 114c252894dSZane Shelley 115c252894dSZane Shelley#------------------------------------------------------------------------------- 116c252894dSZane Shelley# Build the executable 117c252894dSZane Shelley#------------------------------------------------------------------------------- 1188c2f8b24SBen Tyner 119d3cda742SBen Tynerno_listener_mode = get_option('nlmode') 120d3cda742SBen Tyner 121d3cda742SBen Tynerif not no_listener_mode.disabled() 122832526dfSBen Tyner executable('openpower-hw-diags', 123475237a4SZane Shelley sources : [ 'main_nl.cpp', 'cli.cpp', buildinfo, plugins_src ], 124475237a4SZane Shelley dependencies : [ libhei_dep ], 125c252894dSZane Shelley link_with : hwdiags_libs, 126d3cda742SBen Tyner install : true) 127d3cda742SBen Tynerelse 128832526dfSBen Tyner executable('openpower-hw-diags', 129475237a4SZane Shelley sources : [ 'main.cpp', 'cli.cpp', 'listener.cpp', buildinfo, 130475237a4SZane Shelley plugins_src ], 131475237a4SZane Shelley dependencies : [lrt, pthread, libhei_dep], 132c252894dSZane Shelley link_with : hwdiags_libs, 1330205f3b3SBen Tyner install : true) 134d3cda742SBen Tynerendif 1350205f3b3SBen Tyner 136c252894dSZane Shelley#------------------------------------------------------------------------------- 137c252894dSZane Shelley# Test, if configured 138c252894dSZane Shelley#------------------------------------------------------------------------------- 139c252894dSZane Shelley 140248cbf83SZane Shelleybuild_tests = get_option('tests') 141248cbf83SZane Shelley 142248cbf83SZane Shelleyif not build_tests.disabled() 143*5dbebde0Saustinfcui 144*5dbebde0Saustinfcui # IMPORTANT NOTE: 145*5dbebde0Saustinfcui # We cannot link the test executables to `util_lib` because: 146*5dbebde0Saustinfcui # - It is built without `-DTEST_TRACE` and any of the util functions that 147*5dbebde0Saustinfcui # use `trace.hpp` will throw a linker error because we don't have access 148*5dbebde0Saustinfcui # to phosphor-logging in test ... yet. This issue will go away once we 149*5dbebde0Saustinfcui # have converted all of our trace to use the `lg2` interfaces. 150*5dbebde0Saustinfcui # - Some functions related to pdbg and dbus simply cannot be built in the 151*5dbebde0Saustinfcui # test environment. Instead, there are alternate implementation of those 152*5dbebde0Saustinfcui # functions to simulate them for testing (see `test/*-sim-only.cpp`). 153*5dbebde0Saustinfcui # Instead we will build a `test_util_lib` that will contain the `util` files 154*5dbebde0Saustinfcui # that we need in test along with simulated versions of some util functions. 155*5dbebde0Saustinfcui 156*5dbebde0Saustinfcui # IMPORTANT NOTE: 157*5dbebde0Saustinfcui # When running GCOV reports, the Jenkins CI script explicitly ignores any 158*5dbebde0Saustinfcui # libraries and executables built in the `test/` directory. Therefore, this 159*5dbebde0Saustinfcui # `test_util_lib` library must be built here instead in order to get any GCOV 160*5dbebde0Saustinfcui # credit for the code. 161*5dbebde0Saustinfcui 162*5dbebde0Saustinfcui test_args = [ 163*5dbebde0Saustinfcui '-DTEST_TRACE', 164*5dbebde0Saustinfcui package_args, 165*5dbebde0Saustinfcui ] 166*5dbebde0Saustinfcui 167*5dbebde0Saustinfcui test_util_srcs = [ 168*5dbebde0Saustinfcui files( 169*5dbebde0Saustinfcui 'util/data_file.cpp', 170*5dbebde0Saustinfcui 'util/ffdc_file.cpp', 171*5dbebde0Saustinfcui 'util/pdbg.cpp', 172*5dbebde0Saustinfcui 'util/temporary_file.cpp', 173*5dbebde0Saustinfcui 'test/dbus-sim-only.cpp', 174*5dbebde0Saustinfcui 'test/pdbg-sim-only.cpp', 175*5dbebde0Saustinfcui ), 176*5dbebde0Saustinfcui ] 177*5dbebde0Saustinfcui 178*5dbebde0Saustinfcui test_util_deps = [ 179*5dbebde0Saustinfcui libhei_dep, 180*5dbebde0Saustinfcui libpdbg_dep, 181*5dbebde0Saustinfcui phosphor_logging_dep, 182*5dbebde0Saustinfcui ] 183*5dbebde0Saustinfcui 184*5dbebde0Saustinfcui test_util_lib = static_library('test_util_lib', 185*5dbebde0Saustinfcui sources : test_util_srcs, 186*5dbebde0Saustinfcui include_directories : incdir, 187*5dbebde0Saustinfcui dependencies : test_util_deps, 188*5dbebde0Saustinfcui cpp_args : test_args, 189*5dbebde0Saustinfcui install : true, 190*5dbebde0Saustinfcui ) 191*5dbebde0Saustinfcui 192*5dbebde0Saustinfcui test_libs = [ 193*5dbebde0Saustinfcui analyzer_lib, 194*5dbebde0Saustinfcui attn_lib, 195*5dbebde0Saustinfcui test_util_lib, 196*5dbebde0Saustinfcui ] 197*5dbebde0Saustinfcui 198248cbf83SZane Shelley subdir('test') 199248cbf83SZane Shelleyendif 200