blob: 1928783717a62f166de159cb86a38f9608d0cb72 [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#-------------------------------------------------------------------------------
Zane Shelley3a851082021-03-23 16:45:28 -050017# Config file
18#-------------------------------------------------------------------------------
19
20conf = configuration_data()
21
22conf.set('CONFIG_PHAL_API', get_option('phal').enabled())
23
24configure_file(input: 'config.h.in', output: 'config.h', configuration: conf)
25
26#-------------------------------------------------------------------------------
Zane Shelleyd9573f42020-12-02 15:52:06 -060027# Include directories
28#-------------------------------------------------------------------------------
29
30# Only using the base directory. All header includes should provide the full
31# path from the base directory.
32incdir = include_directories('.')
33
34#-------------------------------------------------------------------------------
35# External library dependencies
36#-------------------------------------------------------------------------------
37
38# Look if the libhei library has already been built and installed. If not,
39# default to the subproject.
Zane Shelleyf480b732020-06-11 10:05:16 -050040libhei_dep = dependency('hei', fallback : ['libhei', 'libhei_dep'])
Ben Tyner92e39fd2020-02-05 18:11:02 -060041
Zane Shelley61465db2020-10-30 14:53:11 -050042sdbusplus_dep = dependency('sdbusplus', version : '>=1.0')
43dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
44
Zane Shelleyf80482a2020-12-02 15:13:13 -060045libpdbg_dep = cmplr.find_library('pdbg')
46
Ben Tyner13683082020-06-25 12:49:47 -050047# See if phosphor-logging is available, if not use test case logging code. This
48# allows for local builds outside of CI test sandbox.
49h = 'phosphor-logging/log.hpp'
Ben Tyner13683082020-06-25 12:49:47 -050050if cmplr.compiles('#include <@0@>'.format(h), name : '#include <@0@>'.format(h))
51 test_arg = []
52 phosphor_logging = true
53else
54 test_arg = [
55 '-DTEST_TRACE',
56 ]
57 phosphor_logging = false
58endif
59
Zane Shelleyc2528942020-12-02 15:42:42 -060060pthread = declare_dependency(link_args : '-pthread')
61lrt = declare_dependency(link_args : '-lrt')
62
63#-------------------------------------------------------------------------------
Zane Shelleyd9573f42020-12-02 15:52:06 -060064# Build the local static libraries
Zane Shelleyc2528942020-12-02 15:42:42 -060065#-------------------------------------------------------------------------------
66
Ben Tyner0205f3b2020-02-24 10:24:47 -060067subdir('analyzer')
Ben Tyneref320152020-01-09 10:31:23 -060068subdir('attn')
Zane Shelleyf80482a2020-12-02 15:13:13 -060069subdir('util')
Zane Shelley248cbf82019-05-03 17:07:18 -050070
Zane Shelleyc2528942020-12-02 15:42:42 -060071hwdiags_libs = [
72 analyzer_lib,
73 attn_lib,
74 util_lib,
75]
76
77#-------------------------------------------------------------------------------
78# Build the executable
79#-------------------------------------------------------------------------------
Ben Tyner8c2f8b22020-03-27 10:39:31 -050080
Ben Tynerd3cda742020-05-04 08:00:28 -050081no_listener_mode = get_option('nlmode')
82
83if not no_listener_mode.disabled()
84 executable('openpower-hw-diags', 'main_nl.cpp', 'cli.cpp',
Zane Shelleyc2528942020-12-02 15:42:42 -060085 link_with : hwdiags_libs,
Ben Tynerd3cda742020-05-04 08:00:28 -050086 install : true)
87else
88 executable('openpower-hw-diags', 'main.cpp', 'cli.cpp', 'listener.cpp',
89 dependencies : [lrt, pthread],
Zane Shelleyc2528942020-12-02 15:42:42 -060090 link_with : hwdiags_libs,
Ben Tyner13683082020-06-25 12:49:47 -050091 cpp_args : test_arg,
Ben Tynerd3cda742020-05-04 08:00:28 -050092 install : true)
93endif
Ben Tyner0205f3b2020-02-24 10:24:47 -060094
Zane Shelleyc2528942020-12-02 15:42:42 -060095#-------------------------------------------------------------------------------
96# Test, if configured
97#-------------------------------------------------------------------------------
98
Zane Shelley248cbf82019-05-03 17:07:18 -050099build_tests = get_option('tests')
100
101if not build_tests.disabled()
102 subdir('test')
103endif