blob: c2a74c7f209887ca6bf15afe8f0fe4435c3b3763 [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',
8 'cpp_args=-Wno-unused-parameter'
Zane Shelley248cbf82019-05-03 17:07:18 -05009 ])
10
Zane Shelleyd9573f42020-12-02 15:52:06 -060011#-------------------------------------------------------------------------------
12# Compiler
13#-------------------------------------------------------------------------------
14
Zane Shelleyf80482a2020-12-02 15:13:13 -060015cmplr = meson.get_compiler('cpp')
16
Zane Shelleyd9573f42020-12-02 15:52:06 -060017#-------------------------------------------------------------------------------
18# Include directories
19#-------------------------------------------------------------------------------
20
21# Only using the base directory. All header includes should provide the full
22# path from the base directory.
23incdir = include_directories('.')
24
25#-------------------------------------------------------------------------------
26# External library dependencies
27#-------------------------------------------------------------------------------
28
29# Look if the libhei library has already been built and installed. If not,
30# default to the subproject.
Zane Shelleyf480b732020-06-11 10:05:16 -050031libhei_dep = dependency('hei', fallback : ['libhei', 'libhei_dep'])
Ben Tyner92e39fd2020-02-05 18:11:02 -060032
Zane Shelley61465db2020-10-30 14:53:11 -050033sdbusplus_dep = dependency('sdbusplus', version : '>=1.0')
34dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
35
Zane Shelleyf80482a2020-12-02 15:13:13 -060036libpdbg_dep = cmplr.find_library('pdbg')
37
Ben Tyner13683082020-06-25 12:49:47 -050038# See if phosphor-logging is available, if not use test case logging code. This
39# allows for local builds outside of CI test sandbox.
40h = 'phosphor-logging/log.hpp'
Ben Tyner13683082020-06-25 12:49:47 -050041if cmplr.compiles('#include <@0@>'.format(h), name : '#include <@0@>'.format(h))
42 test_arg = []
43 phosphor_logging = true
44else
45 test_arg = [
46 '-DTEST_TRACE',
47 ]
48 phosphor_logging = false
49endif
50
Zane Shelleyc2528942020-12-02 15:42:42 -060051pthread = declare_dependency(link_args : '-pthread')
52lrt = declare_dependency(link_args : '-lrt')
53
54#-------------------------------------------------------------------------------
Zane Shelleyd9573f42020-12-02 15:52:06 -060055# Build the local static libraries
Zane Shelleyc2528942020-12-02 15:42:42 -060056#-------------------------------------------------------------------------------
57
Ben Tyner0205f3b2020-02-24 10:24:47 -060058subdir('analyzer')
Ben Tyneref320152020-01-09 10:31:23 -060059subdir('attn')
Zane Shelleyf80482a2020-12-02 15:13:13 -060060subdir('util')
Zane Shelley248cbf82019-05-03 17:07:18 -050061
Zane Shelleyc2528942020-12-02 15:42:42 -060062hwdiags_libs = [
63 analyzer_lib,
64 attn_lib,
65 util_lib,
66]
67
68#-------------------------------------------------------------------------------
69# Build the executable
70#-------------------------------------------------------------------------------
Ben Tyner8c2f8b22020-03-27 10:39:31 -050071
Ben Tynerd3cda742020-05-04 08:00:28 -050072no_listener_mode = get_option('nlmode')
73
74if not no_listener_mode.disabled()
75 executable('openpower-hw-diags', 'main_nl.cpp', 'cli.cpp',
Zane Shelleyc2528942020-12-02 15:42:42 -060076 link_with : hwdiags_libs,
Ben Tynerd3cda742020-05-04 08:00:28 -050077 install : true)
78else
79 executable('openpower-hw-diags', 'main.cpp', 'cli.cpp', 'listener.cpp',
80 dependencies : [lrt, pthread],
Zane Shelleyc2528942020-12-02 15:42:42 -060081 link_with : hwdiags_libs,
Ben Tyner13683082020-06-25 12:49:47 -050082 cpp_args : test_arg,
Ben Tynerd3cda742020-05-04 08:00:28 -050083 install : true)
84endif
Ben Tyner0205f3b2020-02-24 10:24:47 -060085
Zane Shelleyc2528942020-12-02 15:42:42 -060086#-------------------------------------------------------------------------------
87# Test, if configured
88#-------------------------------------------------------------------------------
89
Zane Shelley248cbf82019-05-03 17:07:18 -050090build_tests = get_option('tests')
91
92if not build_tests.disabled()
93 subdir('test')
94endif
Zane Shelleyc2528942020-12-02 15:42:42 -060095