blob: 89ccf90eb4be422b70dcc8e4071f740132e9b20b [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#-------------------------------------------------------------------------------
Ben Tynereea45422021-04-15 10:54:14 -050011# Versioning
12#-------------------------------------------------------------------------------
13buildinfo = vcs_tag(command: ['git', 'describe', '--always', '--long'],
14 input: 'buildinfo.hpp.in',
15 output: 'buildinfo.hpp',
16 replace_string:'@BUILDINFO@',
17 fallback: '0')
18
19#-------------------------------------------------------------------------------
Zane Shelleyd9573f42020-12-02 15:52:06 -060020# Compiler
21#-------------------------------------------------------------------------------
22
Zane Shelleyf80482a2020-12-02 15:13:13 -060023cmplr = meson.get_compiler('cpp')
24
Zane Shelleyd9573f42020-12-02 15:52:06 -060025#-------------------------------------------------------------------------------
Zane Shelley3a851082021-03-23 16:45:28 -050026# Config file
27#-------------------------------------------------------------------------------
28
29conf = configuration_data()
30
31conf.set('CONFIG_PHAL_API', get_option('phal').enabled())
32
33configure_file(input: 'config.h.in', output: 'config.h', configuration: conf)
34
35#-------------------------------------------------------------------------------
Zane Shelleyd9573f42020-12-02 15:52:06 -060036# Include directories
37#-------------------------------------------------------------------------------
38
39# Only using the base directory. All header includes should provide the full
40# path from the base directory.
41incdir = include_directories('.')
42
43#-------------------------------------------------------------------------------
44# External library dependencies
45#-------------------------------------------------------------------------------
46
47# Look if the libhei library has already been built and installed. If not,
48# default to the subproject.
Zane Shelleyf480b732020-06-11 10:05:16 -050049libhei_dep = dependency('hei', fallback : ['libhei', 'libhei_dep'])
Ben Tyner92e39fd2020-02-05 18:11:02 -060050
Zane Shelley61465db2020-10-30 14:53:11 -050051sdbusplus_dep = dependency('sdbusplus', version : '>=1.0')
52dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
53
Zane Shelleyf80482a2020-12-02 15:13:13 -060054libpdbg_dep = cmplr.find_library('pdbg')
55
Ben Tyner13683082020-06-25 12:49:47 -050056# See if phosphor-logging is available, if not use test case logging code. This
57# allows for local builds outside of CI test sandbox.
58h = 'phosphor-logging/log.hpp'
Ben Tyner13683082020-06-25 12:49:47 -050059if cmplr.compiles('#include <@0@>'.format(h), name : '#include <@0@>'.format(h))
60 test_arg = []
61 phosphor_logging = true
62else
63 test_arg = [
64 '-DTEST_TRACE',
65 ]
66 phosphor_logging = false
67endif
68
Zane Shelleyc2528942020-12-02 15:42:42 -060069pthread = declare_dependency(link_args : '-pthread')
70lrt = declare_dependency(link_args : '-lrt')
71
72#-------------------------------------------------------------------------------
Zane Shelleyd9573f42020-12-02 15:52:06 -060073# Build the local static libraries
Zane Shelleyc2528942020-12-02 15:42:42 -060074#-------------------------------------------------------------------------------
75
Ben Tyner0205f3b2020-02-24 10:24:47 -060076subdir('analyzer')
Ben Tyneref320152020-01-09 10:31:23 -060077subdir('attn')
Zane Shelleyf80482a2020-12-02 15:13:13 -060078subdir('util')
Zane Shelley248cbf82019-05-03 17:07:18 -050079
Zane Shelleyc2528942020-12-02 15:42:42 -060080hwdiags_libs = [
81 analyzer_lib,
82 attn_lib,
83 util_lib,
84]
85
86#-------------------------------------------------------------------------------
87# Build the executable
88#-------------------------------------------------------------------------------
Ben Tyner8c2f8b22020-03-27 10:39:31 -050089
Ben Tynerd3cda742020-05-04 08:00:28 -050090no_listener_mode = get_option('nlmode')
91
92if not no_listener_mode.disabled()
Ben Tyner832526d2021-05-05 13:34:28 -050093 executable('openpower-hw-diags',
94 sources : [ 'main_nl.cpp', 'cli.cpp', buildinfo ],
Zane Shelleyc2528942020-12-02 15:42:42 -060095 link_with : hwdiags_libs,
Ben Tynerd3cda742020-05-04 08:00:28 -050096 install : true)
97else
Ben Tyner832526d2021-05-05 13:34:28 -050098 executable('openpower-hw-diags',
99 sources : [ 'main.cpp', 'cli.cpp', 'listener.cpp', buildinfo ],
Ben Tynerd3cda742020-05-04 08:00:28 -0500100 dependencies : [lrt, pthread],
Zane Shelleyc2528942020-12-02 15:42:42 -0600101 link_with : hwdiags_libs,
Ben Tyner13683082020-06-25 12:49:47 -0500102 cpp_args : test_arg,
Ben Tynerd3cda742020-05-04 08:00:28 -0500103 install : true)
104endif
Ben Tyner0205f3b2020-02-24 10:24:47 -0600105
Zane Shelleyc2528942020-12-02 15:42:42 -0600106#-------------------------------------------------------------------------------
107# Test, if configured
108#-------------------------------------------------------------------------------
109
Zane Shelley248cbf82019-05-03 17:07:18 -0500110build_tests = get_option('tests')
111
112if not build_tests.disabled()
113 subdir('test')
114endif