blob: 0bde48731c6fa14a38a254bfb04021904e27b105 [file] [log] [blame]
Zane Shelleyf480b732020-06-11 10:05:16 -05001# See README.md for details.
Zane Shelley248cbf82019-05-03 17:07:18 -05002project('openpower-hw-diags', 'cpp',
3 version: '0.1', meson_version: '>=0.49.0',
4 default_options: [
5 'warning_level=3',
6 'werror=true',
Ben Tyner92e39fd2020-02-05 18:11:02 -06007 'cpp_std=c++17',
Zane Shelley248cbf82019-05-03 17:07:18 -05008 ])
9
Zane Shelleyd9573f42020-12-02 15:52:06 -060010#-------------------------------------------------------------------------------
11# Compiler
12#-------------------------------------------------------------------------------
13
Zane Shelleyf80482a2020-12-02 15:13:13 -060014cmplr = meson.get_compiler('cpp')
15
Zane Shelleyd9573f42020-12-02 15:52:06 -060016#-------------------------------------------------------------------------------
17# Include directories
18#-------------------------------------------------------------------------------
19
20# Only using the base directory. All header includes should provide the full
21# path from the base directory.
22incdir = include_directories('.')
23
24#-------------------------------------------------------------------------------
25# External library dependencies
26#-------------------------------------------------------------------------------
27
28# Look if the libhei library has already been built and installed. If not,
29# default to the subproject.
Zane Shelleyf480b732020-06-11 10:05:16 -050030libhei_dep = dependency('hei', fallback : ['libhei', 'libhei_dep'])
Ben Tyner92e39fd2020-02-05 18:11:02 -060031
Zane Shelley61465db2020-10-30 14:53:11 -050032sdbusplus_dep = dependency('sdbusplus', version : '>=1.0')
33dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
34
Zane Shelleyf80482a2020-12-02 15:13:13 -060035libpdbg_dep = cmplr.find_library('pdbg')
36
Ben Tyner13683082020-06-25 12:49:47 -050037# See if phosphor-logging is available, if not use test case logging code. This
38# allows for local builds outside of CI test sandbox.
39h = 'phosphor-logging/log.hpp'
Ben Tyner13683082020-06-25 12:49:47 -050040if cmplr.compiles('#include <@0@>'.format(h), name : '#include <@0@>'.format(h))
41 test_arg = []
42 phosphor_logging = true
43else
44 test_arg = [
45 '-DTEST_TRACE',
46 ]
47 phosphor_logging = false
48endif
49
Zane Shelleyc2528942020-12-02 15:42:42 -060050pthread = declare_dependency(link_args : '-pthread')
51lrt = declare_dependency(link_args : '-lrt')
52
53#-------------------------------------------------------------------------------
Zane Shelleyd9573f42020-12-02 15:52:06 -060054# Build the local static libraries
Zane Shelleyc2528942020-12-02 15:42:42 -060055#-------------------------------------------------------------------------------
56
Ben Tyner0205f3b2020-02-24 10:24:47 -060057subdir('analyzer')
Ben Tyneref320152020-01-09 10:31:23 -060058subdir('attn')
Zane Shelleyf80482a2020-12-02 15:13:13 -060059subdir('util')
Zane Shelley248cbf82019-05-03 17:07:18 -050060
Zane Shelleyc2528942020-12-02 15:42:42 -060061hwdiags_libs = [
62 analyzer_lib,
63 attn_lib,
64 util_lib,
65]
66
67#-------------------------------------------------------------------------------
68# Build the executable
69#-------------------------------------------------------------------------------
Ben Tyner8c2f8b22020-03-27 10:39:31 -050070
Ben Tynerd3cda742020-05-04 08:00:28 -050071no_listener_mode = get_option('nlmode')
72
73if not no_listener_mode.disabled()
74 executable('openpower-hw-diags', 'main_nl.cpp', 'cli.cpp',
Zane Shelleyc2528942020-12-02 15:42:42 -060075 link_with : hwdiags_libs,
Ben Tynerd3cda742020-05-04 08:00:28 -050076 install : true)
77else
78 executable('openpower-hw-diags', 'main.cpp', 'cli.cpp', 'listener.cpp',
79 dependencies : [lrt, pthread],
Zane Shelleyc2528942020-12-02 15:42:42 -060080 link_with : hwdiags_libs,
Ben Tyner13683082020-06-25 12:49:47 -050081 cpp_args : test_arg,
Ben Tynerd3cda742020-05-04 08:00:28 -050082 install : true)
83endif
Ben Tyner0205f3b2020-02-24 10:24:47 -060084
Zane Shelleyc2528942020-12-02 15:42:42 -060085#-------------------------------------------------------------------------------
86# Test, if configured
87#-------------------------------------------------------------------------------
88
Zane Shelley248cbf82019-05-03 17:07:18 -050089build_tests = get_option('tests')
90
91if not build_tests.disabled()
92 subdir('test')
93endif