blob: 514e94c0ac79345471e517a94d2106373f31359f [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 Shelleyd2854b72021-08-04 22:23:20 -050010# Package directory root, which will contain required data files.
11package_dir = join_paths( get_option('prefix'),
12 get_option('datadir'),
13 meson.project_name() )
14
15# Compiler option so that source knows the package directory.
16package_args = [ '-DPACKAGE_DIR="' + package_dir + '/"' ]
17
Zane Shelleyd9573f42020-12-02 15:52:06 -060018#-------------------------------------------------------------------------------
Ben Tynereea45422021-04-15 10:54:14 -050019# Versioning
20#-------------------------------------------------------------------------------
21buildinfo = vcs_tag(command: ['git', 'describe', '--always', '--long'],
22 input: 'buildinfo.hpp.in',
23 output: 'buildinfo.hpp',
24 replace_string:'@BUILDINFO@',
25 fallback: '0')
26
27#-------------------------------------------------------------------------------
Zane Shelleyd9573f42020-12-02 15:52:06 -060028# Compiler
29#-------------------------------------------------------------------------------
30
Zane Shelleyf80482a2020-12-02 15:13:13 -060031cmplr = meson.get_compiler('cpp')
32
Zane Shelleyd9573f42020-12-02 15:52:06 -060033#-------------------------------------------------------------------------------
Zane Shelley3a851082021-03-23 16:45:28 -050034# Config file
35#-------------------------------------------------------------------------------
36
37conf = configuration_data()
38
39conf.set('CONFIG_PHAL_API', get_option('phal').enabled())
40
41configure_file(input: 'config.h.in', output: 'config.h', configuration: conf)
42
43#-------------------------------------------------------------------------------
Zane Shelleyd9573f42020-12-02 15:52:06 -060044# Include directories
45#-------------------------------------------------------------------------------
46
47# Only using the base directory. All header includes should provide the full
48# path from the base directory.
49incdir = include_directories('.')
50
51#-------------------------------------------------------------------------------
52# External library dependencies
53#-------------------------------------------------------------------------------
54
55# Look if the libhei library has already been built and installed. If not,
56# default to the subproject.
Zane Shelleyf480b732020-06-11 10:05:16 -050057libhei_dep = dependency('hei', fallback : ['libhei', 'libhei_dep'])
Ben Tyner92e39fd2020-02-05 18:11:02 -060058
Zane Shelley61465db2020-10-30 14:53:11 -050059sdbusplus_dep = dependency('sdbusplus', version : '>=1.0')
60dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
61
Zane Shelleyf80482a2020-12-02 15:13:13 -060062libpdbg_dep = cmplr.find_library('pdbg')
63
Ben Tyner13683082020-06-25 12:49:47 -050064# See if phosphor-logging is available, if not use test case logging code. This
65# allows for local builds outside of CI test sandbox.
66h = 'phosphor-logging/log.hpp'
Ben Tyner13683082020-06-25 12:49:47 -050067if cmplr.compiles('#include <@0@>'.format(h), name : '#include <@0@>'.format(h))
68 test_arg = []
69 phosphor_logging = true
70else
71 test_arg = [
72 '-DTEST_TRACE',
73 ]
74 phosphor_logging = false
75endif
76
Zane Shelleyc2528942020-12-02 15:42:42 -060077pthread = declare_dependency(link_args : '-pthread')
78lrt = declare_dependency(link_args : '-lrt')
79
80#-------------------------------------------------------------------------------
Zane Shelleyd9573f42020-12-02 15:52:06 -060081# Build the local static libraries
Zane Shelleyc2528942020-12-02 15:42:42 -060082#-------------------------------------------------------------------------------
83
Ben Tyner0205f3b2020-02-24 10:24:47 -060084subdir('analyzer')
Ben Tyneref320152020-01-09 10:31:23 -060085subdir('attn')
Zane Shelleyf80482a2020-12-02 15:13:13 -060086subdir('util')
Zane Shelley248cbf82019-05-03 17:07:18 -050087
Zane Shelleyc2528942020-12-02 15:42:42 -060088hwdiags_libs = [
89 analyzer_lib,
90 attn_lib,
91 util_lib,
92]
93
94#-------------------------------------------------------------------------------
95# Build the executable
96#-------------------------------------------------------------------------------
Ben Tyner8c2f8b22020-03-27 10:39:31 -050097
Ben Tynerd3cda742020-05-04 08:00:28 -050098no_listener_mode = get_option('nlmode')
99
100if not no_listener_mode.disabled()
Ben Tyner832526d2021-05-05 13:34:28 -0500101 executable('openpower-hw-diags',
102 sources : [ 'main_nl.cpp', 'cli.cpp', buildinfo ],
Zane Shelleyc2528942020-12-02 15:42:42 -0600103 link_with : hwdiags_libs,
Ben Tynerd3cda742020-05-04 08:00:28 -0500104 install : true)
105else
Ben Tyner832526d2021-05-05 13:34:28 -0500106 executable('openpower-hw-diags',
107 sources : [ 'main.cpp', 'cli.cpp', 'listener.cpp', buildinfo ],
Ben Tynerd3cda742020-05-04 08:00:28 -0500108 dependencies : [lrt, pthread],
Zane Shelleyc2528942020-12-02 15:42:42 -0600109 link_with : hwdiags_libs,
Ben Tyner13683082020-06-25 12:49:47 -0500110 cpp_args : test_arg,
Ben Tynerd3cda742020-05-04 08:00:28 -0500111 install : true)
112endif
Ben Tyner0205f3b2020-02-24 10:24:47 -0600113
Zane Shelleyc2528942020-12-02 15:42:42 -0600114#-------------------------------------------------------------------------------
115# Test, if configured
116#-------------------------------------------------------------------------------
117
Zane Shelley248cbf82019-05-03 17:07:18 -0500118build_tests = get_option('tests')
119
120if not build_tests.disabled()
121 subdir('test')
122endif