1f480b739SZane Shelley# See README.md for details. 2248cbf83SZane Shelleyproject('openpower-hw-diags', 'cpp', 3248cbf83SZane Shelley version: '0.1', meson_version: '>=0.49.0', 4248cbf83SZane Shelley default_options: [ 5248cbf83SZane Shelley 'warning_level=3', 6248cbf83SZane Shelley 'werror=true', 792e39fd9SBen Tyner 'cpp_std=c++17', 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 5961465db5SZane Shelleysdbusplus_dep = dependency('sdbusplus', version : '>=1.0') 6061465db5SZane Shelleydbus_interfaces_dep = dependency('phosphor-dbus-interfaces') 6161465db5SZane Shelley 62f80482a5SZane Shelleylibpdbg_dep = cmplr.find_library('pdbg') 63f80482a5SZane Shelley 6413683089SBen Tyner# See if phosphor-logging is available, if not use test case logging code. This 6513683089SBen Tyner# allows for local builds outside of CI test sandbox. 6613683089SBen Tynerh = 'phosphor-logging/log.hpp' 6713683089SBen Tynerif cmplr.compiles('#include <@0@>'.format(h), name : '#include <@0@>'.format(h)) 6813683089SBen Tyner test_arg = [] 6913683089SBen Tyner phosphor_logging = true 7013683089SBen Tynerelse 7113683089SBen Tyner test_arg = [ 7213683089SBen Tyner '-DTEST_TRACE', 7313683089SBen Tyner ] 7413683089SBen Tyner phosphor_logging = false 7513683089SBen Tynerendif 7613683089SBen Tyner 77c252894dSZane Shelleypthread = declare_dependency(link_args : '-pthread') 78c252894dSZane Shelleylrt = declare_dependency(link_args : '-lrt') 79c252894dSZane Shelley 80*5191bae9SZane Shelley# JSON parser 81*5191bae9SZane Shelleyif cmplr.has_header('nlohmann/json.hpp') 82*5191bae9SZane Shelley nlohmann_json_dep = declare_dependency() 83*5191bae9SZane Shelleyelse 84*5191bae9SZane Shelley subproject('nlohmann', required: false) 85*5191bae9SZane Shelley nlohmann_json_dep = declare_dependency( 86*5191bae9SZane Shelley include_directories: [ 87*5191bae9SZane Shelley 'subprojects/nlohmann/single_include', 88*5191bae9SZane Shelley 'subprojects/nlohmann/single_include/nlohmann', 89*5191bae9SZane Shelley ] 90*5191bae9SZane Shelley ) 91*5191bae9SZane Shelley nlohmann_json_dep = nlohmann_json_dep.as_system('system') 92*5191bae9SZane Shelleyendif 93*5191bae9SZane Shelley 94*5191bae9SZane Shelley# JSON validator 95*5191bae9SZane Shelleyif cmplr.has_header('valijson/validator.hpp') 96*5191bae9SZane Shelley valijson_dep = declare_dependency() 97*5191bae9SZane Shelleyelse 98*5191bae9SZane Shelley subproject('valijson', required: false) 99*5191bae9SZane Shelley valijson_dep = declare_dependency( 100*5191bae9SZane Shelley include_directories: 'subprojects/valijson/include' 101*5191bae9SZane Shelley ) 102*5191bae9SZane Shelley valijson_dep = valijson_dep.as_system('system') 103*5191bae9SZane Shelleyendif 104*5191bae9SZane Shelley 105c252894dSZane Shelley#------------------------------------------------------------------------------- 106d9573f48SZane Shelley# Build the local static libraries 107c252894dSZane Shelley#------------------------------------------------------------------------------- 108c252894dSZane Shelley 1090205f3b3SBen Tynersubdir('analyzer') 110ef320154SBen Tynersubdir('attn') 111f80482a5SZane Shelleysubdir('util') 112248cbf83SZane Shelley 113c252894dSZane Shelleyhwdiags_libs = [ 114c252894dSZane Shelley analyzer_lib, 115c252894dSZane Shelley attn_lib, 116c252894dSZane Shelley util_lib, 117c252894dSZane Shelley] 118c252894dSZane Shelley 119c252894dSZane Shelley#------------------------------------------------------------------------------- 120c252894dSZane Shelley# Build the executable 121c252894dSZane Shelley#------------------------------------------------------------------------------- 1228c2f8b24SBen Tyner 123d3cda742SBen Tynerno_listener_mode = get_option('nlmode') 124d3cda742SBen Tyner 125d3cda742SBen Tynerif not no_listener_mode.disabled() 126832526dfSBen Tyner executable('openpower-hw-diags', 127832526dfSBen Tyner sources : [ 'main_nl.cpp', 'cli.cpp', buildinfo ], 128c252894dSZane Shelley link_with : hwdiags_libs, 129d3cda742SBen Tyner install : true) 130d3cda742SBen Tynerelse 131832526dfSBen Tyner executable('openpower-hw-diags', 132832526dfSBen Tyner sources : [ 'main.cpp', 'cli.cpp', 'listener.cpp', buildinfo ], 1338c2f8b24SBen Tyner dependencies : [lrt, pthread], 134c252894dSZane Shelley link_with : hwdiags_libs, 13513683089SBen Tyner cpp_args : test_arg, 1360205f3b3SBen Tyner install : true) 137d3cda742SBen Tynerendif 1380205f3b3SBen Tyner 139c252894dSZane Shelley#------------------------------------------------------------------------------- 140c252894dSZane Shelley# Test, if configured 141c252894dSZane Shelley#------------------------------------------------------------------------------- 142c252894dSZane Shelley 143248cbf83SZane Shelleybuild_tests = get_option('tests') 144248cbf83SZane Shelley 145248cbf83SZane Shelleyif not build_tests.disabled() 146248cbf83SZane Shelley subdir('test') 147248cbf83SZane Shelleyendif 148